From 67dce66d30242d58fb79724632c9d27688edb5ae Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 13:06:50 +0000 Subject: [PATCH 1/6] ci: verify the whole image set before advancing :testing Promotion copied each digest as it read it and asserted the total afterwards: while IFS='=' read -r name digest; do skopeo copy ... "docker://${REGISTRY}/${name}:testing" done < <(find /tmp/digests -name '*.txt' -exec cat {} +) test "$count" -eq 4 The order is wrong. A run that produced three of the four flavors advances :testing for those three and then fails, so the stream is left carrying a set nobody promised and no step undoes it. The same is true of a digest naming an image no flavor asks for: it is copied first and counted second. The literal four is the second fault. config/flavors.json is the single source for which images exist -- the build matrix, the promote matrix and the release matrix all read it, and `just check` already forbids naming a flavor directly in these workflows. The count was the one place that escaped, so narrowing the flavor set would have left promotion failing on a number rather than doing less work. Now the run is checked against `scripts/flavors.py images` before anything is copied: every promised image present, exactly once, no image that is not promised, and every value an actual digest. Only then does the promotion loop run, over the verified list. `just check` gains a guard so the count cannot be hardcoded here again. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KVSCoKWBWAuFFZyLwteEbB --- .github/workflows/post-testing-e2e.yml | 63 ++++++++++++++++++++++++-- Justfile | 5 ++ 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/.github/workflows/post-testing-e2e.yml b/.github/workflows/post-testing-e2e.yml index 7bbfcc484..e3173f2af 100644 --- a/.github/workflows/post-testing-e2e.yml +++ b/.github/workflows/post-testing-e2e.yml @@ -19,10 +19,66 @@ jobs: packages: write actions: read steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Download all flavor digests env: GH_TOKEN: ${{ github.token }} run: gh run download "${{ github.event.workflow_run.id }}" --repo "${{ github.repository }}" --pattern 'image-digest-testing-*' --dir /tmp/digests + # The whole set is checked before any of it is promoted. This used to + # copy each digest as it read it and assert the total afterwards, which + # is the wrong order twice over: a short or unexpected set had already + # moved :testing for the flavors it did reach by the time the assertion + # failed, and the total was a literal four, while config/flavors.json is + # supposed to be the only source for which images exist. `just check` + # forbids that literal everywhere else in this workflow directory. + - name: Verify the run produced exactly the promised images + id: verify + run: | + set -euo pipefail + find /tmp/digests -name '*.txt' -exec cat {} + > /tmp/digests.txt + python3 - <<'PY' + import json, pathlib, subprocess, sys + + expected = { + item["image"] + for item in json.loads( + subprocess.run( + [sys.executable, "scripts/flavors.py", "images"], + capture_output=True, text=True, check=True, + ).stdout + ) + } + found = {} + for line in pathlib.Path("/tmp/digests.txt").read_text().splitlines(): + name, _, digest = line.partition("=") + name, digest = name.strip(), digest.strip() + if not name or not digest: + continue + if not digest.startswith("sha256:"): + sys.exit(f"{name}: {digest!r} is not a digest") + if name in found and found[name] != digest: + sys.exit(f"{name}: the run reported two different digests") + found[name] = digest + + missing = sorted(expected - set(found)) + unexpected = sorted(set(found) - expected) + if missing or unexpected: + if missing: + print("The build did not produce these images:", ", ".join(missing)) + if unexpected: + print("The build produced images no flavor asks for:", ", ".join(unexpected)) + sys.exit( + "Refusing to advance :testing. config/flavors.json is the only " + "source for which images exist, and this run does not match it." + ) + pathlib.Path("/tmp/promote.txt").write_text( + "".join(f"{name}={found[name]}\n" for name in sorted(expected)) + ) + print(f"verified all {len(expected)} promised images:", ", ".join(sorted(expected))) + PY - name: Promote verified images to testing env: GH_TOKEN: ${{ github.token }} @@ -30,10 +86,7 @@ jobs: run: | set -euo pipefail echo "$GH_TOKEN" | skopeo login ghcr.io --username "${{ github.actor }}" --password-stdin - count=0 while IFS='=' read -r name digest; do - [[ -n "$name" && "$digest" == sha256:* ]] || continue + [ -n "$name" ] || continue skopeo copy --all "docker://${REGISTRY}/${name}@${digest}" "docker://${REGISTRY}/${name}:testing" - count=$((count + 1)) - done < <(find /tmp/digests -name '*.txt' -exec cat {} +) - test "$count" -eq 4 + done < /tmp/promote.txt diff --git a/Justfile b/Justfile index bd79a4eca..43c8eeaba 100644 --- a/Justfile +++ b/Justfile @@ -75,6 +75,11 @@ check: # config/flavors.json exists to stop: narrowing the build matrix while # promote and release still name images nothing produces fails late. ! grep -rn 'utah-nvidia\|utah-gaming' .github/workflows/ + # Nor its own count of them. Promotion asserted `count -eq 4` after it had + # already copied whatever it found, so a short set advanced :testing for + # the flavors it did reach and failed afterwards. + ! grep -nE '\-eq [0-9]+' .github/workflows/post-testing-e2e.yml + grep -q 'scripts/flavors.py' .github/workflows/post-testing-e2e.yml # Verify branding, desktop defaults, first-boot Flatpak policy, and service # enablement in an already-composed image. The same verifier runs in the From e44f2805d19ceb6bda28822bc08fba41640503c7 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 2 Sep 2026 20:56:28 +0000 Subject: [PATCH 2/6] ci: boot every flavor before advancing :testing, and record Firefox as a Flatpak Two things, both about a published image containing what it promises. Firefox. The package factory used to build the RPM and stopped: a full PGO and LTO Gecko compile was the longest build it had, it repeatedly hit the runner memory ceiling, and nothing else links it. There is no packages/firefox recipe any more, so `firefox` and `firefox-langpacks` can never appear in Utah's repositories and `just check-repos` was right to fail. What ships instead was already here: org.mozilla.firefox is in the desktop contract and 99-flatpaks.sh installs Bluefin's own policy into its systemconfig extension, and verify-desktop-contract asserts that on every build. Both names move to [unavailable] with that reasoning, so the parity arithmetic stays honest rather than passing silently. Booting. The Containerfile asserts what an image contains -- package contract, desktop contract, extensions, bootc lint -- and none of it can say the image starts. Three of this project's claims live entirely on the other side of a boot: that a desktop appears, that the gaming flavors run the OGC kernel and not the stock one, and that the NVIDIA module matches the kernel that actually booted rather than the one it was compiled against. The README calls those unproven, and they stayed unproven because nothing could prove them. scripts/verify-boot.sh checks them from inside a booted system and prints one marker line. Containerfile.e2e derives a throwaway layer that runs it on first boot and powers off; `just e2e-boot` installs that to a disk and boots it under QEMU with the console on a serial port. A hang or a panic produces no marker, so it cannot be mistaken for a pass. The layer is never published -- it carries a unit that powers the machine off shortly after gdm starts, which is exactly the sort of thing that must not reach anyone. post-testing-e2e now resolves the image set once, boots every image in it, and promotes only that list. Promotion previously copied each digest as it read it and counted afterwards; it now cannot advance :testing for an image that has not started. Hosted runners have no KVM so this is TCG and slow, which is the price of the only check that answers the question. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KVSCoKWBWAuFFZyLwteEbB --- .github/workflows/post-testing-e2e.yml | 89 +++++++++++++++++-- Containerfile.e2e | 41 +++++++++ Justfile | 72 +++++++++++++++ README.md | 5 +- docs/building.md | 26 ++++++ packages/utah.toml | 21 +++++ scripts/verify-boot.sh | 117 +++++++++++++++++++++++++ 7 files changed, 362 insertions(+), 9 deletions(-) create mode 100644 Containerfile.e2e create mode 100755 scripts/verify-boot.sh diff --git a/.github/workflows/post-testing-e2e.yml b/.github/workflows/post-testing-e2e.yml index e3173f2af..826d06579 100644 --- a/.github/workflows/post-testing-e2e.yml +++ b/.github/workflows/post-testing-e2e.yml @@ -9,15 +9,19 @@ on: permissions: read-all jobs: - promote-to-testing: + # Which images the run produced, and their digests, resolved once so the boot + # matrix and the promotion agree on exactly the same set. + resolve: if: >- github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'testing' - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: - packages: write actions: read + contents: read + outputs: + images: ${{ steps.verify.outputs.images }} steps: - name: Checkout uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 @@ -40,7 +44,7 @@ jobs: set -euo pipefail find /tmp/digests -name '*.txt' -exec cat {} + > /tmp/digests.txt python3 - <<'PY' - import json, pathlib, subprocess, sys + import json, os, pathlib, subprocess, sys expected = { item["image"] @@ -74,19 +78,88 @@ jobs: "Refusing to advance :testing. config/flavors.json is the only " "source for which images exist, and this run does not match it." ) - pathlib.Path("/tmp/promote.txt").write_text( - "".join(f"{name}={found[name]}\n" for name in sorted(expected)) - ) + images = [{"image": name, "digest": found[name]} for name in sorted(expected)] + with open(os.environ["GITHUB_OUTPUT"], "a") as handle: + handle.write("images=" + json.dumps(images) + "\n") print(f"verified all {len(expected)} promised images:", ", ".join(sorted(expected))) PY - - name: Promote verified images to testing + + # Every promised image is booted before any of them is promoted. The build + # already asserts what an image contains -- the package contract, the desktop + # contract, the extensions, bootc lint -- and none of that can tell you it + # comes up, that the gaming flavors boot the OGC kernel rather than the stock + # one, or that the NVIDIA module matches the kernel that actually booted. + # Those are the claims the README calls unproven, so they are checked here + # rather than asserted in prose. + boot: + needs: resolve + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: read + strategy: + fail-fast: false + matrix: + image: ${{ fromJSON(needs.resolve.outputs.images) }} + # TCG emulation without KVM, which hosted runners do not offer. A desktop + # image takes minutes to reach gdm this way. + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + ref: ${{ github.event.workflow_run.head_sha }} + - name: Install just + uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3 + - name: Free disk space + run: | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY" + df -h / + - name: Install QEMU and UEFI firmware + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends qemu-system-x86 ovmf + - name: Log in to GHCR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: echo "$GITHUB_TOKEN" | podman login ghcr.io -u "${{ github.actor }}" --password-stdin + - name: Boot ${{ matrix.image.image }} and verify it + env: + REGISTRY: ghcr.io/${{ github.repository_owner }} + run: | + set -euo pipefail + ref="${REGISTRY}/${{ matrix.image.image }}@${{ matrix.image.digest }}" + # By digest, so the image booted is the exact one that will be + # promoted rather than whatever the tag points at by then. + podman pull "$ref" + just e2e-boot "$ref" + + promote-to-testing: + needs: [resolve, boot] + runs-on: ubuntu-24.04 + permissions: + packages: write + actions: read + steps: + # No re-derivation here. resolve already checked the run against + # config/flavors.json and boot proved every one of those images starts, + # so this copies exactly that list and nothing else. + - name: Promote the booted images to testing env: GH_TOKEN: ${{ github.token }} REGISTRY: ghcr.io/${{ github.repository_owner }} + IMAGES: ${{ needs.resolve.outputs.images }} run: | set -euo pipefail echo "$GH_TOKEN" | skopeo login ghcr.io --username "${{ github.actor }}" --password-stdin + python3 - <<'PY' > /tmp/promote.txt + import json, os + for item in json.loads(os.environ["IMAGES"]): + print(item["image"], item["digest"], sep="=") + PY + test -s /tmp/promote.txt while IFS='=' read -r name digest; do [ -n "$name" ] || continue + echo "promoting ${name}@${digest}" skopeo copy --all "docker://${REGISTRY}/${name}@${digest}" "docker://${REGISTRY}/${name}:testing" done < /tmp/promote.txt diff --git a/Containerfile.e2e b/Containerfile.e2e new file mode 100644 index 000000000..463237c15 --- /dev/null +++ b/Containerfile.e2e @@ -0,0 +1,41 @@ +# The boot test layer. Never published. +# +# A published image must contain what it promises and nothing else, so the unit +# that drives the boot check does not live in it. This derives from a finished +# flavor image, adds the verifier and a first-boot unit, and is installed to a +# throwaway disk by `just e2e-disk`. The image under test is unmodified in +# every other respect: same kernel, same packages, same configuration, so what +# boots here is what would boot on hardware. +ARG IMAGE +FROM ${IMAGE} + +COPY scripts/verify-boot.sh /usr/local/libexec/utah-verify-boot + +# Ordered after gdm rather than after graphical.target: reaching the target +# does not mean the display manager came up, and gdm is what a user meets +# first. The verifier polls for it anyway, so a slow start is not a failure. +# +# Output goes to the console because that is the only channel the harness has: +# it reads the serial port of a VM it cannot log in to. +RUN chmod 0755 /usr/local/libexec/utah-verify-boot && \ + printf '%s\n' \ + '[Unit]' \ + 'Description=Utah boot verification' \ + 'After=gdm.service systemd-user-sessions.service' \ + 'Wants=gdm.service' \ + '' \ + '[Service]' \ + 'Type=oneshot' \ + 'RemainAfterExit=yes' \ + 'ExecStart=/usr/local/libexec/utah-verify-boot' \ + 'StandardOutput=journal+console' \ + 'StandardError=journal+console' \ + '# Whatever the verdict, the VM must not sit there until the job times' \ + '# out. The harness decides pass or fail from the console text.' \ + 'ExecStopPost=/usr/bin/systemctl --no-block poweroff' \ + '' \ + '[Install]' \ + 'WantedBy=multi-user.target' \ + > /usr/lib/systemd/system/utah-verify-boot.service && \ + systemctl enable utah-verify-boot.service && \ + test -x /usr/local/libexec/utah-verify-boot diff --git a/Justfile b/Justfile index 43c8eeaba..8e48e3743 100644 --- a/Justfile +++ b/Justfile @@ -80,6 +80,18 @@ check: # the flavors it did reach and failed afterwards. ! grep -nE '\-eq [0-9]+' .github/workflows/post-testing-e2e.yml grep -q 'scripts/flavors.py' .github/workflows/post-testing-e2e.yml + # Promotion must be gated on a real boot, not only on the build's own + # in-image contract checks. Those cannot see whether the thing starts. + test -f scripts/verify-boot.sh + test -f Containerfile.e2e + bash -n scripts/verify-boot.sh + grep -q 'e2e-boot' .github/workflows/post-testing-e2e.yml + grep -qE '^\s*needs: \[resolve, boot\]' .github/workflows/post-testing-e2e.yml + grep -q 'UTAH_BOOT_OK' scripts/verify-boot.sh + # The verification layer is a test artifact. If it ever appears in the + # image's own Containerfile it would ship a unit that powers the machine + # off shortly after gdm starts. + ! grep -q 'verify-boot' Containerfile # Verify branding, desktop defaults, first-boot Flatpak policy, and service # enablement in an already-composed image. The same verifier runs in the @@ -306,6 +318,66 @@ generate-bootable-image stream="testing": sync echo "Bootable disk ready: $disk" +# The runner has no KVM, so this is TCG emulation and slow -- minutes, not +# seconds. That is still the cheapest honest answer to "does it boot", and it +# is the one gate the build-time contract checks cannot supply. +# +# Boot an image headless and assert what only a boot can show. +e2e-boot image_ref timeout="1800": + #!/usr/bin/env bash + set -euo pipefail + work="$(mktemp -d)" + trap 'rm -rf "$work"' EXIT + # The verification layer is built here and never pushed; see + # Containerfile.e2e for why it is not part of the image under test. + test_ref="localhost/utah-e2e:$(date +%s)" + podman build --build-arg IMAGE="{{ image_ref }}" \ + --tag "$test_ref" --file Containerfile.e2e . + disk="$work/boot.raw" + truncate -s 20G "$disk" + # console=ttyS0 is what makes the verifier readable: the harness has no way + # into this VM other than the serial port. + sudo podman run --rm --privileged --pid=host \ + --security-opt label=type:unconfined_t \ + -v "$work:/data:Z" \ + "$test_ref" bootc install to-disk \ + --via-loopback /data/boot.raw --filesystem btrfs --wipe \ + --generic-image --karg console=ttyS0,115200 --karg utah.local + sudo chown "$(id -u):$(id -g)" "$disk" + # A fresh VM has no NVRAM entry, so install the removable-media fallback + # the same way generate-bootable-image does. + loop="$(sudo losetup --find --show --partscan "$disk")" + esp="$work/esp"; mkdir -p "$esp" + sudo mount "${loop}p2" "$esp" + sudo install -d "$esp/EFI/BOOT" + sudo install -m 0644 "$esp/EFI/fedora/shimx64.efi" "$esp/EFI/BOOT/BOOTX64.EFI" + sudo install -m 0644 "$esp/EFI/fedora/grubx64.efi" "$esp/EFI/BOOT/grubx64.efi" + sudo umount "$esp" + sudo losetup -d "$loop" + cp /usr/share/OVMF/OVMF_VARS_4M.fd "$work/vars.fd" 2>/dev/null \ + || cp /usr/share/OVMF/OVMF_VARS.fd "$work/vars.fd" + code=/usr/share/OVMF/OVMF_CODE_4M.fd + test -f "$code" || code=/usr/share/OVMF/OVMF_CODE.fd + log="$work/console.log" + set +e + timeout "{{ timeout }}" qemu-system-x86_64 \ + -machine q35 -m 4096 -smp "$(nproc)" -no-reboot -nographic \ + -drive "if=pflash,format=raw,unit=0,readonly=on,file=$code" \ + -drive "if=pflash,format=raw,unit=1,file=$work/vars.fd" \ + -drive "file=$disk,format=raw,if=virtio" \ + -serial "file:$log" -display none + set -e + echo "--- serial console" + cat "$log" || true + echo "--- end serial console" + if grep -q '^UTAH_BOOT_OK ' "$log"; then + grep '^UTAH_BOOT_OK ' "$log" + exit 0 + fi + echo "The VM never reported a successful boot." >&2 + grep -E 'utah-boot:|Kernel panic|emergency|Failed to' "$log" >&2 || true + exit 1 + # Build a single-architecture UEFI live ISO. This first slice proves the # Utah live boot path; installer payload integration is intentionally the next # ISO milestone. diff --git a/README.md b/README.md index c0b1fbca7..22d9b7695 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,10 @@ This is the honest list, and it is why the label above says pre-alpha. - **Nothing is published.** No image, no ISO, no installer. An ISO is planned as a fork of [dakota-iso](https://github.com/projectbluefin/dakota-iso). -- **The NVIDIA and gaming flavors are unproven.** The OGC kernel compiles with +- **The NVIDIA and gaming flavors are unproven.** Nothing asserted the claims + below across a boot until `post-testing-e2e.yml` gained a boot gate; it now + checks them on every flavor before `:testing` moves, so this entry should be + settled by the first green run rather than by argument. The OGC kernel compiles with `sched_ext` and `binderfs` genuinely enabled, and the NVIDIA open module compiles for the base kernel. The module against the OGC kernel, the driver installer flags, and the flavored builds pulling the kernel cache image have diff --git a/docs/building.md b/docs/building.md index d8473bebf..4e7abaea9 100644 --- a/docs/building.md +++ b/docs/building.md @@ -67,6 +67,32 @@ The result is `output/utah-live.iso`, assembled with systemd-boot, a intended to prove live desktop boot first; bootc-installer/offline payload integration is the next ISO milestone. +### Proving an image boots + +The Containerfile asserts what an image *contains* -- the package contract, the +desktop contract, the GNOME extensions, `bootc container lint`. None of that can +say whether it starts, and three of Utah's claims live entirely on the other +side of a boot: that a desktop appears at all, that the gaming flavors run the +OGC kernel rather than the stock one, and that the NVIDIA module matches the +kernel that actually booted rather than the one it was compiled against. + +`just e2e-boot ` answers those. It derives a throwaway layer from the +image (`Containerfile.e2e`), which adds a first-boot unit running +`scripts/verify-boot.sh`, installs that to a disk with `bootc install to-disk`, +and boots it under QEMU with the console on a serial port. The verifier prints +its findings and one marker line, `UTAH_BOOT_OK`, and powers the machine off; +the caller passes only if that marker appears. A VM that panics or hangs cannot +look like a pass, because a hang produces no marker either. + +That layer is never published. A published image must contain what it promises +and nothing more, and it certainly must not carry a unit that powers the machine +off once gdm is up. + +`post-testing-e2e.yml` runs it for every flavor between verifying the image set +and advancing `:testing`, so an image that does not boot cannot be promoted. +Hosted runners offer no KVM, so this is TCG emulation and takes minutes per +flavor; that is the cost of the only check that can answer the question. + ### Image flavors `config/flavors.json` decides which images exist. Everything derives from it -- diff --git a/packages/utah.toml b/packages/utah.toml index 748609e94..a1ac82590 100644 --- a/packages/utah.toml +++ b/packages/utah.toml @@ -100,8 +100,29 @@ packages = [ # (ruby-default-gems) into a buildroot that already carries Hummingbird's # ruby4.0. The two conflict on file paths, so the transaction fails. Needs # either a ruby exclusion in the buildroot or dropping the html subpackage. +# +# firefox, firefox-langpacks +# Not a gap: a deliberate substitution, and the only entry here that is not +# parity debt. The package factory used to build the RPM and stopped -- a +# full PGO and LTO Gecko compile was the longest build it had and it +# repeatedly hit the runner memory ceiling, for a leaf application no other +# package links. There is no packages/firefox recipe any more, so the name +# can never appear in Utah's repositories. +# +# What ships instead is the Flatpak, which was already here before the RPM +# went away: org.mozilla.firefox is in contracts/bluefin-desktop.toml, and +# system_files/.../99-flatpaks.sh installs Bluefin's own policy into the +# org.mozilla.firefox.systemconfig extension. So the browser is present and +# configured; verify-desktop-contract.py asserts it on every build, which is +# a stronger check than the RPM name ever got. +# +# This entry exists so the parity arithmetic stays honest: Bluefin's manifest +# asks for an RPM Utah does not install, and that is recorded here rather +# than passing silently. packages = [ "evolution-ews-core", + "firefox", + "firefox-langpacks", "fish", "tailscale", "zsh", diff --git a/scripts/verify-boot.sh b/scripts/verify-boot.sh new file mode 100755 index 000000000..8da316f3c --- /dev/null +++ b/scripts/verify-boot.sh @@ -0,0 +1,117 @@ +#!/usr/bin/bash +# Assert, from inside a booted Utah system, the things a container cannot show. +# +# Everything the image *contains* is already checked at build time: +# verify-rpm-contract, verify-desktop-contract, verify-gnome-extensions and +# bootc lint all run in the Containerfile. None of them can tell you whether the +# result boots, whether the kernel that boots is the one the flavor asked for, +# or whether the features that kernel exists for are actually live. That is what +# this checks, and it runs once on the first boot of a throwaway VM. +# +# It prints its findings to the console and ends with a single marker line the +# harness greps for. Anything unexpected exits non-zero without the marker, so a +# missing marker and a failure are the same thing to the caller -- a VM that +# hung or panicked cannot look like a pass. +set -uo pipefail + +# configure-branding.sh records this; it is the image's own statement of which +# flavor it is, so the checks below test the image against itself rather than +# against something the harness passed in and could get wrong. +IMAGE_INFO=/usr/share/ublue-os/image-info.json +FLAVOR="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["image-flavor"])' "$IMAGE_INFO" 2>/dev/null || echo unknown)" +KERNEL="$(uname -r)" +failures=0 + +note() { printf 'utah-boot: %s\n' "$*"; } +fail() { printf 'utah-boot: FAIL %s\n' "$*"; failures=$((failures + 1)); } + +# systemd first: a degraded system may still start gdm, and the failed units +# are the most useful thing to print when something below goes wrong. +state="$(systemctl is-system-running 2>/dev/null || true)" +note "systemd state: ${state}" +case "$state" in + running) ;; + degraded) + fail "systemd is degraded" + systemctl --failed --no-legend --no-pager || true + ;; + *) fail "systemd never settled (${state})" ;; +esac + +# The desktop. gdm is what 85-utah-desktop.preset enables and what a user sees +# first; graphical.target alone would be satisfied without it. +for _ in $(seq 1 60); do + [ "$(systemctl is-active gdm.service 2>/dev/null)" = active ] && break + sleep 5 +done +if [ "$(systemctl is-active gdm.service 2>/dev/null)" = active ]; then + note "gdm.service is active" +else + fail "gdm.service did not become active" + systemctl status gdm.service --no-pager -l 2>&1 | head -40 || true +fi + +# Identity. The flavored repository name must not have leaked into the OS +# identity: every flavor presents itself as utah. +for pair in IMAGE_ID=utah VARIANT_ID=utah; do + key="${pair%%=*}"; want="${pair#*=}" + got="$(. /usr/lib/os-release 2>/dev/null; eval "printf '%s' \"\${$key:-}\"")" + [ "$got" = "$want" ] && note "os-release ${key}=${got}" || fail "os-release ${key} is '${got}', expected '${want}'" +done + +ogc_release="" +[ -f /usr/lib/utah/ogc-kernel-release ] && ogc_release="$(cat /usr/lib/utah/ogc-kernel-release)" + +case "$FLAVOR" in + gaming|nvidia-gaming) + # The OGC kernel is the only reason these flavors exist, so booting the + # stock kernel instead is a silent, total failure of the flavor. + if [ -z "$ogc_release" ]; then + fail "no OGC kernel release recorded in the image" + elif [ "$KERNEL" = "$ogc_release" ]; then + note "booted the OGC kernel ${KERNEL}" + else + fail "booted ${KERNEL}, expected the OGC kernel ${ogc_release}" + fi + # sched_ext and binderfs are what the OGC kernel is built for. The config + # was asserted when it was compiled; these are the runtime proof. + [ -d /sys/kernel/sched_ext ] && note "sched_ext is live" || fail "no /sys/kernel/sched_ext" + grep -qw binder /proc/filesystems && note "binderfs is registered" \ + || fail "binderfs is not in /proc/filesystems" + ;; + main|nvidia) + if [ -n "$ogc_release" ] && [ "$KERNEL" = "$ogc_release" ]; then + fail "booted the OGC kernel on the ${FLAVOR} flavor" + else + note "booted the stock kernel ${KERNEL}" + fi + ;; + *) fail "unknown image flavor '${FLAVOR}'" ;; +esac + +case "$FLAVOR" in + nvidia|nvidia-gaming) + # Built against the kernel that is now running, which is the thing the + # build could only assume. Loading it needs a GPU the runner has not got, + # so this asserts the module is present and readable for this kernel. + module="/usr/lib/modules/${KERNEL}/extra/nvidia/nvidia.ko" + if [ -f "$module" ]; then + note "nvidia.ko present for ${KERNEL}" + else + fail "no nvidia.ko for the booted kernel ${KERNEL}" + find "/usr/lib/modules/${KERNEL}/extra" -maxdepth 3 2>/dev/null || true + fi + modinfo -F version nvidia >/dev/null 2>&1 \ + && note "modinfo resolves nvidia $(modinfo -F version nvidia 2>/dev/null)" \ + || fail "modinfo cannot resolve the nvidia module for ${KERNEL}" + grep -q 'blacklist nouveau' /usr/lib/modprobe.d/00-nouveau-blacklist.conf 2>/dev/null \ + && note "nouveau is blacklisted" || fail "nouveau blacklist is missing" + ;; +esac + +if [ "$failures" -ne 0 ]; then + printf 'utah-boot: %s check(s) failed on %s\n' "$failures" "$FLAVOR" + exit 1 +fi +# The harness greps for exactly this. Keep it on one line and last. +printf 'UTAH_BOOT_OK flavor=%s kernel=%s\n' "$FLAVOR" "$KERNEL" From 814422ed0819017a290273809b94c51ddcd41e9b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 5 Sep 2026 06:33:12 +0000 Subject: [PATCH 3/6] feat: install device firmware, which Utah had none of Utah reaches GDM and cannot bring up a wifi adapter. Established by checking the whole chain rather than inferring it: Hummingbird bootc-os base image 262 packages: kernel, kernel-core, kernel-modules, kernel-modules-core, and no linux-firmware Hummingbird RPM repository 3,511 packages, and the only match for firm/iwl/wifi/wireless is NetworkManager-wifi packages/bluefin.toml alsa-firmware, alsa-tools-firmware packages/utah.toml nothing Bluefin never names linux-firmware because it inherits it from its Fedora base image, so it is absent from the parity contract this repository copies byte-for-byte. Swapping the base to Hummingbird's bootc-os dropped it in silence. Nothing Requires linux-firmware, so no dependency resolution pulls it and the factory's consumer transaction is satisfied without it; the boot test added in this branch runs under QEMU on virtio, which needs no firmware blobs. Every gate passed on an image with no firmware at all. Wireless is the headline, but GPUs and Bluetooth are in the same position. Fedora splits one linux-firmware source into thirty subpackages by device family. All thirty are listed here, which is what parity with Fedora means: iwlwifi dvm/mvm/mld, atheros, brcmfmac, mt7xxx, realtek, mediatek, nxpwireless, tiwilink and libertas for wireless; amd, intel and nvidia GPU; cirrus and intel audio; amd-ucode; and the datacenter NIC families. Together they are roughly 740 MiB. If image size becomes the binding constraint, the datacenter NICs and the Qualcomm SoC firmware are the obvious trim for an x86_64 desktop and would save about 350 MiB -- recorded in the section as a reduction to decide on rather than a default to drift into. install-packages.py needed the section wired in. contract() composes the install set from named sections, so a new [firmware] section would have been read by nobody and silently installed nothing -- the failure mode this whole change exists to fix, repeated one level up. The install set goes from 71 to 101. These are not published yet: utah-packages is building linux-firmware for the first time, so check-repo-availability.py will report them missing until that lands. That is the same position every other package in this branch is in. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KVSCoKWBWAuFFZyLwteEbB --- packages/utah.toml | 53 +++++++++++++++++++++++++++++++++++++ scripts/install-packages.py | 4 +++ 2 files changed, 57 insertions(+) diff --git a/packages/utah.toml b/packages/utah.toml index a1ac82590..3a9b9570b 100644 --- a/packages/utah.toml +++ b/packages/utah.toml @@ -7,6 +7,7 @@ # # Sections: # [gnome] GNOME 51 desktop contract Hummingbird does not ship +# [firmware] device firmware Bluefin inherits from its Fedora base # [build] toolchain needed to build the pinned GNOME extensions # [unavailable] Bluefin contract packages with no Fedora Rawhide source # @@ -48,6 +49,58 @@ packages = [ "xdg-desktop-portal-gnome", ] +[firmware] +# Bluefin never names these: it inherits them from its Fedora base image, so +# they are absent from the parity contract in packages/bluefin.toml. Utah's +# base is Hummingbird's bootc-os, which ships the kernel and no firmware at +# all -- 262 packages, none of them linux-firmware -- and Hummingbird's +# repository has no firmware package either. Nothing Requires linux-firmware, +# so no dependency resolution pulls it in and no gate noticed: the boot test +# runs under QEMU on virtio, which needs no firmware blobs. The result was an +# image that reaches GDM and cannot bring up any wifi adapter that loads a +# blob, which is nearly all of them, nor an AMD, Intel or NVIDIA GPU at full +# capability. +# +# Fedora splits one linux-firmware source into these thirty subpackages by +# device family. All thirty are listed, which is what parity with Fedora +# means; together they are roughly 740 MiB. If image size becomes the binding +# constraint, the datacenter NIC families -- liquidio, mlxsw_spectrum, +# mrvlprestera, netronome, qed -- and the Qualcomm SoC ones are the obvious +# trim for an x86_64 desktop, worth about 350 MiB. That is a reduction to +# decide on, not a default to drift into. +packages = [ + "amd-gpu-firmware", + "amd-ucode-firmware", + "atheros-firmware", + "brcmfmac-firmware", + "cirrus-audio-firmware", + "dvb-firmware", + "intel-audio-firmware", + "intel-gpu-firmware", + "intel-vsc-firmware", + "iwlegacy-firmware", + "iwlwifi-dvm-firmware", + "iwlwifi-mld-firmware", + "iwlwifi-mvm-firmware", + "libertas-firmware", + "linux-firmware", + "linux-firmware-whence", + "liquidio-firmware", + "mediatek-firmware", + "mlxsw_spectrum-firmware", + "mrvlprestera-firmware", + "mt7xxx-firmware", + "netronome-firmware", + "nvidia-gpu-firmware", + "nxpwireless-firmware", + "qcom-accel-firmware", + "qcom-firmware", + "qcom-wwan-firmware", + "qed-firmware", + "realtek-firmware", + "tiwilink-firmware", +] + [build] # Build dependencies for scripts/build-gnome-extensions.sh. packages = [ diff --git a/scripts/install-packages.py b/scripts/install-packages.py index fa7e5ab69..0e006b3fa 100755 --- a/scripts/install-packages.py +++ b/scripts/install-packages.py @@ -55,6 +55,10 @@ def contract(base: Path, overlay: Path, major: str | None) -> list[str]: # Service packages are part of the desktop contract as well: 40-services.sh # cannot enable what the server base never installed. packages += section(overlay, "services") + # Firmware likewise. Bluefin inherits it from its Fedora base and so never + # names it; Hummingbird's base ships none, and nothing Requires it, so it + # reaches the image only by being asked for here. + packages += section(overlay, "firmware") unavailable = set(section(overlay, "unavailable")) # Deduplicate while preserving order so build logs stay diffable. seen: dict[str, None] = {} From 10d99b4f4baffa621cf29679077766a207aa10fb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 5 Sep 2026 06:39:31 +0000 Subject: [PATCH 4/6] fix: match Bluefin's firmware set, and close the holes that hid it Two corrections, one of them to my own last commit. FIRST, the set. I listed all thirty linux-firmware subpackages on the reasoning that parity with Fedora means taking what Fedora splits out. Bluefin is the actual parity target, and files/pkg-churn.json in projectbluefin/bluefin records what that image carries: twenty-one of the thirty, plus alsa-sof-firmware. It leaves behind the datacenter NIC families -- liquidio, mlxsw_spectrum, mrvlprestera, netronome, qed -- and the Qualcomm SoC ones. Matching Bluefin instead of Fedora drops about 350 MiB, most of it qcom-firmware at 148 MiB and mlxsw_spectrum-firmware at 102 MiB, neither of which an x86_64 desktop loads. Bluefin keeps qcom-wwan-firmware for modems and mt7xxx-firmware for MediaTek wireless while dropping the broader mediatek-firmware; that asymmetry is theirs and is copied rather than tidied. Dakota was read too. It curates at file level -- 6,810 files under components/linux-firmware.bst -- and its set is wider than Bluefin's, carrying qcom, netronome, mellanox and qed. Bluefin is the closer comparison and the contract this repository already tracks, so it is the one matched. Dakota does settle one thing: alsa-sof-firmware gets its own component there, components/sof-firmware.bst, which is a second vote for treating Sound Open Firmware as its own concern rather than a detail of the blob set. Without it a modern Intel laptop has no audio at all, and nothing in Utah's stack had it. SECOND, and worse: the check that should have caught this could not see it. check-repo-availability.py composes its list from sections named one at a time, and [firmware] was not among them -- so the twenty-two packages were installed and never preflighted. I predicted the contract check would report 32 missing names after the last commit; it reported 2, and that gap is the bug, not a happy surprise. The same enumeration was missing [services] entirely, which has been installed and unverified all along, and verify-rpm-contract.py's off-image --check path had the same shape. That is three copies of the failure this whole change exists to fix: a package set that is live in one place and invisible in another, failing quietly. So scripts/check-overlay-sections.py now asserts that every section of utah.toml is read by every consumer that must read it, with the one exemption written down rather than assumed -- verify-rpm-contract.py does not check [build], because the toolchain is installed, used and removed inside the build. It runs in `just check`, so the next section added to utah.toml fails there instead of on hardware. The install set goes to 93 and the contract verifier now reports firmware as its own count: 60 Bluefin, 10 GNOME, 2 services, 22 firmware. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KVSCoKWBWAuFFZyLwteEbB --- Justfile | 5 ++ packages/utah.toml | 52 +++++++++++---------- scripts/check-overlay-sections.py | 73 ++++++++++++++++++++++++++++++ scripts/check-repo-availability.py | 9 ++++ scripts/verify-rpm-contract.py | 14 ++++-- 5 files changed, 127 insertions(+), 26 deletions(-) create mode 100755 scripts/check-overlay-sections.py diff --git a/Justfile b/Justfile index 8e48e3743..35892992f 100644 --- a/Justfile +++ b/Justfile @@ -55,6 +55,11 @@ check: python3 -m py_compile scripts/verify-rpm-contract.py python3 -m py_compile scripts/check-repo-availability.py python3 scripts/install-packages.py --check packages/bluefin.toml + # Both scripts compose their package list from sections named one by + # one, so a new section in utah.toml can be live in one and invisible + # to the other. [services] was unverified that way, and [firmware] + # briefly was too. + python3 scripts/check-overlay-sections.py python3 scripts/verify-rpm-contract.py --check packages/bluefin.toml grep -qE 'reusable-build\.yml@(v1|[0-9a-f]{40} # v1)$' .github/workflows/build.yml test -f Containerfile.kernel diff --git a/packages/utah.toml b/packages/utah.toml index 3a9b9570b..b1a3b7611 100644 --- a/packages/utah.toml +++ b/packages/utah.toml @@ -54,27 +54,41 @@ packages = [ # they are absent from the parity contract in packages/bluefin.toml. Utah's # base is Hummingbird's bootc-os, which ships the kernel and no firmware at # all -- 262 packages, none of them linux-firmware -- and Hummingbird's -# repository has no firmware package either. Nothing Requires linux-firmware, -# so no dependency resolution pulls it in and no gate noticed: the boot test -# runs under QEMU on virtio, which needs no firmware blobs. The result was an -# image that reaches GDM and cannot bring up any wifi adapter that loads a -# blob, which is nearly all of them, nor an AMD, Intel or NVIDIA GPU at full -# capability. -# -# Fedora splits one linux-firmware source into these thirty subpackages by -# device family. All thirty are listed, which is what parity with Fedora -# means; together they are roughly 740 MiB. If image size becomes the binding -# constraint, the datacenter NIC families -- liquidio, mlxsw_spectrum, -# mrvlprestera, netronome, qed -- and the Qualcomm SoC ones are the obvious -# trim for an x86_64 desktop, worth about 350 MiB. That is a reduction to -# decide on, not a default to drift into. +# repository has none either. Nothing Requires linux-firmware, so no +# resolution pulls it in and no gate noticed: the boot test runs under QEMU on +# virtio, which needs no firmware blobs. The result was an image that reaches +# GDM and cannot bring up any wifi adapter that loads a blob, which is nearly +# all of them, nor an AMD, Intel or NVIDIA GPU at full capability. +# +# This list is Bluefin's, read out of files/pkg-churn.json in +# projectbluefin/bluefin, which records what that image actually carries. That +# is the parity target, not "everything Fedora splits out of linux-firmware". +# Bluefin takes twenty-one of the thirty subpackages and leaves the datacenter +# NIC families -- liquidio, mlxsw_spectrum, mrvlprestera, netronome, qed -- and +# the Qualcomm SoC ones behind. Matching it rather than taking the lot saves +# about 350 MiB, most of that qcom-firmware at 148 MiB and +# mlxsw_spectrum-firmware at 102 MiB, neither of which an x86_64 desktop +# loads. Bluefin does keep qcom-wwan-firmware for modems and mt7xxx-firmware +# for MediaTek wireless while dropping the broader mediatek-firmware; that +# asymmetry is theirs, and it is copied rather than smoothed over. +# +# alsa-sof-firmware is the one entry that is not a linux-firmware subpackage. +# Sound Open Firmware is what a modern Intel laptop loads before it has audio +# at all. Dakota agrees strongly enough to give it its own BuildStream +# component, components/sof-firmware.bst, separate from linux-firmware. +# +# Dakota was read too. It curates at file level rather than by package -- 6,810 +# files under components/linux-firmware.bst -- and its set is wider than +# Bluefin's, carrying qcom, netronome, mellanox and qed. Bluefin is the closer +# comparison for Utah and the contract this repository already tracks, so it +# is the one matched. packages = [ + "alsa-sof-firmware", "amd-gpu-firmware", "amd-ucode-firmware", "atheros-firmware", "brcmfmac-firmware", "cirrus-audio-firmware", - "dvb-firmware", "intel-audio-firmware", "intel-gpu-firmware", "intel-vsc-firmware", @@ -85,18 +99,10 @@ packages = [ "libertas-firmware", "linux-firmware", "linux-firmware-whence", - "liquidio-firmware", - "mediatek-firmware", - "mlxsw_spectrum-firmware", - "mrvlprestera-firmware", "mt7xxx-firmware", - "netronome-firmware", "nvidia-gpu-firmware", "nxpwireless-firmware", - "qcom-accel-firmware", - "qcom-firmware", "qcom-wwan-firmware", - "qed-firmware", "realtek-firmware", "tiwilink-firmware", ] diff --git a/scripts/check-overlay-sections.py b/scripts/check-overlay-sections.py new file mode 100755 index 000000000..d217734a9 --- /dev/null +++ b/scripts/check-overlay-sections.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +"""Every section of packages/utah.toml must be consumed by both scripts. + +install-packages.py decides what the image installs; check-repo-availability.py +decides what gets preflighted. Both compose their list from sections named one +by one, so a section added to utah.toml and wired into only one of them is +silently half-live: installed but never verified, or verified but never +installed. Neither failure is loud. + +That has happened twice. [services] was installed and never preflighted. Then +[firmware] was added -- for packages whose absence had already shipped an image +with no wifi -- and was, for one commit, installed and unverified in exactly +the same way. This turns the next occurrence into a failure at `just check` +rather than a discovery on hardware. +""" + +from __future__ import annotations + +import re +import sys +import tomllib +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +OVERLAY = ROOT / "packages" / "utah.toml" +# Each consumer, with the sections it is allowed not to read and why. An +# exemption is a claim about the section's nature, so it has to be written +# down; anything not exempted must be read. +CONSUMERS = { + "install-packages.py": set(), + "check-repo-availability.py": set(), + # [build] is the toolchain for scripts/build-gnome-extensions.sh. It is + # installed, used and removed inside the build, so it is deliberately not + # part of what the finished image must contain. + "verify-rpm-contract.py": {"build"}, +} +# [unavailable] records contract packages no repository provides. Every script +# reads it to subtract rather than to add, so it is never in the wanted set. +EXEMPT = {"unavailable"} +SECTION = re.compile(r'section\((?:[A-Za-z_.\[\]"\' ]+),\s*"([a-z_]+)"\)') + + +def main() -> int: + sections = set(tomllib.loads(OVERLAY.read_text())) - EXEMPT + failed = False + for name, exempt in CONSUMERS.items(): + consumer = ROOT / "scripts" / name + read = set(SECTION.findall(consumer.read_text())) + missing = sorted(sections - read - exempt) + if missing: + failed = True + print( + f"ERROR: scripts/{name} never reads " + f"{', '.join('[' + section + ']' for section in missing)} " + f"from packages/utah.toml", + file=sys.stderr, + ) + if failed: + print( + "Add the section to the list that script composes, or move its " + "packages into a section that is already read.", + file=sys.stderr, + ) + return 1 + print( + f"overlay sections read by every consumer that must: " + f"{', '.join(sorted(sections))}" + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/check-repo-availability.py b/scripts/check-repo-availability.py index fb1b05e0a..59f3dd406 100644 --- a/scripts/check-repo-availability.py +++ b/scripts/check-repo-availability.py @@ -85,9 +85,18 @@ def main() -> int: overlay = args.overlay or args.manifest.with_name("utah.toml") unavailable = set(section(overlay, "unavailable")) + # Every section that reaches the image, named explicitly. This list has + # drifted from install-packages.py's twice: [services] was never checked, + # and [firmware] was installed but unverified the moment it was added. A + # section missing here is not a loud failure -- it is a package the image + # installs that nothing preflights, which is the exact shape of the bug + # that left Utah with no firmware at all. Adding a section to utah.toml + # means adding it in both places. wanted = sorted( set(section(args.manifest, "fedora")) | set(section(overlay, "gnome")) + | set(section(overlay, "firmware")) + | set(section(overlay, "services")) | set(section(overlay, "build")) ) names: set[str] = set() diff --git a/scripts/verify-rpm-contract.py b/scripts/verify-rpm-contract.py index 08fb22ff3..d0eba42ba 100644 --- a/scripts/verify-rpm-contract.py +++ b/scripts/verify-rpm-contract.py @@ -62,19 +62,27 @@ def main() -> int: contract = [line for line in resolved.read_text().split() if line] gnome_names = set(section(overlay, "gnome")) service_names = set(section(overlay, "services")) - bluefin = [p for p in contract if p not in gnome_names and p not in service_names] + firmware_names = set(section(overlay, "firmware")) + overlay_names = gnome_names | service_names | firmware_names + bluefin = [p for p in contract if p not in overlay_names] gnome = [p for p in contract if p in gnome_names] services = [p for p in contract if p in service_names] + firmware = [p for p in contract if p in firmware_names] else: bluefin = [p for p in section(args.manifest, "fedora") if p not in unavailable] gnome = section(overlay, "gnome") services = section(overlay, "services") + # The off-image fallback used to stop at services, so --check silently + # asserted nothing about firmware -- the same blind spot that let the + # image ship with none. + firmware = section(overlay, "firmware") nvidia = list(NVIDIA_PACKAGES) if "nvidia" in flavor else [] - expected = [*bluefin, *gnome, *services, *nvidia] + expected = [*bluefin, *gnome, *services, *firmware, *nvidia] print( f"Verifying {len(bluefin)} Bluefin packages, {len(gnome)} GNOME desktop packages," - f" {len(services)} desktop service packages, and {len(nvidia)} NVIDIA packages", + f" {len(services)} desktop service packages, {len(firmware)} firmware packages," + f" and {len(nvidia)} NVIDIA packages", flush=True, ) if args.check: From 36d6ddf7e4b8a14c8f1fe81ec99adebea74fd73e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 5 Sep 2026 07:29:15 +0000 Subject: [PATCH 5/6] ci: read the factory from its OCI image, not the Pages mirror The mirror is gone on the factory side -- linux-firmware put two files over GitHub Pages' 100 MB per-file limit and the site over its 1 GB total, and a mirror that quietly sheds packages while this script treats it as authoritative is worse than no mirror at all. So this reads the same OCI image Utah's Containerfile already consumes, which is a better source anyway: the preflight and the build now ask the same thing rather than a copy of it. ghcr hands out a pull token for public images without credentials, so this stays a dependency-free urllib script. Layers are tried smallest first and streamed, stopping at the primary index. The factory now copies repository/repodata into its own layer ahead of the full tree, so that is a few megabytes; an image built as a single layer still works, it just reads until it reaches repodata. Streaming rather than reading the blob whole is load-bearing -- buffering the current 524 MiB single layer raised IncompleteRead. Verified against the live registry: 421 binary packages, the same count the Pages mirror reported, and the same 25 contract names outstanding. The image build path never touched Pages. packages/utah-packages.repo is already file:///etc/utah-packages, filled from the digest-pinned package image; this check was the only reader left. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KVSCoKWBWAuFFZyLwteEbB --- scripts/check-repo-availability.py | 112 +++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 14 deletions(-) diff --git a/scripts/check-repo-availability.py b/scripts/check-repo-availability.py index 59f3dd406..cc487c4b2 100644 --- a/scripts/check-repo-availability.py +++ b/scripts/check-repo-availability.py @@ -15,21 +15,29 @@ from __future__ import annotations import argparse +import gzip import io +import json import re import sys +import tarfile import tomllib import urllib.request import xml.etree.ElementTree as ET from pathlib import Path -# The same repositories the image installs from, in the same precedence order: -# Hummingbird's own overlay plus the utah-packages factory (its Pages mirror, -# since check-repos runs in CI before the OCI repo is copied into the image). +# Hummingbird serves plain HTTP repodata. The factory publishes to a registry +# and nothing else -- the Pages mirror is gone, because linux-firmware put two +# files over the 100 MB per-file limit and the site over its 1 GB total, and a +# mirror that quietly drops packages while this script treats it as +# authoritative is worse than no mirror. So the factory is read out of the OCI +# image Utah's Containerfile already consumes, which also makes this check ask +# the same source the build does rather than a copy of it. REPOS = { "public-hummingbird": "https://packages.redhat.com/api/pulp-content/public-hummingbird/x86_64/", - "utah-packages": "https://projectbluefin.github.io/utah-packages/", } +FACTORY_IMAGE = "ghcr.io/projectbluefin/utah-packages" +FACTORY_TAG = "latest" def section(path: Path, name: str) -> list[str]: @@ -37,11 +45,91 @@ def section(path: Path, name: str) -> list[str]: return list(data.get(name, {}).get("packages", [])) -def fetch(url: str) -> bytes: - with urllib.request.urlopen(url, timeout=120) as response: +def fetch(url: str, headers: dict[str, str] | None = None) -> bytes: + request = urllib.request.Request(url, headers=headers or {}) + with urllib.request.urlopen(request, timeout=120) as response: return response.read() +def primary_names(stream) -> set[str]: + """Package names out of a primary.xml stream. + + Streamed rather than parsed into a tree: Hummingbird's index is ~16 MiB + across 66k packages and only at package scope matters here. + """ + names = set() + for line in io.TextIOWrapper(stream, encoding="utf-8", errors="replace"): + match = re.match(r"\s*([^<]+)", line) + if match: + names.add(match.group(1)) + return names + + +def registry_token(image: str) -> str: + """ghcr hands out a pull token for public images without credentials.""" + repository = image.split("/", 1)[1] + url = ( + "https://ghcr.io/token?service=ghcr.io" + f"&scope=repository:{repository}:pull" + ) + return json.loads(fetch(url))["token"] + + +def factory_package_names(image: str, tag: str) -> set[str]: + """Read repodata out of the published OCI repository image. + + The factory copies repository/repodata into its own layer ahead of the full + tree, so the metadata is a few megabytes at the front rather than behind a + gigabyte of RPMs. Layers are tried smallest first and streamed, stopping at + the primary index: an image built as a single layer still works, it just + reads until it reaches repodata rather than downloading a known-small blob. + """ + host, repository = image.split("/", 1) + token = registry_token(image) + accept = ", ".join( + ( + "application/vnd.oci.image.manifest.v1+json", + "application/vnd.docker.distribution.manifest.v2+json", + ) + ) + bearer = {"Authorization": f"Bearer {token}"} + base = f"https://{host}/v2/{repository}" + manifest = json.loads(fetch(f"{base}/manifests/{tag}", {**bearer, "Accept": accept})) + for layer in sorted(manifest["layers"], key=lambda entry: entry["size"]): + request = urllib.request.Request( + f"{base}/blobs/{layer['digest']}", headers=bearer + ) + with urllib.request.urlopen(request, timeout=600) as response: + media = layer.get("mediaType", "") + if media.endswith("zstd"): + import zstandard + + stream = zstandard.ZstdDecompressor( + max_window_size=2**31 + ).stream_reader(response) + else: + stream = gzip.GzipFile(fileobj=response) + # Streaming mode: members arrive in archive order and are read + # once, so nothing buffers the layer. A 500 MiB blob read whole + # raised IncompleteRead here before. + with tarfile.open(fileobj=stream, mode="r|*") as archive: + for member in archive: + name = member.name + if "repodata/" not in name or "primary" not in name: + continue + if not name.endswith((".gz", ".zst")): + continue + raw = archive.extractfile(member).read() + if name.endswith(".zst"): + import zstandard + + return primary_names( + zstandard.ZstdDecompressor().stream_reader(io.BytesIO(raw)) + ) + return primary_names(gzip.GzipFile(fileobj=io.BytesIO(raw))) + raise SystemExit(f"ERROR: no repodata layer in {image}:{tag}") + + def repo_package_names(base: str) -> set[str]: repomd = ET.fromstring(fetch(base + "repodata/repomd.xml")) ns = {"repo": "http://linux.duke.edu/metadata/repo"} @@ -67,14 +155,7 @@ def repo_package_names(base: str) -> set[str]: stream = gzip.GzipFile(fileobj=io.BytesIO(raw)) - names = set() - # Stream the ~16 MiB of metadata rather than holding a parse tree for - # 66k packages; only at package scope matters here. - for line in io.TextIOWrapper(stream, encoding="utf-8", errors="replace"): - match = re.match(r"\s*([^<]+)", line) - if match: - names.add(match.group(1)) - return names + return primary_names(stream) def main() -> int: @@ -104,6 +185,9 @@ def main() -> int: found = repo_package_names(base) print(f"{label}: {len(found)} binary packages") names |= found + factory = factory_package_names(FACTORY_IMAGE, FACTORY_TAG) + print(f"{FACTORY_IMAGE}:{FACTORY_TAG}: {len(factory)} binary packages") + names |= factory missing = [pkg for pkg in wanted if pkg not in names and pkg not in unavailable] resolved = sorted(pkg for pkg in unavailable if pkg in names) From a5519f705d77c93e251152317c71311ebb50f133 Mon Sep 17 00:00:00 2001 From: "sec-check[bot]" Date: Sat, 5 Sep 2026 22:18:02 -0400 Subject: [PATCH 6/6] ci: update setup-just action for Node 24 Signed-off-by: sec-check[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d80e40915..b0bee448e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: with: submodules: recursive - name: Install just - uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b # v3 + uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 - name: Install zstandard run: pip install --quiet zstandard - name: Validate manifests