From 94fd5d1ce919102913db3c730daa0c18bcdf1c5e Mon Sep 17 00:00:00 2001 From: Job Date: Sun, 22 Nov 2026 16:07:45 +0000 Subject: [PATCH] fix: check out with git, sign local builds with a test key gitea-runner 6 has no builtin:checkout, and plain Fedora has no Node.js for actions/checkout, so the workflow fetches the commit with git. Setting permissions: keeps read access for that and asks for package writes. mkosi genkey won't replace mkosi.crt, so the docs now sign local builds with a test key in mkosi.local.conf, which also covers the PCR and verity keys. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/os.yml | 15 ++++++++++++++- .gitignore | 1 + AGENTS.md | 3 ++- README.md | 22 ++++++++++++++++++++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/os.yml b/.gitea/workflows/os.yml index 168faf0..651008d 100644 --- a/.gitea/workflows/os.yml +++ b/.gitea/workflows/os.yml @@ -19,11 +19,24 @@ on: jobs: os: runs-on: linux + # permissions lets gitea.token check out the repository and publish the + # package. + permissions: + contents: read + packages: write steps: - name: Install tools run: dnf install -yq mkosi git-core + # Check out fetches the commit with git, because the job image has no + # Node.js for actions/checkout. - name: Check out - uses: builtin:checkout + env: + AUTH: "Authorization: token ${{ gitea.token }}" + run: | + git init -q + git -c http.extraHeader="$AUTH" fetch -q --depth 1 \ + "${{ gitea.server_url }}/${{ gitea.repository }}" "${{ gitea.sha }}" + git checkout -q FETCH_HEAD - name: Build env: KEY: ${{ secrets.SECUREBOOT_KEY }} diff --git a/.gitignore b/.gitignore index 931bdcd..7654f12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ mkosi.key mkosi.output/ mkosi.cache/ +mkosi.local.conf diff --git a/AGENTS.md b/AGENTS.md index 3dfbc82..4fe5530 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -66,7 +66,6 @@ CMD ["/sbin/init"] END podman run -d --name mkosi --privileged --systemd=always -v :/repo \ -v mkosi-cache:/root/.cache/mkosi -v mkosi-work:/var/tmp -w /repo mkosi-vm -podman exec mkosi mkosi genkey # Run this once, if there is no mkosi.key. podman exec mkosi mkdir -p mkosi.cache podman exec -d -t mkosi sh -c 'mkosi -i -f \ --kernel-command-line-extra=console=ttyS0 vm -- -serial chardev:console \ @@ -74,6 +73,8 @@ podman exec -d -t mkosi sh -c 'mkosi -i -f \ podman exec mkosi mkosi ssh -- systemctl --failed ``` +- mkosi signs with the test key of `mkosi.local.conf` + ([README.md](README.md#development)), with paths as the container sees them. - `mkosi -i` keeps the image with its packages installed in `mkosi.cache/`. Rebuilds start from it and skip installing packages. - The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off overlayfs. diff --git a/README.md b/README.md index aea64f5..92d8379 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,29 @@ itself up as at first boot. ## Development +`mkosi build` signs with `mkosi.key`, the private key of `mkosi.crt`, which +only CI has (the `SECUREBOOT_KEY` secret). `mkosi genkey` won't replace +`mkosi.crt`, so local builds sign with a test key. Make one: + ```sh -mkosi genkey # This is for local tests. CI uses the SECUREBOOT_KEY secret. -mkosi build +openssl req -new -x509 -newkey rsa:2048 -nodes -subj /CN=test \ + -keyout ~/test.key -out ~/test.crt ``` +and point `mkosi.local.conf` at it, which mkosi reads and git ignores: + +```ini +[Validation] +SecureBootKey=~/test.key +SecureBootCertificate=~/test.crt +SignExpectedPcrKey=~/test.key +SignExpectedPcrCertificate=~/test.crt +VerityKey=~/test.key +VerityCertificate=~/test.crt +``` + +Then run `mkosi build`. + `mkosi.output/` then holds the disk image (`agentos_.raw`) and the UKI and /usr partitions that make up an update.