Skip to content

feat(kernel): Publish the kernel's GPL source - #8

Merged
ananos merged 1 commit into
mainfrom
fix/kernel-gpl-source
Dec 2, 2026
Merged

ananos merged 1 commit into
mainfrom
fix/kernel-gpl-source

Conversation

@ananos

@ananos ananos commented Dec 1, 2026

Copy link
Copy Markdown
Member

The kernel we publish is GPL-2.0-only, so its corresponding source has to be available from the place the binary is offered. Until now we pointed at kernel.org. This publishes the source next to every kernel in the same GHCR package, and marks the licenses on the artifacts.

  • kernel/build-kernel.sh writes dist/source/: the upstream tarball and signature it verified, the .config, build.tar.gz (the script, PINS, kernel/keys, and a variant's fragments and driver directories under extra/), and SOURCE, which lists them and gives the rebuild command.
  • build-kernel.yml pushes it as guest-kernel:<tag>-source, signs it, and names it by digest in the kernel's sh.brig.hull-kernel.source. The kernel gets org.opencontainers.image.licenses=GPL-2.0-only. The example variant job checks that the driver source is in build.tar.gz.
  • build-assets.yml reads that annotation, and push-bundle.sh records it in bundle.json and sh.brig.hull-assets.kernel-source, with licenses=GPL-2.0-only AND Apache-2.0 AND MIT. It refuses to publish a bundle without a source digest.
  • README: a License section, and the -source tag in the registry layout.

Tested on nofire (x86_64, the example Rust variant): the build writes dist/source/ with the tarball at the pinned sha256 and a config identical to the kernel's. Rebuilding from build.tar.gz alone, with the command in SOURCE, gives an identical .config and the 7 example_hello symbols. The push and annotation lookup, replayed against a local registry, resolve and pull the source. push-bundle.sh exits 1 with no KERNEL_SOURCE or with a tag in place of a digest.

build-kernel.sh is in the inputs hash, so merging this republishes both kernels with their source, then the bundles. Kernels already published do not have it; those need a backfill.

@ananos

ananos commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@claude-fleet review

@claude-fleet

claude-fleet Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Review task queued.

Task: 4994300c-8a80-4216-80d4-b2a9b2e20dc3
Commit: 3bb92a1
Model: claude-opus-5 (effort medium)
Executor: ravel-clickbench-ubuntu-2
Status: done. Review posted.

@claude-fleet claude-fleet Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: one should_fix.

The design holds up. I staged the source tree locally (stub docker, so only the host half ran) and confirmed build.tar.gz is self-sufficient: build-kernel.sh reads nothing from the repo except PINS, itself, kernel/keys and the EXTRA_* paths, and all four are staged. The $PWD in the rebuild command survives the heredoc literally, and the tarball bytes that ship are the ones already past the sha256 and gpgv gates.

Findings:

  • should_fix, oci/push-bundle.sh:86 — the new required KERNEL_SOURCE breaks make push, which the README documents
  • nit, .github/workflows/build-kernel.yml:205 — -source is annotated GPL-2.0-only while build.tar.gz holds Apache-2.0 scripts
  • nit, README.md:279 — make kernel writes dist/<arch>/source/, not dist/source/
  • nit, oci/push-bundle.sh:87 — the guard accepts an empty digest
  • nit, kernel/build-kernel.sh:811 — a failed build leaves $OUT/.source-tree behind

Verified:

  • build.tar.gz is complete for the rebuild command: the script's only repo inputs are PINS (build-kernel.sh:119), itself, kernel/keys (build-kernel.sh:567) and the EXTRA_* paths, all staged at build-kernel.sh:515-522
  • the shipped tarball and .sign are the verified bytes: the cp is after the sha256 check and gpgv (build-kernel.sh:609-629)
  • the example job's grep -qxF ./kernel/build-kernel.sh matches what tar stores: -C /srctree -cf - . yields ./-prefixed names (build-kernel.sh:790)
  • SOURCE_DIGEST reaches the signing step through GITHUB_ENV (build-kernel.yml:217, 264), and the source is resolved through the immutable -source tag, not a moving one
  • the pre-annotation kernel does not break main: build-kernel.sh is in the inputs hash (inputs-hash.sh:40), so the merge republishes both kernels, and until that lands a publishing build-assets run skips rather than bundling (build-assets.yml:186-192). On a PR the minimal-$ARCH fallback (build-assets.yml:197-199) can yield an empty annotation, but PUBLISH is false there so push-bundle.sh never runs (build-assets.yml:265)
  • README's URUNIT_REF reference matches PINS:48

Checks run:

  • staged the example variant with a stub docker and JOBS=1 → dist/source/SOURCE renders the pinned sha256 and ARCH=x86_64 PROFILE=minimal EXTRA_CONFIG=$PWD/extra/config/1-example.config EXTRA_SRC=$PWD/extra/src/example_hello, and .source-tree contains PINS, kernel/{build-kernel.sh,inputs-hash.sh,keys}, extra/{config,src}
  • ./oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with KERNEL_SOURCE unset → exit 1; with …guest-kernel:minimal-arm64 → exit 1; with a/b@sha256: → passes the guard
  • the same run with no KERNEL_SOURCE reproduces the make push failure

Smaller things:

  • the build.tar.gz file list now lives in four places — build-kernel.sh:94-96, the SOURCE heredoc at build-kernel.sh:541-544, README.md:258 and the check at build-kernel.yml:316-317 — and two of them omit inputs-hash.sh, which the archive does contain. One list with pointers would keep them honest.
  • the kernel digest gets a cosign verify self-check right after signing (build-kernel.yml:269-273); the source digest only gets cosign sign (build-kernel.yml:264). The README says all three are signed, which is true, but the source is the one whose identity nobody exercises here.
  • SOURCE does not name BUILDER_IMG, so a non-Rust rebuild resolves debian:bookworm-slim at whatever that tag points to then. Not a GPL concern, but it is the one input the rebuild command cannot pin.

Not checked:

  • shellcheck is not installed here, so make lint over the changed scripts did not run
  • no registry was reachable, so oras push/oras resolve/oras manifest fetch and the annotation round-trip are taken from the description's replay against a local registry
  • no kernel was compiled: the container half of build-kernel.sh (the cp into /out/source, cp .config /out/source/config, the tar | gzip) was read, not executed

Not checked:

  • make lint / shellcheck over the changed scripts: shellcheck is not installed in this environment
  • the registry round-trip: oras push, oras resolve and oras manifest fetch of the -source tag and the sh.brig.hull-kernel.source annotation lookup, taken from the description's local-registry replay
  • the container half of kernel/build-kernel.sh (the cp of the tarball and .config into /out/source, and the tar | gzip of /srctree) was read but not executed; no kernel was compiled
  • cosign signing and verification of the new -source digest

Task 4994300c-8a80-4216-80d4-b2a9b2e20dc3 on ravel-clickbench-ubuntu-2, model claude-opus-5, effort medium.

Comment thread oci/push-bundle.sh Outdated
if [ "${COSIGN_SIGN:-0}" = "1" ]; then
command -v cosign >/dev/null || { echo "ERROR: cosign is required when COSIGN_SIGN=1" >&2; exit 1; }
fi
case "${KERNEL_SOURCE:-}" in

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should_fix: Making KERNEL_SOURCE required breaks make push, which the README documents, because the Makefile target never sets it and no documentation names the variable.
Failure: make push PLATFORM=darwin-arm64 (README.md:113) exits 1 with ERROR: KERNEL_SOURCE is '' before it looks at the dist directory, and the hint points at build-kernel.yml, which is not something a local publisher runs. This hits exactly the case README.md:279-282 invites: someone publishing a variant built from these scripts.
Evidence: Makefile:68-70 invokes oci/push-bundle.sh $(PLATFORM) $(DIST) $(VERSION) with no KERNEL_SOURCE in its environment; I ran ./oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with it unset and got that exit 1. The guard is also above the cd "$dist" at oci/push-bundle.sh:96 and above the already-published early exit at oci/push-bundle.sh:134-138, so a re-run of a commit that is already published now fails instead of being a no-op.
Fix: pass it through in the Makefile (KERNEL_SOURCE="$(KERNEL_SOURCE)") with a #? flag line, and name it in the README's publish step.

Comment thread .github/workflows/build-kernel.yml Outdated
"$REGISTRY/$KERNEL_REPO:$TAG-source" \
--artifact-type application/vnd.nofire.hull-kernel.source.v1 \
--annotation "org.opencontainers.image.source=https://github.com/brig-sh/boot-assets" \
--annotation "org.opencontainers.image.licenses=GPL-2.0-only" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The -source artifact is annotated org.opencontainers.image.licenses=GPL-2.0-only, but it carries Apache-2.0 files too.
Failure: a consumer reading the annotation on guest-kernel:<tag>-source is told the whole artifact is GPL-2.0-only, while build.tar.gz contains kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS, which LICENSE and README.md:244-245 put under Apache-2.0. The bundle push got a compound expression for the same reason (oci/push-bundle.sh:154); this push did not.
Evidence: kernel/build-kernel.sh:515-517 stages the Apache-2.0 scripts into the archive; .github/workflows/build-kernel.yml:205 annotates the artifact that contains it.
Fix: GPL-2.0-only AND Apache-2.0.

Comment thread README.md Outdated
cat kernel-source/SOURCE
```

`make kernel` writes the same files to `dist/source/`. Whoever publishes a

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make kernel does not write dist/source/.
Failure: a reader following this line looks in dist/source/ and finds nothing; the files are in dist/<arch>/source/.
Evidence: Makefile:28 sets DIST ?= $(CURDIR)/dist/$(ARCH) and Makefile:43 passes OUT=$(DIST), and build-kernel.sh writes $OUT/source.

Comment thread oci/push-bundle.sh Outdated
command -v cosign >/dev/null || { echo "ERROR: cosign is required when COSIGN_SIGN=1" >&2; exit 1; }
fi
case "${KERNEL_SOURCE:-}" in
*/*@sha256:*) ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The */*@sha256:* pattern accepts a digest-less reference.
Failure: KERNEL_SOURCE=a/b@sha256: passes the guard and lands verbatim in bundle.json (oci/push-bundle.sh:116) and in sh.brig.hull-assets.kernel-source (oci/push-bundle.sh:156), so the bundle advertises a source location nothing can resolve. I ran that value and the script proceeded past the guard to the dist-file check. Today the value comes from an annotation this repo wrote, so this is narrow and the failure direction is safe; it just does not catch what the error message claims to.
Fix: */*@sha256:[0-9a-f][0-9a-f]*) with a length check, or validate against the 64-hex form.

Comment thread kernel/build-kernel.sh Outdated
ls -l "/out/$KERNEL_OUT"
'

rm -rf "$src_tree"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rm -rf "$src_tree" runs only after a successful container build, so a failed build leaves the staging tree in the output directory.
Failure: with set -e, a non-zero docker run exits before this line and $OUT/.source-tree stays behind. I reproduced it with a stub docker that exits 7: /tmp/d1/.source-tree was still fully populated afterwards. Harmless on CI (the uploads and oras push both name files explicitly, and the next run's rm -rf at kernel/build-kernel.sh:513 cleans it), but it is a 40KB surprise in a local dist/ after every failed build.
Evidence: kernel/build-kernel.sh:512-513 creates it, kernel/build-kernel.sh:558 is the command that can fail, kernel/build-kernel.sh:811 is the cleanup.
Fix: a trap 'rm -rf "$src_tree"' EXIT after the mkdir.

@ananos
ananos force-pushed the fix/kernel-gpl-source branch from 3bb92a1 to 9dec10f Compare December 2, 2026 00:11
@ananos

ananos commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

@claude-fleet review

@claude-fleet

claude-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Review task queued.

Task: ef383fd6-1104-4b2b-9e9d-02d5dcd3bf70
Commit: 9dec10f
Model: claude-opus-5 (effort medium)
Executor: pimox5
Status: done. Review posted.

@claude-fleet claude-fleet Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous round at 3bb92a1: 5 findings.

Previous finding Classification Cited line
oci/push-bundle.sh:86 (should_fix): Making KERNEL_SOURCE required breaks make push, which the README documents, because the Makefile target never sets it and no documentation names the variable. Failure: make push PLATFORM=darwin-arm64 (README.md:113) exits 1 with ERROR: KERNEL_SOURCE is '' before it looks at the dist directory, and the hint points at build-kernel.yml, which is not something a local publisher runs. This hits exactly the case README.md:279-282 invites: someone publishing a variant built from these scripts. Evidence: Makefile:68-70 invokes oci/push-bundle.sh $(PLATFORM) $(DIST) $(VERSION) with no KERNEL_SOURCE in its environment; I ran ./oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with it unset and got that exit 1. The guard is also above the cd "$dist" at oci/push-bundle.sh:96 and above the already-published early exit at oci/push-bundle.sh:134-138, so a re-run of a commit that is already published now fails instead of being a no-op. Fix: pass it through in the Makefile (KERNEL_SOURCE="$(KERNEL_SOURCE)") with a #? flag line, and name it in the README's publish step. fixed oci/push-bundle.sh:134
.github/workflows/build-kernel.yml:205 (nit): The -source artifact is annotated org.opencontainers.image.licenses=GPL-2.0-only, but it carries Apache-2.0 files too. Failure: a consumer reading the annotation on guest-kernel:<tag>-source is told the whole artifact is GPL-2.0-only, while build.tar.gz contains kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS, which LICENSE and README.md:244-245 put under Apache-2.0. The bundle push got a compound expression for the same reason (oci/push-bundle.sh:154); this push did not. Evidence: kernel/build-kernel.sh:515-517 stages the Apache-2.0 scripts into the archive; .github/workflows/build-kernel.yml:205 annotates the artifact that contains it. Fix: GPL-2.0-only AND Apache-2.0. fixed .github/workflows/build-kernel.yml:205
README.md:279 (nit): make kernel does not write dist/source/. Failure: a reader following this line looks in dist/source/ and finds nothing; the files are in dist/<arch>/source/. Evidence: Makefile:28 sets DIST ?= $(CURDIR)/dist/$(ARCH) and Makefile:43 passes OUT=$(DIST), and build-kernel.sh writes $OUT/source. fixed README.md:283
oci/push-bundle.sh:87 (nit): The */*@sha256:* pattern accepts a digest-less reference. Failure: KERNEL_SOURCE=a/b@sha256: passes the guard and lands verbatim in bundle.json (oci/push-bundle.sh:116) and in sh.brig.hull-assets.kernel-source (oci/push-bundle.sh:156), so the bundle advertises a source location nothing can resolve. I ran that value and the script proceeded past the guard to the dist-file check. Today the value comes from an annotation this repo wrote, so this is narrow and the failure direction is safe; it just does not catch what the error message claims to. Fix: */*@sha256:[0-9a-f][0-9a-f]*) with a length check, or validate against the 64-hex form. fixed oci/push-bundle.sh:134
kernel/build-kernel.sh:811 (nit): rm -rf "$src_tree" runs only after a successful container build, so a failed build leaves the staging tree in the output directory. Failure: with set -e, a non-zero docker run exits before this line and $OUT/.source-tree stays behind. I reproduced it with a stub docker that exits 7: /tmp/d1/.source-tree was still fully populated afterwards. Harmless on CI (the uploads and oras push both name files explicitly, and the next run's rm -rf at kernel/build-kernel.sh:513 cleans it), but it is a 40KB surprise in a local dist/ after every failed build. Evidence: kernel/build-kernel.sh:512-513 creates it, kernel/build-kernel.sh:558 is the command that can fail, kernel/build-kernel.sh:811 is the cleanup. Fix: a trap 'rm -rf "$src_tree"' EXIT after the mkdir. fixed kernel/build-kernel.sh:515

All five findings from the last round are fixed. One new one, in the same license-compliance area.

Request changes: one should_fix finding.

Findings:

  • should_fix, kernel/build-kernel.sh:517 — build.tar.gz declares Apache-2.0 but ships no copy of the Apache license

Previous round:

  • 1 (KERNEL_SOURCE breaks make push) — fixed. Makefile:72 passes it through, Makefile:25-26 declares it with a #? line, README.md:113 and README.md:286-290 name it. The guard also moved to oci/push-bundle.sh:134, below cd "$dist" (91), the dist-file loop (92-94) and the already-published early exit (129-133), so an already-published re-run is a no-op again.
  • 2 (-source license annotation) — fixed, .github/workflows/build-kernel.yml:205 is now GPL-2.0-only AND Apache-2.0, and README.md:268-269 says why.
  • 3 (dist/source/) — fixed, README.md:283.
  • 4 (digest-less reference accepted) — fixed, the 64-hex regex at oci/push-bundle.sh:134 rejects a/b@sha256:.
  • 5 (staging tree left after a failed build) — fixed, trap at kernel/build-kernel.sh:515.

Verified:

  • The source push runs before the kernel push and under its own tag, and both the push and the sign/verify steps carry the same exists != 'true' condition, so SOURCE_DIGEST is never read unset — build-kernel.yml:177, 207-215, 251-258.
  • build.tar.gz is self-contained for the rebuild in SOURCE: build-kernel.sh reads only $repo_root/PINS (line 119) and $here/keys, both staged at build-kernel.sh:516-518.
  • ARCH is normalized (build-kernel.sh:145-161) before the rebuild line is composed at build-kernel.sh:519, so the command in SOURCE uses an accepted value.
  • $extra_dir/config and $extra_dir/src always exist (build-kernel.sh:495), so the cp -R at build-kernel.sh:523 cannot fail for a config-only variant.
  • kernel/build-kernel.sh is in the inputs hash (kernel/inputs-hash.sh:40), so merging does produce new kernel tags that carry the annotation.
  • push-bundle.sh has no other caller than Makefile:72 and build-assets.yml:284.

Checks run:

  • Regex at oci/push-bundle.sh:134 against six values: rejects ``, a/b@sha256:, a 63-hex digest, `ghcr.io/x/y:tag`, and a trailing-garbage form; accepts the 64-hex form.
  • oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with KERNEL_SOURCE unset, stub oras, populated dist: reaches the guard only after writing bundle.json, i.e. past the dist checks. Previously it exited before them.
  • OUT=/tmp/d1 ARCH=x86_64 kernel/build-kernel.sh with a stub docker exiting 7: exit 7, and /tmp/d1/.source-tree is gone.

Smaller things:

  • A failed guard at oci/push-bundle.sh:134 leaves bundle.json in the dist directory with "source": "" (written at line 98-117). Nothing publishes it and the next run overwrites it, but moving the guard above the heredoc would cost nothing.
  • grep -Eq at oci/push-bundle.sh:134 matches per line, so a KERNEL_SOURCE with an embedded newline whose first line is well-formed passes and the rest lands in the annotation at line 157. The value comes from an annotation this repo wrote, so this is narrow.
  • $OUT/.extra (build-kernel.sh:493) has no equivalent of the new trap and still survives a failed build. Pre-existing, outside this diff.

Not checked:

  • No registry, oras or cosign in this workspace, so the pushes, oras resolve, the annotation lookup at build-assets.yml:222-223 and the cosign loop were read, not run.
  • No kernel build was run, so dist/source/ contents, the tar -tzf paths the example job greps for (build-kernel.yml:317-320), and the rebuild from build.tar.gz are taken from the PR description's test report.

Not checked:

  • The oras/cosign pushes, oras resolve, the sh.brig.hull-kernel.source annotation lookup at .github/workflows/build-assets.yml:222-223 and the cosign verify loop: no registry, oras or cosign in this workspace, so these were read rather than run.
  • The actual contents of dist/source/ and build.tar.gz, the tar entry paths the example job greps for (.github/workflows/build-kernel.yml:317-320), and the rebuild-from-build.tar.gz claim: no kernel build was run, so these rest on the PR description's test report.

Task ef383fd6-1104-4b2b-9e9d-02d5dcd3bf70 on pimox5, model claude-opus-5, effort medium.

Comment thread kernel/build-kernel.sh
mkdir -p "$src_tree/kernel" "$OUT/source"
trap 'rm -rf "$src_tree"' EXIT
cp "$repo_root/PINS" "$src_tree/"
cp "$here/build-kernel.sh" "$here/inputs-hash.sh" "$src_tree/kernel/"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should_fix: build.tar.gz is distributed as Apache-2.0 but contains no copy of the Apache license.
Failure: a consumer pulls guest-kernel:<tag>-source, reads org.opencontainers.image.licenses=GPL-2.0-only AND Apache-2.0 (.github/workflows/build-kernel.yml:205), unpacks build.tar.gz, and gets kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS with no license text and no attribution notice. Apache-2.0 section 4(a) requires a copy of the License to go with the Work; SOURCE does not mention Apache-2.0 either, it says only "The kernel is licensed GPL-2.0-only" (kernel/build-kernel.sh:533). This is the one piece of the licensing story the PR declares and does not ship.
Evidence: the staging tree is built at kernel/build-kernel.sh:514-523 from PINS, kernel/build-kernel.sh, kernel/inputs-hash.sh, kernel/keys and extra/ only; the repo's LICENSE (Apache-2.0, repo root) is not among them, and tar -C /srctree -cf - at kernel/build-kernel.sh:793-794 packs exactly that tree. README.md:245 puts those scripts under Apache-2.0.
Fix: cp "$repo_root/LICENSE" "$src_tree/" beside line 516, and a line in the build.tar.gz block of SOURCE saying the build scripts are Apache-2.0 and LICENSE is their license.

@ananos

ananos commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

@claude-fleet review

@ananos
ananos force-pushed the fix/kernel-gpl-source branch from 9dec10f to 37c34ac Compare December 2, 2026 00:38
@claude-fleet

claude-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Review task queued.

Task: 5a78057a-ba0f-41fc-81c5-b1187ef68f57
Commit: 37c34ac
Model: claude-opus-5 (effort medium)
Executor: ravel-fleet-amd64-1
Status: done. Review posted.

@claude-fleet claude-fleet Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous round at 9dec10f: 6 findings.

Previous finding Classification Cited line
oci/push-bundle.sh:134 (should_fix): Making KERNEL_SOURCE required breaks make push, which the README documents, because the Makefile target never sets it and no documentation names the variable. Failure: make push PLATFORM=darwin-arm64 (README.md:113) exits 1 with ERROR: KERNEL_SOURCE is '' before it looks at the dist directory, and the hint points at build-kernel.yml, which is not something a local publisher runs. This hits exactly the case README.md:279-282 invites: someone publishing a variant built from these scripts. Evidence: Makefile:68-70 invokes oci/push-bundle.sh $(PLATFORM) $(DIST) $(VERSION) with no KERNEL_SOURCE in its environment; I ran ./oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with it unset and got that exit 1. The guard is also above the cd "$dist" at oci/push-bundle.sh:96 and above the already-published early exit at oci/push-bundle.sh:134-138, so a re-run of a commit that is already published now fails instead of being a no-op. Fix: pass it through in the Makefile (KERNEL_SOURCE="$(KERNEL_SOURCE)") with a #? flag line, and name it in the README's publish step. fixed Makefile:72
.github/workflows/build-kernel.yml:205 (nit): The -source artifact is annotated org.opencontainers.image.licenses=GPL-2.0-only, but it carries Apache-2.0 files too. Failure: a consumer reading the annotation on guest-kernel:<tag>-source is told the whole artifact is GPL-2.0-only, while build.tar.gz contains kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS, which LICENSE and README.md:244-245 put under Apache-2.0. The bundle push got a compound expression for the same reason (oci/push-bundle.sh:154); this push did not. Evidence: kernel/build-kernel.sh:515-517 stages the Apache-2.0 scripts into the archive; .github/workflows/build-kernel.yml:205 annotates the artifact that contains it. Fix: GPL-2.0-only AND Apache-2.0. fixed .github/workflows/build-kernel.yml:205
README.md:283 (nit): make kernel does not write dist/source/. Failure: a reader following this line looks in dist/source/ and finds nothing; the files are in dist/<arch>/source/. Evidence: Makefile:28 sets DIST ?= $(CURDIR)/dist/$(ARCH) and Makefile:43 passes OUT=$(DIST), and build-kernel.sh writes $OUT/source. fixed README.md:283
oci/push-bundle.sh:134 (nit): The */*@sha256:* pattern accepts a digest-less reference. Failure: KERNEL_SOURCE=a/b@sha256: passes the guard and lands verbatim in bundle.json (oci/push-bundle.sh:116) and in sh.brig.hull-assets.kernel-source (oci/push-bundle.sh:156), so the bundle advertises a source location nothing can resolve. I ran that value and the script proceeded past the guard to the dist-file check. Today the value comes from an annotation this repo wrote, so this is narrow and the failure direction is safe; it just does not catch what the error message claims to. Fix: */*@sha256:[0-9a-f][0-9a-f]*) with a length check, or validate against the 64-hex form. fixed oci/push-bundle.sh:134
kernel/build-kernel.sh:515 (nit): rm -rf "$src_tree" runs only after a successful container build, so a failed build leaves the staging tree in the output directory. Failure: with set -e, a non-zero docker run exits before this line and $OUT/.source-tree stays behind. I reproduced it with a stub docker that exits 7: /tmp/d1/.source-tree was still fully populated afterwards. Harmless on CI (the uploads and oras push both name files explicitly, and the next run's rm -rf at kernel/build-kernel.sh:513 cleans it), but it is a 40KB surprise in a local dist/ after every failed build. Evidence: kernel/build-kernel.sh:512-513 creates it, kernel/build-kernel.sh:558 is the command that can fail, kernel/build-kernel.sh:811 is the cleanup. Fix: a trap 'rm -rf "$src_tree"' EXIT after the mkdir. fixed kernel/build-kernel.sh:516
kernel/build-kernel.sh:517 (should_fix): build.tar.gz is distributed as Apache-2.0 but contains no copy of the Apache license. Failure: a consumer pulls guest-kernel:<tag>-source, reads org.opencontainers.image.licenses=GPL-2.0-only AND Apache-2.0 (.github/workflows/build-kernel.yml:205), unpacks build.tar.gz, and gets kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS with no license text and no attribution notice. Apache-2.0 section 4(a) requires a copy of the License to go with the Work; SOURCE does not mention Apache-2.0 either, it says only "The kernel is licensed GPL-2.0-only" (kernel/build-kernel.sh:533). This is the one piece of the licensing story the PR declares and does not ship. Evidence: the staging tree is built at kernel/build-kernel.sh:514-523 from PINS, kernel/build-kernel.sh, kernel/inputs-hash.sh, kernel/keys and extra/ only; the repo's LICENSE (Apache-2.0, repo root) is not among them, and tar -C /srctree -cf - at kernel/build-kernel.sh:793-794 packs exactly that tree. README.md:245 puts those scripts under Apache-2.0. Fix: cp "$repo_root/LICENSE" "$src_tree/" beside line 516, and a line in the build.tar.gz block of SOURCE saying the build scripts are Apache-2.0 and LICENSE is their license. fixed kernel/build-kernel.sh:517

No longer carried to the next round, settled in rounds 2 and 3:

  • oci/push-bundle.sh:134 (should_fix): Making KERNEL_SOURCE required breaks make push, which the README documents, because the Makefile target never sets it and no documentation names the variable. Failure: make push PLATFORM=darwin-arm64 (README.md:113) exits 1 with ERROR: KERNEL_SOURCE is '' before it looks at the dist directory, and the hint points at build-kernel.yml, which is not something a local publisher runs. This hits exactly the case README.md:279-282 invites: someone publishing a variant built from these scripts. Evidence: Makefile:68-70 invokes oci/push-bundle.sh $(PLATFORM) $(DIST) $(VERSION) with no KERNEL_SOURCE in its environment; I ran ./oci/push-bundle.sh linux-arm64 /tmp/dd 0.0.0 with it unset and got that exit 1. The guard is also above the cd "$dist" at oci/push-bundle.sh:96 and above the already-published early exit at oci/push-bundle.sh:134-138, so a re-run of a commit that is already published now fails instead of being a no-op. Fix: pass it through in the Makefile (KERNEL_SOURCE="$(KERNEL_SOURCE)") with a #? flag line, and name it in the README's publish step.
  • .github/workflows/build-kernel.yml:205 (nit): The -source artifact is annotated org.opencontainers.image.licenses=GPL-2.0-only, but it carries Apache-2.0 files too. Failure: a consumer reading the annotation on guest-kernel:<tag>-source is told the whole artifact is GPL-2.0-only, while build.tar.gz contains kernel/build-kernel.sh, kernel/inputs-hash.sh and PINS, which LICENSE and README.md:244-245 put under Apache-2.0. The bundle push got a compound expression for the same reason (oci/push-bundle.sh:154); this push did not. Evidence: kernel/build-kernel.sh:515-517 stages the Apache-2.0 scripts into the archive; .github/workflows/build-kernel.yml:205 annotates the artifact that contains it. Fix: GPL-2.0-only AND Apache-2.0.
  • README.md:283 (nit): make kernel does not write dist/source/. Failure: a reader following this line looks in dist/source/ and finds nothing; the files are in dist/<arch>/source/. Evidence: Makefile:28 sets DIST ?= $(CURDIR)/dist/$(ARCH) and Makefile:43 passes OUT=$(DIST), and build-kernel.sh writes $OUT/source.
  • oci/push-bundle.sh:134 (nit): The */*@sha256:* pattern accepts a digest-less reference. Failure: KERNEL_SOURCE=a/b@sha256: passes the guard and lands verbatim in bundle.json (oci/push-bundle.sh:116) and in sh.brig.hull-assets.kernel-source (oci/push-bundle.sh:156), so the bundle advertises a source location nothing can resolve. I ran that value and the script proceeded past the guard to the dist-file check. Today the value comes from an annotation this repo wrote, so this is narrow and the failure direction is safe; it just does not catch what the error message claims to. Fix: */*@sha256:[0-9a-f][0-9a-f]*) with a length check, or validate against the 64-hex form.
  • kernel/build-kernel.sh:515 (nit): rm -rf "$src_tree" runs only after a successful container build, so a failed build leaves the staging tree in the output directory. Failure: with set -e, a non-zero docker run exits before this line and $OUT/.source-tree stays behind. I reproduced it with a stub docker that exits 7: /tmp/d1/.source-tree was still fully populated afterwards. Harmless on CI (the uploads and oras push both name files explicitly, and the next run's rm -rf at kernel/build-kernel.sh:513 cleans it), but it is a 40KB surprise in a local dist/ after every failed build. Evidence: kernel/build-kernel.sh:512-513 creates it, kernel/build-kernel.sh:558 is the command that can fail, kernel/build-kernel.sh:811 is the cleanup. Fix: a trap 'rm -rf "$src_tree"' EXIT after the mkdir.

All six previous findings are fixed. Two nits left, both narrow.

Findings:

  • nit, kernel/build-kernel.sh:552 — the documented rebuild re-downloads the tarball it ships
  • nit, oci/push-bundle.sh:111 — bundle.json is written before the KERNEL_SOURCE guard

Verified:

  • Finding 1: Makefile:72 passes KERNEL_SOURCE through, Makefile:25-26 declares it with a #? line, README.md:110-112,286-291 name it, and the guard now sits at oci/push-bundle.sh:134, below the cd "$dist" and below the already-published early exit at oci/push-bundle.sh:128-133, so a re-run of a published commit is a no-op again.
  • Finding 2: the -source push is annotated GPL-2.0-only AND Apache-2.0 — .github/workflows/build-kernel.yml:205; the kernel artifact keeps the bare GPL-2.0-only at :233, which is right, it carries no Apache files.
  • Finding 3: README.md:283 says dist/<arch>/source/.
  • Finding 4: regex is ^[^@[:space:]]+/[^@[:space:]]+@sha256:[0-9a-f]{64}$ — oci/push-bundle.sh:134. Ran it against "", a/b@sha256:, ghcr.io/o/r:tag (all rejected) and a 64-hex ref (accepted).
  • Finding 5: trap 'rm -rf "$src_tree"' EXIT at kernel/build-kernel.sh:516, right after the mkdir -p, so it covers the container run at :571 and every path to it.
  • Finding 6: kernel/build-kernel.sh:517 copies LICENSE into the staging tree, :548 names it in SOURCE, README.md:260 lists it, and .github/workflows/build-kernel.yml:318 makes the example job fail if ./LICENSE is not in build.tar.gz. The CI check is better than the fix I proposed: it keeps the staging list and the claim from drifting apart.
  • The bundle's GPL-2.0-only AND Apache-2.0 AND MIT is complete for what the bundle layers hold: kernel, container-initrd, bundle.json, KVER (oci/push-bundle.sh:160-164), and the initrd is urunit alone, no BusyBox and no second binary (initrd/build-container-initrd.sh:24-27).
  • SOURCE_DIGEST is only read where it is set: the push step writes it to $GITHUB_ENV (.github/workflows/build-kernel.yml:214) and the sign step carries the same if: guard as the push (:251,257), so an exists=true run never reaches it under set -u.
  • The tarball and signature go into source/ only after both the sha256 and the gpgv check (kernel/build-kernel.sh:615-631, copy at :635).
  • KERNEL_SOURCE reaches push-bundle.sh: the annotation lookup and the push are in the same build job (.github/workflows/build-assets.yml:129,220-231,264-285), and the push step's env: block does not shadow it.
  • Fragment order in build.tar.gz does not affect a rebuild: extra_y/extra_off are unions and a symbol set both ways is a hard error (kernel/build-kernel.sh:427-433), so the LC_ALL=C sort at :525 cannot change the resulting .config.

Checks run:

  • bash regex probe of the KERNEL_SOURCE guard against four values → rejects empty, digest-less and tag refs, accepts a 64-hex digest ref.

Smaller things:

  • SOURCE names the builder image (kernel/build-kernel.sh:550) but the rebuild command does not set BUILDER_IMG, so a minimal-profile rebuild uses whatever debian:bookworm-slim resolves to that day. Rust builds are pinned by digest through PINS, which ships, so this only affects the non-Rust path and only the toolchain, not the .config.
  • SOURCE says LICENSE covers "the build scripts and PINS"; kernel/keys is also in the archive and is kernel.org's public keys, not Apache-2.0 material. Not worth a line unless you want the archive's own manifest to be exhaustive.

Not checked:

  • The claims in the PR description about an end-to-end run on nofire: the GHCR push, the annotation lookup against a real registry, the rebuild from build.tar.gz producing an identical .config and the 7 example_hello symbols. No registry, docker or kernel build is reachable here; I checked the scripts and workflow logic that would produce those results.
  • Whether cdn.kernel.org retains superseded stable tarballs indefinitely. The nit on kernel/build-kernel.sh:552 is written to not depend on it.

Task 5a78057a-ba0f-41fc-81c5-b1187ef68f57 on ravel-fleet-amd64-1, model claude-opus-5, effort medium.

Comment thread kernel/build-kernel.sh Outdated

The build ran in the $BUILDER_IMG container.

To rebuild (needs docker; the script fetches the same tarball and checks

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The rebuild command in SOURCE cannot use the linux-$KVER.tar.xz shipped beside it; it always re-downloads the same bytes from cdn.kernel.org.
Failure: a recipient of guest-kernel:<tag>-source who has the artifact but no route to cdn.kernel.org (air-gapped mirror, a CDN path that fails, a tarball that moved) cannot rebuild, even though the corresponding source is on disk. The build dies at the wget with the container's bare exit, not at a message about the tarball it already has.
Evidence: kernel/build-kernel.sh:606-607 fetches linux-$KVER.tar.xz and .tar.sign unconditionally inside the container and there is no env var or path that feeds it a local copy; the rebuild recipe at kernel/build-kernel.sh:552-557 unpacks only build.tar.gz, which does not contain the tarball. The line is honest about what it does, so this is a gap in the recipe, not a wrong claim.
Fix: accept a KERNEL_TARBALL dir mounted into the container and skip the wget when the two files are already there (the sha256 and gpgv checks at :615-631 stay, so nothing is trusted that is not verified), and say in SOURCE that the shipped tarball can be used that way.

Comment thread oci/push-bundle.sh
"inputs": "${KERNEL_INPUTS:-}"
"inputs": "${KERNEL_INPUTS:-}",
"license": "GPL-2.0-only",
"source": "$KERNEL_SOURCE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: bundle.json is written with "source": "$KERNEL_SOURCE" before the guard that validates KERNEL_SOURCE, so a rejected run still leaves a rewritten bundle.json in the dist directory.
Failure: make push PLATFORM=linux-arm64 with no (or a malformed) KERNEL_SOURCE exits 1 at oci/push-bundle.sh:134, and dist/<arch>/bundle.json now records "source": "" where it previously held the value from the last successful push. The same happens on the already-published early exit at oci/push-bundle.sh:128-133, which returns 0 after the rewrite and before the guard: the on-disk bundle.json then disagrees with the published one. Nothing is pushed in either case and the next successful run rewrites the file, so this is cosmetic.
Evidence: oci/push-bundle.sh:98-115 writes the file, oci/push-bundle.sh:128-133 is the early exit, oci/push-bundle.sh:134-139 is the guard.
Fix: move the guard above the cat > bundle.json heredoc. It would also then fire before the registry round-trip, which is the faster failure for a local publisher.

- build-kernel.sh writes dist/source: the verified upstream tarball and
  signature, the .config, and build.tar.gz with the scripts, PINS, keys,
  LICENSE and a variant's fragments and driver sources. KERNEL_TARBALL_DIR
  rebuilds from a local tarball, under the same checks.
- build-kernel.yml pushes it as guest-kernel:<tag>-source, signs and
  verifies it, and names it by digest in sh.brig.hull-kernel.source.
- Bundles record that source in bundle.json and an annotation, with
  org.opencontainers.image.licenses. push-bundle.sh, and make push via
  KERNEL_SOURCE, refuse to publish a new bundle without a source digest.
- README: License section.

Signed-off-by: Anastassios Nanos <ananos@nofire.ai>
@ananos
ananos marked this pull request as ready for review December 2, 2026 00:50
@ananos
ananos force-pushed the fix/kernel-gpl-source branch from 37c34ac to 40f8c40 Compare December 2, 2026 00:50
@ananos
ananos merged commit 2e7c7c2 into main Dec 2, 2026
16 checks passed
@ananos
ananos deleted the fix/kernel-gpl-source branch December 2, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant