diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 68d907d..e168a8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,14 @@ name: Release # per-architecture workflow artifacts for review/testing. # - tag push v*.*.*: publishes a stable release at that tag. # - workflow_dispatch: manual run for ad-hoc rebuilds. +# +# Every published .deb gets a GitHub build-provenance attestation, recorded in +# the public Sigstore transparency log. It ties the package's digest to this +# repository, workflow and commit, so anyone can check that a SmoothKernel +# package (from a release or from the Smooth* apt repository, which publishes +# them unmodified) was built here: +# +# gh attestation verify .deb --repo RakuenSoftware/smoothkernel on: push: branches: [main] @@ -22,6 +30,8 @@ on: permissions: contents: write + id-token: write # build-provenance attestations (Sigstore) + attestations: write env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true @@ -35,6 +45,7 @@ jobs: prerelease: ${{ steps.meta.outputs.prerelease }} kernel_version: ${{ steps.meta.outputs.kernel_version }} zfs_version: ${{ steps.meta.outputs.zfs_version }} + build_number: ${{ steps.meta.outputs.build_number }} steps: - uses: actions/checkout@v4 with: @@ -47,6 +58,9 @@ jobs: KERNEL_VERSION="$(awk -F= '/^KERNEL_VERSION=/ {gsub(/[ \t]/,""); print $2; exit}' examples/smooth.env)" ZFS_VERSION="$(awk -F= '/^ZFS_VERSION=/ {gsub(/[ \t]/,""); print $2; exit}' examples/smooth.env)" SHORT_SHA="$(git rev-parse --short HEAD)" + # Package versions and the kernel release carry it (see + # recipes/build-number.sh); computed once so every job agrees. + BUILD_NUMBER="$(recipes/build-number.sh)" if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then TAG="${GITHUB_REF#refs/tags/}" @@ -63,6 +77,8 @@ jobs: echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT" echo "kernel_version=${KERNEL_VERSION}" >> "$GITHUB_OUTPUT" echo "zfs_version=${ZFS_VERSION}" >> "$GITHUB_OUTPUT" + echo "build_number=${BUILD_NUMBER}" >> "$GITHUB_OUTPUT" + echo "SmoothKernel ${KERNEL_VERSION} build ${BUILD_NUMBER}: kernel release ${KERNEL_VERSION}-${BUILD_NUMBER}-smoothkernel" build: needs: meta @@ -76,6 +92,8 @@ jobs: runner: ubuntu-24.04-arm runs-on: ${{ matrix.runner }} timeout-minutes: 180 + env: + BUILD_NUMBER: ${{ needs.meta.outputs.build_number }} steps: - uses: actions/checkout@v4 with: @@ -111,8 +129,9 @@ jobs: # workspace so it is never picked up by artifact upload, and is removed # again by the cleanup step below (which runs even if the build fails). # - # Fork PRs do not receive secrets. Those builds still run, but produce - # unsigned developer artifacts marked as not promotable. + # Without the secrets (fork PRs never get them) the build still runs and + # produces an unsigned kernel, marked as such, which runs only with + # Secure Boot off. - name: Materialize signing material id: signing env: @@ -151,7 +170,7 @@ jobs: echo "Signing material present: modules + kernel image." else echo "signed=0" >> "$GITHUB_OUTPUT" - echo "::warning::Signing secrets absent or incomplete (modules=$have_modsig, secureboot=$have_sb). Artifacts will be UNSIGNED developer builds and are not promotable." + echo "::warning::Signing secrets absent or incomplete (modules=$have_modsig, secureboot=$have_sb). The kernel is unsigned and runs only with Secure Boot off." fi - name: Install signing tools @@ -217,17 +236,19 @@ jobs: - name: Mark unsigned build if: steps.signing.outputs.signed != '1' run: | - echo "::warning::This build is UNSIGNED and not promotable per docs/signing.md." + echo "::warning::This build is UNSIGNED: it runs only with Secure Boot off (docs/signing.md)." mkdir -p "out/${{ matrix.deb_arch }}" - cat > "out/${{ matrix.deb_arch }}/UNSIGNED-NOT-PROMOTABLE.txt" <<'EOF' - These packages were built without release signing material. + cat > "out/${{ matrix.deb_arch }}/UNSIGNED.txt" <<'EOF' + These packages were built without signing material. Packaged modules carry an ephemeral "Build time autogenerated kernel - key" and the kernel image has no EFI signature, so it will be refused - by shim on a Secure Boot machine ("bad shim signature"). + key" and the kernel image has no EFI signature, so shim refuses it on + a Secure Boot machine ("bad shim signature"). Run it with Secure Boot + off. See docs/signing.md. - Valid for development and functional testing. NOT promotable to the - apt repo. See docs/signing.md. + Where the packages came from is shown by their build-provenance + attestations, not by signing: + gh attestation verify .deb --repo RakuenSoftware/smoothkernel EOF - name: Stage release artifacts @@ -237,14 +258,22 @@ jobs: cp "out/${{ matrix.deb_arch }}"/*.deb "dist/${{ matrix.deb_arch }}/" # The unsigned-build marker is not a .deb, so it has to be copied # explicitly or it never leaves out/ — the artifact would then look - # identical to a promotable one, which is the whole point of it. - marker="out/${{ matrix.deb_arch }}/UNSIGNED-NOT-PROMOTABLE.txt" + # identical to a signed one, which is the whole point of it. + marker="out/${{ matrix.deb_arch }}/UNSIGNED.txt" if [ -f "$marker" ]; then cp "$marker" "dist/${{ matrix.deb_arch }}/" echo "staged unsigned-build marker" fi (cd "dist/${{ matrix.deb_arch }}" && sha256sum *.deb > "SHA256SUMS.${{ matrix.deb_arch }}") ls -lh "dist/${{ matrix.deb_arch }}/" + # Publish each package's identity as a run annotation: annotations + # are readable without GitHub auth, unlike logs and artifacts, so + # anyone can check names, versions and dependencies of a build. + summary="" + for deb in "dist/${{ matrix.deb_arch }}"/*.deb; do + summary+="$(dpkg-deb -W --showformat='${Package} ${Version} Depends: ${Depends} Provides: ${Provides}' "$deb")%0A" + done + echo "::notice title=packages ${{ matrix.deb_arch }}::${summary}" - name: Upload package artifact uses: actions/upload-artifact@v4 @@ -292,13 +321,13 @@ jobs: done # Carry the unsigned-build marker into the published release. Without - # this the release assets are indistinguishable from a promotable - # build, which is exactly what the marker exists to prevent. + # this the release assets are indistinguishable from a signed build, + # which is exactly what the marker exists to prevent. for arch in amd64 arm64; do - m="release-input/packages-${arch}/UNSIGNED-NOT-PROMOTABLE.txt" + m="release-input/packages-${arch}/UNSIGNED.txt" if [ -f "$m" ]; then cp "$m" dist/ - echo "::warning::This release was built WITHOUT signing material and is not promotable." + echo "::warning::This release was built WITHOUT signing material; it runs only with Secure Boot off." break fi done @@ -312,6 +341,8 @@ jobs: printf ' "tag": "%s",\n' "${{ needs.meta.outputs.tag }}" printf ' "kernel_version": "%s",\n' "${{ needs.meta.outputs.kernel_version }}" printf ' "zfs_version": "%s",\n' "${{ needs.meta.outputs.zfs_version }}" + printf ' "build_number": %s,\n' "${{ needs.meta.outputs.build_number }}" + printf ' "kernel_release": "%s",\n' "${{ needs.meta.outputs.kernel_version }}-${{ needs.meta.outputs.build_number }}-smoothkernel" printf ' "commit": "%s",\n' "${GITHUB_SHA}" printf ' "architectures": ["amd64", "arm64"],\n' printf ' "artifacts": [\n' @@ -331,6 +362,11 @@ jobs: ls -lh dist/ + - name: Attest build provenance + uses: actions/attest-build-provenance@v2 + with: + subject-path: dist/*.deb + - name: Create GitHub release uses: softprops/action-gh-release@v2 with: @@ -342,5 +378,5 @@ jobs: dist/*.deb dist/SHA256SUMS dist/manifest.json - dist/UNSIGNED-NOT-PROMOTABLE.txt + dist/UNSIGNED.txt generate_release_notes: true diff --git a/README.md b/README.md index 857b5ed..1e5bf76 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ smoothkernel/ |-- recipes/ | |-- build-kernel.sh Kernel build recipe | |-- build-zfs.sh OpenZFS package recipe -| `-- stamp-version.sh Version helper +| `-- build-number.sh Build number for package versions |-- templates/ | |-- dkms.conf.in DKMS package template | |-- debian-postinst.in DKMS register/build/install hook diff --git a/docs/APT_REPO.md b/docs/APT_REPO.md index 624dd51..4bebc4a 100644 --- a/docs/APT_REPO.md +++ b/docs/APT_REPO.md @@ -2,12 +2,13 @@ Design for the Smooth* apt repository: suite layout, component choices, pinning, promotion, and the minimum repository mechanics the rest of this doc set assumes. -The sibling `apt-repo` repo may carry the implementation details, but the cross-repo contract is: +The repository is [`smoothapt`](https://github.com/RakuenSoftware/smoothapt), which carries the implementation details. The cross-repo contract is: -- `pool/` and `dists/` are committed artifacts, not generated on the web host -- `scripts/add-package.sh` adds packages, refreshes indices, and updates `Release` metadata -- `Origin: RakuenSoftware` is set in each signed `Release` file -- CI signs `Release` / `InRelease`, publishes `public-key.asc`, and deploys the static tree +- It runs on the VPS and ingests every Smooth* project from that project's GitHub releases: SmoothKernel into `common`, each product into its own suite. Builds happen only in each project's GitHub pipeline; `smoothapt` never builds, re-signs or re-versions a package. +- Before ingesting a package it verifies the package's build-provenance attestation against the project's repository, so every package in the repository is traceable to a public pipeline run (SmoothKernel: [CI_RELEASES.md](CI_RELEASES.md#provenance)). +- The archive (`pool/`, `dists/`) lives on the server, not in git. +- `Origin: RakuenSoftware` is set in each signed `Release` file, and `public-key.asc` is published alongside. +- The `smoothrouter` suite, and its packages, are served only to clients with a per-user credential that can be revoked. ## Suite layout @@ -92,7 +93,7 @@ This keeps our version strictly greater than Debian's (`25.2.3` alone or `25.2.3 ## Promotion -v1 (now): one suite per flavor, `main` component, direct publish. Matches the existing `apt-repo` shape. +v1 (now): one suite per flavor, `main` component, direct publish. v2 (when rebase pain justifies it): introduce a `testing` suite tree mirrored from `common`/`smoothnas`/etc. CI builds land in `testing-`; soak for N days; a promotion script copies approved packages across. Keeps the producer-side simple while letting us de-risk kernel bumps. @@ -100,21 +101,11 @@ The promotion machinery is non-trivial (needs to preserve signatures or re-sign) ## Signing and key custody -Already addressed in `apt-repo/README.md` (Section: One-time setup). Single signing key, stored as GitHub repo secret `APT_SIGNING_KEY`. Key-id as `APT_SIGNING_KEY_ID`. Public half served as `public-key.asc` from the repo root; consumers dearmor into `/etc/apt/keyrings/smooth-archive-keyring.gpg`. - -Not changing this — the existing shape is fine. +Single repository signing key; custody is documented in `smoothapt`. Public half served as `public-key.asc`; consumers dearmor into `/etc/apt/keyrings/smooth-archive-keyring.gpg`. ## Hosting -GitHub Pages (current). Mirrorable to any static HTTP server — `dists/` is committed, so a `git clone` into `/var/www/apt-repo` is a complete mirror. No server-side build needed. - -Production will eventually want: - -- A stable custom domain (`apt.rakuensoftware.com`) -- CDN in front (Cloudflare works with GitHub Pages) -- HTTPS enforced (GitHub Pages provides this) - -Out of scope until we ship to real users. +The Rakuen VPS, as a static tree behind nginx with HTTPS. `smoothapt` documents the setup. ## Out-of-tree modules and DKMS diff --git a/docs/CI_RELEASES.md b/docs/CI_RELEASES.md index ff50ebe..e9e5f8e 100644 --- a/docs/CI_RELEASES.md +++ b/docs/CI_RELEASES.md @@ -21,6 +21,32 @@ v- Tag pushes produce stable GitHub releases at the pushed tag. +## Versions + +Every build has a build number: the commit count of the built commit +(`recipes/build-number.sh`). It names the kernel and versions every package, +so each build of `main` is distinct and newer than the last: + +| Package | Example (kernel 7.2.10, build 68) | +|---|---| +| `linux-image-` | `linux-image-7.2.10-68-smoothkernel_7.2.10-68_amd64.deb` | +| `linux-headers-` | `linux-headers-7.2.10-68-smoothkernel_7.2.10-68_amd64.deb` | +| `linux-libc-dev` | `linux-libc-dev_7.2.10-68_amd64.deb` | +| `linux-image-smoothkernel` (metapackage) | `linux-image-smoothkernel_7.2.10-68_amd64.deb` | +| `linux-headers-smoothkernel` (metapackage) | `linux-headers-smoothkernel_7.2.10-68_amd64.deb` | +| OpenZFS | `zfs_2.4.4-68_amd64.deb`, `zfs-dkms_2.4.4-68_amd64.deb`, ... | + +The kernel release (`uname -r`) is `7.2.10-68-smoothkernel`, so a new build +installs alongside the running kernel rather than replacing its modules, and +the previous kernel stays bootable. Systems install the two metapackages, each +of which depends on exactly its build's package, so `apt upgrade` moves them to +every new build. Old kernels are removed by `apt autoremove`, which keeps the +running and newest ones. The versioned headers package also `Provides: +linux-headers`, for DKMS packages that depend on the generic name. + +The DKMS module version of OpenZFS stays the upstream version (`2.4.4`); only +the package revision carries the build number. + ## Build Steps The workflow: @@ -34,7 +60,25 @@ The workflow: 7. Merges amd64 and arm64 packages into `dist/`, skipping duplicate `_all.deb` assets. 8. Writes `dist/SHA256SUMS`. 9. Writes `dist/manifest.json` with artifact architectures and sha256 values. -10. Publishes a GitHub Release with `.deb`, checksum, and manifest assets. +10. Attests the build provenance of every `.deb` (see below). +11. Publishes a GitHub Release with `.deb`, checksum, and manifest assets. + +## Provenance + +Every published `.deb` carries a GitHub build-provenance attestation: a +statement signed through Sigstore and recorded in its public transparency log +that ties the package's SHA-256 to this repository, the workflow, and the +commit it was built from. Anyone can check a package, whether it came from a +GitHub Release or from the Smooth* apt repository: + +```sh +gh attestation verify linux-image-7.2.10-68-smoothkernel_7.2.10-68_amd64.deb \ + --repo RakuenSoftware/smoothkernel +``` + +The apt repository publishes these packages byte for byte as released, so the +checksums in its indices are the attested ones. Nothing downstream rebuilds, +re-signs or re-versions a SmoothKernel package. ## Manifest @@ -44,13 +88,13 @@ release contents. It records: - Release tag. - Kernel version. - ZFS version. +- Build number and kernel release (`uname -r`). - Git commit. - Supported architectures. - Artifact names, Debian architecture suffixes, and sha256 values. -Consumers should still verify package signatures and apt repository metadata -when installing from the Smooth* apt repo. The GitHub Release manifest is an -artifact inventory, not a substitute for apt trust. +The manifest is an artifact inventory, not a statement of provenance; that is +what the attestations are. ## GitHub Release vs Apt Promotion @@ -59,24 +103,27 @@ itself mean "these artifacts are promoted to users." Promotion to the Smooth* apt repository requires: -- Release-grade provenance checks. -- Signing requirements from [signing.md](signing.md). +- A valid build-provenance attestation for every package, from this + repository's release workflow. The apt repository checks it before + ingesting a package. - Representative flavor smoke tests. - Apt repository indexing and signed `Release` / `InRelease` metadata. +Signing is not required: an unsigned release is promoted like a signed one and +runs only with Secure Boot off (see [signing.md](signing.md)). + The apt repository is the user-facing distribution mechanism. GitHub Releases are useful for builders, downstream automation, and pre-promotion testing. ## Signing Boundary -This repository must not store private module-signing keys. The production -contract in [signing.md](signing.md) requires release-built modules to be signed -by controlled CI signing material and DKMS modules to be signed on-host. +This repository must not store private module-signing keys. When signing +material is provisioned, [signing.md](signing.md) has release-built modules +signed by controlled CI signing material and DKMS modules signed on-host. -If the GitHub workflow is used for promotable artifacts, it must be wired to the -approved signing mechanism before promotion. Local developer builds and unsigned -CI builds are acceptable for bring-up and smoke testing, but they are not final -Secure-Boot release artifacts. +Without it, CI builds unsigned kernels, marked with `UNSIGNED.txt`, which run +only with Secure Boot off. Local developer builds are for bring-up and smoke +testing only; only CI-built packages are promoted. ## Failure Handling diff --git a/docs/README.md b/docs/README.md index e968460..6ba6d35 100644 --- a/docs/README.md +++ b/docs/README.md @@ -64,7 +64,7 @@ Product-level contract described here: - The Smooth* apt repository consumes and promotes release artifacts. - Flavor repositories own their daemons, UIs, meta packages, and smoke tests. -- Signing-capable CI owns release-key custody and promotable signed artifacts. +- CI builds and attests every released package; signing, when its secrets are provisioned, also happens there. - Installers own first-boot setup and flavor-specific source enablement. If a doc makes a production claim that is not implemented yet, prefer language diff --git a/docs/RELEASE_MODEL.md b/docs/RELEASE_MODEL.md index 86b395d..6b180ac 100644 --- a/docs/RELEASE_MODEL.md +++ b/docs/RELEASE_MODEL.md @@ -57,9 +57,9 @@ Kernel is the fastest-moving; expect a kernel PR every 1–2 weeks. Everything e ### v1 (now) -Single `main` component per suite. The release path builds amd64 and arm64 package artifacts, satisfies the required signing gates, commits them to `apt-repo`, GitHub Pages publishes, and users receive them on the next `apt upgrade`. No staging. +Single `main` component per suite. The release path builds amd64 and arm64 package artifacts and attests them, `smoothapt` verifies the attestations and ingests them, and users receive them on the next `apt upgrade`. No staging. -Right posture for where we are — small user base, direct deployment path, rollback is "revert the commit in apt-repo." +Right posture for where we are — small user base, direct deployment path. ### v2 (when pain justifies) @@ -77,12 +77,12 @@ Not preemptive. Operational pain is the forcing function. Today, the soak strategy is: -1. Produce a candidate build through the signing-capable release path. +1. Produce a candidate build through the CI release path. 2. Install on the minimum validation matrix: one NAS target, one router target, one HTPC target, one desktop target. 3. Boot, run flavor-specific smoke tests (mount a ZFS pool for NAS; pass traffic for router; run Kodi video decode for HTPC; boot into Plasma and launch Steam for desktop). -4. If clean, commit the .deb to apt-repo. +4. If clean, let `smoothapt` ingest the release. -Rollback: git revert in apt-repo, re-run publish. Users on stale versions are unaffected; users who upgraded get the old version back on next `apt upgrade` if we leave it — otherwise we need to ship a `.deb` with an epoch bump to force a downgrade, which is painful. Prefer "never publish known-broken" over "rollback fast." +Rollback: ship a fixed build. Every build is a new kernel installed alongside the previous one, so a box that took a bad kernel still has its last good one to boot. Removing a build from the repository does not downgrade boxes that already took it. Prefer "never publish known-broken" over "rollback fast." Per-flavor smoke test checklists will live in each flavor's repo (`SmoothNAS/docs/OPERATIONS.md` is the model). @@ -120,6 +120,6 @@ Hard deprecations (licensing, security) skip the grace cycle. ## Open questions -- **Release notes discipline.** Where do they live? Markdown files in the apt-repo itself, or per-flavor in each product repo? Leaning per-flavor for product-specific notes, cross-cutting kernel/mesa notes in `smoothkernel`. +- **Release notes discipline.** Where do they live? Markdown files in `smoothapt` itself, or per-flavor in each product repo? Leaning per-flavor for product-specific notes, cross-cutting kernel/mesa notes in `smoothkernel`. - **Hotfix kernels.** A security issue lands mid-cycle — do we rebase out-of-band or wait for the next CachyOS series? Policy: rebase out-of-band, only with CachyOS's patch series (not self-maintained). - **Dependency freeze for flavor suites.** Currently we assume trixie-stable deps for daemon packages (tierd etc.). When trixie point releases break source-incompatibility (rare but happens), rebuild vs. pin Debian point release. Defer until it bites. diff --git a/docs/bumping-kernel.md b/docs/bumping-kernel.md index cac6d6f..a1c73de 100644 --- a/docs/bumping-kernel.md +++ b/docs/bumping-kernel.md @@ -130,7 +130,7 @@ before uploading or publishing packages. It does not install or load modules. Both architectures must build clean. Kernel build failures are usually patch-conflict or config drift; ZFS build failures are usually a kernel-API break that OpenZFS hasn't caught up to yet. -Local builds are sufficient for patch/config bring-up. The promotable artifact still comes from the release path that satisfies the signing contract in [`signing.md`](signing.md) and [`CI_RELEASES.md`](CI_RELEASES.md). +Local builds are sufficient for patch/config bring-up. What users get always comes from the CI release path in [`CI_RELEASES.md`](CI_RELEASES.md), which attests every package; signing is optional (see [`signing.md`](signing.md)). ### 5. Update out-of-tree module compat shims @@ -174,22 +174,16 @@ Flavor-specific smoke tests live in their respective repos' `docs/OPERATIONS.md` ### 8. Promote to `common` main -Publish the `.deb`s to the apt repo's `common` suite via the usual path documented in the sibling `apt-repo` repository: +Promotion takes the packages of the CI release for the bump, never a local +build. [`smoothapt`](https://github.com/RakuenSoftware/smoothapt) ingests them +from the GitHub Release into the `common` suite, after verifying each package's +build-provenance attestation (see [`CI_RELEASES.md`](CI_RELEASES.md#provenance)). +Systems follow through the `linux-image-smoothkernel` and +`linux-headers-smoothkernel` metapackages on their next `apt upgrade`. -```sh -cd ../apt-repo -scripts/add-package.sh common ../smoothkernel/out/*/linux-*.deb -scripts/add-package.sh common ../smoothkernel/out/*/zfs*.deb ../smoothkernel/out/*/lib*.deb -git add pool/ dists/ -git commit -m "common: linux-smoothkernel $KERNEL_VERSION, zfs $ZFS_VERSION" -git push -``` - -Signing and GitHub Pages deploy runs in CI. - -### 9. Secure-Boot verify +### 9. Secure-Boot verify (signed releases) -Before marking the bump promotable: +When the release was built with signing material, before promoting it: - verify a CI-produced kernel package reports a non-empty signer on one packaged module - verify a Secure-Boot-enabled test machine enrolled via `smooth-secureboot` can rebuild and load ZFS diff --git a/docs/signing.md b/docs/signing.md index 227aa83..2e31b17 100644 --- a/docs/signing.md +++ b/docs/signing.md @@ -2,7 +2,9 @@ Shipped Smooth* systems support Secure Boot without giving up DKMS-delivered modules such as ZFS, `smoothfs`, or NVIDIA. -This document is the production signing contract. The repository does not store private keys. A local `make kernel` build is valid for bring-up, but an artifact is not promotable to users until the release path has satisfied the signing and verification gates below. +This document is the signing design. The repository does not store private keys. + +Signing is optional. It is what lets a kernel boot under Secure Boot; it is not what establishes where a package came from. That is the job of the build-provenance attestations every release carries (see [CI_RELEASES.md](CI_RELEASES.md)), which anyone can verify. A release built without signing material is published to the apt repository like any other. It is marked unsigned and runs only with Secure Boot off. When signing material is provisioned, the gates below apply and a failure blocks the release. The design uses two trust domains because the module sources come from two places: @@ -154,9 +156,9 @@ a live option if we want in-kernel parity rather than a command-line policy. ## Build and release flow -Developer builds are allowed to use local throwaway keys for bring-up, but only CI-produced release artifacts that satisfy this signing contract are promotable to the apt repo. +Only CI-produced release artifacts are published to the apt repo; local builds, with or without throwaway keys, are for bring-up. -Release build flow: +Release build flow, once signing material is provisioned: 1. CI fetches signing material from KMS / HSM-backed secret storage 2. Kernel build signs packaged modules with the Rakuen release key @@ -166,7 +168,7 @@ Release build flow: ### Repository secrets `.github/workflows/release.yml` reads three secrets. Provision them on the -repository (or its environment) before expecting a promotable artifact: +repository (or its environment) to build signed kernels: | Secret | Contents | |---|---| @@ -198,12 +200,12 @@ Fork pull requests do not receive secrets, and a repository that has not yet provisioned them still needs to build. In that case the workflow: - emits a warning that the build is unsigned, -- drops `UNSIGNED-NOT-PROMOTABLE.txt` into the artifact directory, +- drops `UNSIGNED.txt` into the artifact directory and the release, - and skips the signing verification gates (there is nothing to verify). -Those artifacts are valid for development and functional testing, and must not -be published to the apt repo. When secrets *are* present, the verification gates -run and a failure blocks the release rather than warning about it. +Those packages are published to the apt repo like signed ones; they run only +with Secure Boot off. When secrets *are* present, the verification gates run and +a failure blocks the release rather than warning about it. ### Local builds diff --git a/recipes/build-kernel.sh b/recipes/build-kernel.sh index 15e5f10..033117a 100755 --- a/recipes/build-kernel.sh +++ b/recipes/build-kernel.sh @@ -22,9 +22,18 @@ # MODE build (default) or update-config # STRIP_DEBUG_INFO if "1" (default), disable debug-info packaging # to slim the image and speed up packaging +# BUILD_NUMBER default recipes/build-number.sh (commit count of HEAD) # -# Signing (see docs/signing.md). All optional; unset means a developer -# build, which is explicitly NOT promotable. +# Each build is its own kernel, as Debian does it: the build number goes into +# the kernel release (7.2.10--smoothkernel) and the package version +# (7.2.10-), so a new build installs alongside the running kernel instead +# of replacing its modules, and apt sees every build as an upgrade. The +# linux-image-smoothkernel and linux-headers-smoothkernel metapackages depend +# on this build's packages; a system that installs them follows every new +# kernel through ordinary apt upgrades. +# +# Signing (see docs/signing.md). All optional; unset builds an unsigned +# kernel, which runs only with Secure Boot off. # MODULE_SIGNING_KEY PEM holding the module-signing private key AND its # certificate. Packaged modules are signed with it and # the certificate is embedded in the kernel's builtin @@ -107,6 +116,17 @@ PATCH_ROOT="$ROOT/patches" VERSIONED_CONFIG_DIR="$ROOT/configs/$KERNEL_VERSION" VERSIONED_CONFIG="$VERSIONED_CONFIG_DIR/smooth-$DEB_ARCH.config" +# The checked-in configs keep the plain LOCALVERSION; only a package build +# carries the build number. +if [[ "$MODE" == "update-config" ]]; then + CONFIG_LOCALVERSION="$LOCALVERSION" +else + BUILD_NUMBER="$("$ROOT/recipes/build-number.sh")" + CONFIG_LOCALVERSION="-${BUILD_NUMBER}${LOCALVERSION}" + KERNEL_RELEASE="${KERNEL_VERSION}${CONFIG_LOCALVERSION}" # e.g. 7.2.10-68-smoothkernel + PKG_VERSION="${KERNEL_VERSION}-${BUILD_NUMBER}" # e.g. 7.2.10-68 +fi + kernel_make_args=(ARCH="$KERNEL_ARCH" KBUILD_DEBARCH="$DEB_ARCH") if [[ -n "$CROSS_COMPILE" ]]; then kernel_make_args+=(CROSS_COMPILE="$CROSS_COMPILE") @@ -156,6 +176,34 @@ add_headers_virtual_provides() { rm -rf "$tmp" } +# Build a metapackage __.deb that depends on exactly +# this build's . Systems install the metapackage; each new build's +# metapackage pulls in that build's kernel through an ordinary apt upgrade. +build_metapackage() { + local name="$1" target="$2" description="$3" + local tmp deb maintainer + # Same maintainer as the packages bindeb-pkg built in this run. + maintainer="$(dpkg-deb -f "$OUT_DIR/linux-image-${KERNEL_RELEASE}_${PKG_VERSION}_${DEB_ARCH}.deb" Maintainer)" + tmp="$(mktemp -d)" + mkdir -p "$tmp/DEBIAN" + cat > "$tmp/DEBIAN/control" </dev/null + rm -rf "$tmp" + echo " built $(basename "$deb")" +} + # Sign the kernel image inside a built linux-image .deb, so the packaged # vmlinuz carries an EFI signature and shim will load it under Secure Boot. # bindeb-pkg has no signing step of its own, so this unpacks, signs, repacks — @@ -291,8 +339,8 @@ apply_smoothkernel_profile() { else echo "==> WARNING: MODULE_SIGNING_KEY unset — the kernel will generate an" echo " ephemeral module-signing key. Packaged modules will report" - echo " signer 'Build time autogenerated kernel key'. This is a" - echo " developer build and is NOT promotable (docs/signing.md)." + echo " signer 'Build time autogenerated kernel key'. Unsigned kernels" + echo " run only with Secure Boot off (docs/signing.md)." fi # NAS / server network-path tuning. @@ -481,7 +529,7 @@ apply_smoothkernel_profile() { scripts/config --module ACPI_CALL fi - scripts/config --set-str LOCALVERSION "$LOCALVERSION" + scripts/config --set-str LOCALVERSION "$CONFIG_LOCALVERSION" kernel_make olddefconfig /dev/null } @@ -548,19 +596,25 @@ echo "==> building (-j${BUILD_THREADS})" date # Recursive make must not inherit LOCALVERSION from the top-level wrapper, # or bindeb-pkg appends the suffix on top of CONFIG_LOCALVERSION again. -env -u LOCALVERSION -u MAKEFLAGS make "${kernel_make_args[@]}" -j"$BUILD_THREADS" bindeb-pkg +env -u LOCALVERSION -u MAKEFLAGS make "${kernel_make_args[@]}" -j"$BUILD_THREADS" \ + KDEB_PKGVERSION="$PKG_VERSION" bindeb-pkg date echo "==> collecting .debs into $OUT_DIR" shopt -s nullglob moved=() # bindeb-pkg produces linux-image / linux-image-dbg / linux-headers / -# linux-libc-dev for , where UTS_RELEASE comes from the -# checked-in .config LOCALVERSION. -LOCAL_TAG="${LOCALVERSION#-}" # strip leading '-' so "smooth" anchors the glob cleanly -for f in "../linux-image-${KERNEL_VERSION}-${LOCAL_TAG}"*"_${KERNEL_VERSION}-"*"_${DEB_ARCH}.deb" \ - "../linux-headers-${KERNEL_VERSION}-${LOCAL_TAG}"*"_${KERNEL_VERSION}-"*"_${DEB_ARCH}.deb" \ - "../linux-libc-dev_${KERNEL_VERSION}-"*"_${DEB_ARCH}.deb"; do +# linux-libc-dev for KERNEL_RELEASE, versioned PKG_VERSION. Exact names: a +# glob would also take linux-image--dbg, and stale debs from an +# earlier build left in the build directory. +for f in "../linux-image-${KERNEL_RELEASE}_${PKG_VERSION}_${DEB_ARCH}.deb" \ + "../linux-headers-${KERNEL_RELEASE}_${PKG_VERSION}_${DEB_ARCH}.deb" \ + "../linux-libc-dev_${PKG_VERSION}_${DEB_ARCH}.deb"; do + if [[ ! -f "$f" ]]; then + echo "ERROR: bindeb-pkg did not produce $(basename "$f")" >&2 + ls -la ../ | grep '\.deb$' >&2 + exit 1 + fi dest="$OUT_DIR/$(basename "$f")" cp -v "$f" "$dest" if [[ "$(basename "$dest")" == linux-headers-* ]]; then @@ -580,8 +634,14 @@ for f in "../linux-image-${KERNEL_VERSION}-${LOCAL_TAG}"*"_${KERNEL_VERSION}-"*" moved+=("$f") done if [[ ${#moved[@]} -lt 3 ]]; then - echo "ERROR: expected image + headers + libc-dev .debs, got ${#moved[@]}" >&2 + echo "ERROR: expected image + headers + libc-dev .debs for ${KERNEL_RELEASE} (${PKG_VERSION}), got ${#moved[@]}" >&2 ls -la ../ | grep '\.deb$' >&2 exit 1 fi -echo "==> done. Built ${#moved[@]} .debs in $OUT_DIR" + +echo "==> building metapackages" +build_metapackage linux-image-smoothkernel "linux-image-${KERNEL_RELEASE}" \ + "SmoothKernel image (latest build)" +build_metapackage linux-headers-smoothkernel "linux-headers-${KERNEL_RELEASE}" \ + "SmoothKernel headers (latest build)" +echo "==> done. Built ${#moved[@]} .debs + 2 metapackages for ${KERNEL_RELEASE} in $OUT_DIR" diff --git a/recipes/build-number.sh b/recipes/build-number.sh new file mode 100755 index 0000000..3422889 --- /dev/null +++ b/recipes/build-number.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# build-number.sh — print the build number for this checkout: the number of +# commits reachable from HEAD. +# +# It goes into every package version (7.2.10-, zfs 2.4.4-) and the +# kernel release (7.2.10--smoothkernel), so each build of main gets +# versions that are unique and only ever increase, and a version identifies +# the commit its packages were built from. BUILD_NUMBER in the environment +# overrides it. + +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" + +if [[ -z "${BUILD_NUMBER:-}" ]]; then + # A shallow clone counts only the commits it fetched, which would number + # this build below earlier ones and make apt treat it as a downgrade. + if [[ "$(git -C "$ROOT" rev-parse --is-shallow-repository)" == "true" ]]; then + echo "ERROR: $ROOT is a shallow clone, so its commit count is not the build number." >&2 + echo " Fetch full history (git fetch --unshallow) or set BUILD_NUMBER." >&2 + exit 1 + fi + BUILD_NUMBER="$(git -C "$ROOT" rev-list --count HEAD)" +fi + +[[ "$BUILD_NUMBER" =~ ^[1-9][0-9]*$ ]] || { + echo "ERROR: BUILD_NUMBER must be a positive integer, got '$BUILD_NUMBER'" >&2 + exit 1 +} +echo "$BUILD_NUMBER" diff --git a/recipes/build-zfs.sh b/recipes/build-zfs.sh index 69588a9..61755ff 100755 --- a/recipes/build-zfs.sh +++ b/recipes/build-zfs.sh @@ -13,6 +13,12 @@ # BUILD_THREADS -j N for make (default $(nproc)) # ZFS_PATCHSET patch lane applied to the extracted source before # autogen, e.g. zfs-$ZFS_VERSION. Unset means no patches. +# BUILD_NUMBER default recipes/build-number.sh (commit count of HEAD) +# +# The build number is the package revision (zfs_2.4.4-), as for the +# kernel, so every build's packages have their own version and a patch +# change reaches systems as an upgrade. The DKMS module version stays +# ZFS_VERSION: OpenZFS takes it from META's Version, not its Release. set -euo pipefail @@ -24,6 +30,7 @@ OUT_DIR="${OUT_DIR:-$(pwd)/out}" BUILD_THREADS="${BUILD_THREADS:-$(nproc)}" ROOT="$(cd "$(dirname "$0")/.." && pwd)" +BUILD_NUMBER="$("$ROOT/recipes/build-number.sh")" BUILD_DIR="$ROOT/build/zfs-$ZFS_VERSION-$DEB_ARCH" TARBALL="zfs-$ZFS_VERSION.tar.gz" URL="https://github.com/openzfs/zfs/releases/download/zfs-$ZFS_VERSION/$TARBALL" @@ -88,6 +95,16 @@ fi echo "==> build arch: DEB_ARCH=$DEB_ARCH" +# configure reads the package revision from META. A reused tree configured +# for another build number has to be configured again. +# .nogitrelease: otherwise configure asks git (this repo, as the tree sits +# inside it) for a release before falling back to META. +touch .nogitrelease +if ! grep -qx "Release:[[:space:]]*${BUILD_NUMBER}" META; then + sed -i "s/^Release:.*/Release: ${BUILD_NUMBER}/" META + rm -f Makefile +fi + if [[ ! -f Makefile ]]; then echo "==> autogen + configure" ./autogen.sh >/dev/null diff --git a/recipes/stamp-version.sh b/recipes/stamp-version.sh deleted file mode 100755 index 624f2d6..0000000 --- a/recipes/stamp-version.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# stamp-version.sh — emit a KDEB_PKGVERSION suitable for passing to -# `make bindeb-pkg`. Combines KERNEL_VERSION with a release counter -# tied to the calendar date so successive builds against the same -# kernel are dpkg-comparable. -# -# Print to stdout: - -# e.g. 6.18.22-20260417.1 - -set -euo pipefail - -: "${KERNEL_VERSION:?KERNEL_VERSION required}" -DATESTAMP="$(date -u +%Y%m%d)" -RELEASE="${RELEASE:-${DATESTAMP}.1}" - -echo "${KERNEL_VERSION}-${RELEASE}"