diff --git a/Containerfile b/Containerfile index 64456f10..1f0d9bac 100644 --- a/Containerfile +++ b/Containerfile @@ -68,6 +68,7 @@ COPY --from=common /system_files/bluefin /tmp/utah-bluefin COPY --from=brew /system_files /tmp/utah-brew COPY system_files/shared /tmp/utah-local + RUN for pair in install-packages.py:utah-install-packages \ verify-rpm-contract.py:utah-verify-rpm-contract \ build-gnome-extensions.sh:utah-build-gnome-extensions \ diff --git a/Containerfile.kernel b/Containerfile.kernel index aa4d174f..94f51404 100644 --- a/Containerfile.kernel +++ b/Containerfile.kernel @@ -25,6 +25,7 @@ FROM ${BASE_IMAGE} AS builder # buildroot. Fedora is builder-only; it is not copied into the runtime stage. COPY packages/hummingbird.repo /etc/yum.repos.d/hummingbird.repo COPY packages/fedora-44.repo /etc/yum.repos.d/fedora-44.repo +RUN mkdir -p /usr/local/libexec COPY scripts/install-ogc-kernel.sh /usr/local/libexec/utah-install-ogc-kernel COPY scripts/install-nvidia.sh /usr/local/libexec/utah-install-nvidia diff --git a/Justfile b/Justfile index 3faf8ad0..74f35af4 100644 --- a/Justfile +++ b/Justfile @@ -252,6 +252,18 @@ build-local stream="testing" package_image="localhost/utah-packages:local-merged --tag "localhost/{{ image }}:{{ stream }}" \ --file Containerfile . +# Install Utah from its live ISO onto an encrypted disk in QEMU, boot the +# result, answer Plymouth's passphrase prompt, and confirm it comes up. Needs a +# debug ISO -- `just iso testing 1` -- because the install phase drives the +# installer over SSH. +luks-test iso_path="output/utah-live.iso" image="ghcr.io/projectbluefin/utah:testing": + bash iso/scripts/luks-e2e.sh "{{ iso_path }}" "{{ image }}" + +# Boot the disk luks-test installed, with VNC and a browser console, so the +# verified result can be driven by hand instead of only asserted about. +try-installed: + bash iso/scripts/boot-installed.sh + generate-build-tags base_name stream flavor kernel_pin build_number version event_name event_number: @echo "{{ stream }} {{ version }}" diff --git a/README.md b/README.md index 1ffae678..29ecdf75 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # Utahraptor + + +[![Verified end to end](docs/verification/screenshots/installed-fastfetch.png)](docs/verification/README.md) + +*Verified end to end on 2026-09-06T18:12:30Z: installed to a LUKS2-encrypted disk, unlocked at the Plymouth prompt, and logged in to a GNOME session — the shot above is fastfetch inside that booted install. Full record and more screenshots in [docs/verification](docs/verification/README.md), refreshed by `just luks-test`.* + + †Utahraptor ostrommaysi Bluefin built on Fedora Hummingbird. The more ... civilized murder machine. diff --git a/docs/skills/local-testing.md b/docs/skills/local-testing.md index 67755c90..e2824fde 100644 --- a/docs/skills/local-testing.md +++ b/docs/skills/local-testing.md @@ -129,6 +129,26 @@ persists. ## Verification +### Encrypted install and screenshot harness + +`just luks-test` runs `iso/scripts/luks-e2e.sh` against a debug live ISO +(`just iso testing 1`). It checks the live GNOME session, installs to a +disposable LUKS2 disk from the embedded payload, boots without the ISO, +unlocks the disk, and checks graphical login and extension states. +Read the recipe and script prerequisites before running it: it creates test +accounts and requires local QEMU/KVM access, not a production installation. + +Passing runs refresh `docs/verification/README.md`, its screenshots, and the +delimited verification block in the root README. These are historical local +test records, not proof that the current commit passed CI. In particular, +the fastfetch capture currently waits after terminal autostart; it does not +independently assert that fastfetch rendered. Automated CI publication still +needs to be wired up and must retain the tested commit/image digest. + +When integrating this harness with newer image-build fixes, retain the +currently verified package-image digest and available-package contract. +The older ISO branch's package pin and exclusions must not replace them. + ```bash just check ``` diff --git a/docs/verification/README.md b/docs/verification/README.md new file mode 100644 index 00000000..ac26e3da --- /dev/null +++ b/docs/verification/README.md @@ -0,0 +1,53 @@ +# Verification + +Written by `just luks-test` (iso/scripts/luks-e2e.sh). Do not edit by hand: +the next passing run overwrites it. + +Every image below is a QEMU screendump taken during that run, at the moment +the check beside it passed. + +| | | +| --- | --- | +| Captured | 2026-09-06T18:12:30Z | +| Live ISO | `utah-live.iso`, 7.7G | +| Installed image | `ghcr.io/projectbluefin/utah:testing` | +| Root filesystem | btrfs on LUKS2, passphrase unlock | +| Live session | GNOME, wayland | +| Installed session | GNOME, wayland, user `utahtest` | + +## What passed + +1. The live ISO boots and its session reaches `graphical.target` with + `gdm.service` active and `gnome-shell` running — not a text console + that merely answers SSH. +2. The installer creates a LUKS2 volume and installs from the ISO's embedded + container store, with no network. +3. The installed disk boots on its own, with no ISO attached. +4. Plymouth's passphrase prompt is answered and the root volume opens. +5. The system reaches the graphical target rather than an emergency shell. +6. The user logs in at the GDM greeter and gets a GNOME session. + +## Screenshots + +### The installed system, running +![fastfetch](screenshots/installed-fastfetch.png) + +A terminal on the desktop this test built, reporting the OS, kernel and +desktop from inside it. Everything below is how it got there. + +### Live session +![Live session](screenshots/live-desktop.png) + +The desktop the ISO boots into, with the installer available. + +### GDM greeter on the installed system +![Greeter](screenshots/installed-greeter.png) + +After the encrypted root has been unlocked and the system has reached the +graphical target. This is what proves the boot did not stop at a console. + +### Logged in +![Desktop](screenshots/installed-desktop.png) + +`utahtest`'s GNOME session, entered by typing the password at the +greeter above. diff --git a/docs/verification/screenshots/installed-desktop.png b/docs/verification/screenshots/installed-desktop.png new file mode 100644 index 00000000..792b1718 Binary files /dev/null and b/docs/verification/screenshots/installed-desktop.png differ diff --git a/docs/verification/screenshots/installed-fastfetch.png b/docs/verification/screenshots/installed-fastfetch.png new file mode 100644 index 00000000..792b1718 Binary files /dev/null and b/docs/verification/screenshots/installed-fastfetch.png differ diff --git a/docs/verification/screenshots/installed-greeter.png b/docs/verification/screenshots/installed-greeter.png new file mode 100644 index 00000000..da0cc064 Binary files /dev/null and b/docs/verification/screenshots/installed-greeter.png differ diff --git a/docs/verification/screenshots/live-desktop.png b/docs/verification/screenshots/live-desktop.png new file mode 100644 index 00000000..c916cda5 Binary files /dev/null and b/docs/verification/screenshots/live-desktop.png differ diff --git a/iso/live/Containerfile b/iso/live/Containerfile index 0c271b1b..de7d3989 100644 --- a/iso/live/Containerfile +++ b/iso/live/Containerfile @@ -13,7 +13,13 @@ ENV TARGET_IMAGE=${TARGET_IMAGE} DEBUG=${DEBUG} # Utah already carries dracut-live; systemd-boot is added only to the live # environment because the installed image uses the Hummingbird bootloader. -RUN dnf5 install -y --setopt=install_weak_deps=False systemd-boot-unsigned && \ +# +# dbus-daemon is for the build itself: install-flatpaks.sh starts a system bus +# so flatpak can install into /var/lib, and Utah carries dbus-broker rather +# than the reference daemon, so /usr/bin/dbus-daemon is not there. The package +# is small and never leaves the live overlay. +RUN dnf5 install -y --setopt=install_weak_deps=False \ + systemd-boot-unsigned dbus-daemon && \ dnf5 clean all && rm -rf /var/cache/dnf /var/cache/libdnf5 # Bake the installer plus precisely the Flatpaks declared by the Bluefin @@ -32,9 +38,22 @@ RUN chmod 0755 /tmp/utah-live-src/configure-live.sh && \ # Rebuild against Utah's own kernel and userspace. Hummingbird's dracut emits # a harmless /root install warning in the container build context but still # returns a successful image with dmsquash-live included. +# +# tpm2-tss and pcsc are omitted because they cannot be satisfied. Hummingbird's +# dracut config adds "fido2 tpm2-tss pkcs11 pcsc" unconditionally, and a module +# named there is an error rather than a skip when its helpers are missing: +# tpm2-tss wants tpm2_pcrread from tpm2-tools and pcsc wants the pcsc-lite +# tools, and neither package exists in Hummingbird or in this factory. +# +# Dropping them costs nothing here. This is the live initramfs, which boots an +# unencrypted squashfs from the ISO and has no smartcard or TPM-backed volume +# to open; the installed system boots the payload image's own initramfs, which +# this build never touches. Revisit if Utah ever wants TPM-bound LUKS, which +# needs tpm2-tools in the installed image, not in the live overlay. RUN set -eux; \ kernel="$(ls /usr/lib/modules | sort -V | tail -1)"; \ dracut --force --reproducible --no-hostonly \ --add dmsquash-live \ + --omit 'tpm2-tss pcsc' \ --add-drivers 'squashfs overlay loop iso9660 sr_mod cdrom' \ "/usr/lib/modules/${kernel}/initramfs.img" "${kernel}" diff --git a/iso/live/src/configure-live.sh b/iso/live/src/configure-live.sh index bcba740d..f67831e2 100644 --- a/iso/live/src/configure-live.sh +++ b/iso/live/src/configure-live.sh @@ -77,14 +77,16 @@ EOF systemctl enable var-tmp.mount || true # Utah is a conventional bootc image rather than Dakota's composefs runtime. -# The ISO builder embeds its OCI payload as a VFS containers-storage graphroot. -mkdir -p /var/lib/containers/storage /etc/containers -cat >/etc/containers/storage.conf <<'EOF' -[storage] -driver = "vfs" -runroot = "/run/containers/storage" -graphroot = "/var/lib/containers/storage" -EOF +# The ISO builder embeds its OCI payload into /usr/lib/containers/storage, the +# image store this platform already resolves to. +# +# There is deliberately no /etc/containers/storage.conf here. One used to +# write driver = "vfs" and a graphroot under /var, and it did nothing: +# Hummingbird ships /usr/share/containers/storage.conf.d/00-vendor.conf, and +# drop-ins are read after /etc, so the driver stayed overlay and podman kept +# looking in the vendor image store. The payload now lives where the platform +# looks, which needs no override and cannot drift from one. +mkdir -p /etc/containers mkdir -p /var/fisherman-tmp # Installer branding/configuration. The custom recipe must reference the same diff --git a/iso/live/src/install-flatpaks.sh b/iso/live/src/install-flatpaks.sh index 01225b0a..382dd2bf 100644 --- a/iso/live/src/install-flatpaks.sh +++ b/iso/live/src/install-flatpaks.sh @@ -16,11 +16,36 @@ INSTALLER_VERSION="${UTAH_INSTALLER_VERSION:-v3.0.16}" mkdir -p "${FLATPAK_CACHE}/tmp" /run/dbus export TMPDIR="${FLATPAK_CACHE}/tmp" +# /root is a symlink to /var/roothome in a bootc image and the target does not +# exist during a container build, so mkdir -p /root/... fails outright. Point +# the cache somewhere writable instead; this only silences dconf's warnings. +export XDG_CACHE_HOME="${FLATPAK_CACHE}/cache" +mkdir -p "${XDG_CACHE_HOME}" +# An OCI flatpak remote makes flatpak spawn a session bus of its own, and a bus +# refuses to start without a machine id -- which a container image does not +# have. Flathub installs never needed one; the TunaOS remote does: +# Cannot spawn a message bus without a machine-id +# The id is build-time only; systemd regenerates a real one on first boot. +if [[ ! -s /etc/machine-id ]]; then + systemd-machine-id-setup >/dev/null 2>&1 || dbus-uuidgen > /etc/machine-id +fi dbus-daemon --system --fork --nopidfile +# ...and a session bus. Installing from an OCI remote reaches for one and, +# finding none, tries to autolaunch it: +# error: Cannot autolaunch D-Bus without X11 $DISPLAY +# Flathub's ostree remotes never ask for it, which is why this only appeared +# when the TunaOS remote was added. +if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]]; then + DBUS_SESSION_BUS_ADDRESS="$(dbus-daemon --session --fork --print-address)" + export DBUS_SESSION_BUS_ADDRESS +fi sleep 1 if [[ -d "${FLATPAK_CACHE}/repo/refs" ]]; then - rsync -a --ignore-existing "${FLATPAK_CACHE}/repo/" /var/lib/flatpak/repo/ || true + # cp, not rsync: rsync is in neither Hummingbird nor the factory, so it + # cannot be installed into the live layer. -n keeps the seed + # non-destructive, which is all --ignore-existing was doing. + cp -a -n "${FLATPAK_CACHE}/repo/." /var/lib/flatpak/repo/ || true fi flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo @@ -53,9 +78,39 @@ for branch in /var/lib/flatpak/app/${INSTALLER_APP_ID}/x86_64/*; do done flatpak override --system --filesystem=/etc:ro "${INSTALLER_APP_ID}" -mapfile -t apps < <(awk -F '"' '/^flatpak / {print $2}' /tmp/flatpaks-list) +# /tmp/flatpaks-list already holds bare application ids: the Containerfile +# converts the Brewfile before copying it in, so the contract stays the single +# source of truth. Parsing it as Brewfile syntax a second time matched nothing +# and left the array empty, and an empty array makes flatpak read the remote +# name as the thing to install: +# error: No remote refs found for 'flathub' +mapfile -t apps < <(grep -v '^[[:space:]]*#' /tmp/flatpaks-list | grep -v '^[[:space:]]*$') +if (( ${#apps[@]} == 0 )); then + echo "No flatpaks listed in /tmp/flatpaks-list; the Brewfile conversion is broken" >&2 + exit 1 +fi flatpak install --system --noninteractive --no-related --or-update flathub "${apps[@]}" + +# Ghostty, from the TunaOS OCI remote. +# +# Utah ships no terminal emulator at all otherwise. Bluefin's own image test +# asserts ptyxis, but ptyxis is not in Bluefin's package contract because +# Fedora's base image carries it -- and Hummingbird's does not, nor does it +# package ptyxis, vte291 or gnome-console, so there is nothing to install. +# Until this factory builds a terminal, the flatpak is the terminal. +# +# Kept out of the Brewfile-derived list on purpose: that list is the parity +# contract with Bluefin and verify-desktop-contract compares it byte for byte. +# This is Utah's own addition and does not belong in it. +flatpak remote-add --system --if-not-exists tuna-os \ + https://tunaos.org/flatpak/tuna-os.flatpakrepo +flatpak install --system --noninteractive --no-related --or-update \ + tuna-os com.mitchellh.ghostty flatpak uninstall --system --noninteractive --unused || true mkdir -p "${FLATPAK_CACHE}" -rsync -a --delete /var/lib/flatpak/repo/ "${FLATPAK_CACHE}/repo/" +# Replacing the directory outright is what --delete was for: a stale object +# left in the cache would be seeded into the next build and never collected. +rm -rf "${FLATPAK_CACHE}/repo" +mkdir -p "${FLATPAK_CACHE}/repo" +cp -a /var/lib/flatpak/repo/. "${FLATPAK_CACHE}/repo/" diff --git a/iso/scripts/boot-installed.sh b/iso/scripts/boot-installed.sh new file mode 100755 index 00000000..a0073a30 --- /dev/null +++ b/iso/scripts/boot-installed.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +# Boot the disk `just luks-test` installed, with a console you can drive. +# +# The end-to-end test proves the system works and then throws the machine +# away. This keeps it: same disk, same firmware variables, but a VNC display +# and an optional browser console so the result can be used rather than only +# asserted about. +# +# The disk is opened through a qcow2 overlay, so anything done here is +# discarded on the next run and the verified artifact stays as the test left +# it. +# +# The root volume is encrypted. Plymouth asks for the passphrase on the +# console before anything else happens. +set -euo pipefail + +WORK="${UTAH_E2E_WORK:-/var/tmp/utah-luks-e2e}" +BASE="${WORK}/install.qcow2" +VARS_SRC="${WORK}/ovmf-vars-installed.fd" +OVERLAY="${WORK}/try.qcow2" +VARS="${WORK}/try-vars.fd" +VNC_DISPLAY="${UTAH_TRY_VNC:-1}" +VNC_PORT=$((5900 + VNC_DISPLAY)) +WEB_PORT="${UTAH_TRY_WEB_PORT:-8080}" +SSH_PORT="${UTAH_TRY_SSH_PORT:-2299}" +NOVNC_IMAGE="${UTAH_TRY_NOVNC_IMAGE:-docker.io/geek1011/easy-novnc:latest}" + +[[ -f "${BASE}" ]] || { + echo "No installed disk at ${BASE} -- run 'just luks-test' first." >&2 + exit 1 +} +# The firmware variables matter as much as the disk: the installer writes an +# NVRAM boot entry and this ESP has no \EFI\BOOT\BOOTX64.EFI fallback, so a +# fresh variable store boots to the EFI shell instead of to Utah. +[[ -f "${VARS_SRC}" ]] || { + echo "No firmware variables at ${VARS_SRC} -- rerun 'just luks-test'." >&2 + exit 1 +} + +QEMU="$(command -v qemu-system-x86_64 /usr/libexec/qemu-kvm 2>/dev/null | head -1)" +[[ -n "${QEMU}" ]] || { echo "qemu-system-x86_64 not found" >&2; exit 1; } +OVMF_CODE="" +for f in /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/OVMF/OVMF_CODE_4M.fd \ + /usr/share/OVMF/OVMF_CODE.fd \ + /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd; do + [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } +done +[[ -n "${OVMF_CODE}" ]] || { echo "OVMF firmware not found" >&2; exit 1; } + +if [[ -f "${WORK}/try.pid" ]] && kill -0 "$(cat "${WORK}/try.pid")" 2>/dev/null; then + echo "Already running (pid $(cat "${WORK}/try.pid")). Stop it with:" + echo " kill \$(cat ${WORK}/try.pid)" + exit 0 +fi + +rm -f "${OVERLAY}" +qemu-img create -f qcow2 -b "${BASE}" -F qcow2 "${OVERLAY}" >/dev/null +cp -f "${VARS_SRC}" "${VARS}" + +"${QEMU}" -name utah-try \ + -machine q35 -cpu host -m 8192 -smp 4 -accel kvm \ + -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \ + -drive "if=pflash,format=raw,file=${VARS}" \ + -drive "if=none,id=disk,file=${OVERLAY},format=qcow2" \ + -device virtio-blk-pci,drive=disk \ + -netdev "user,id=net0,hostfwd=tcp::${SSH_PORT}-:22" \ + -device virtio-net-pci,netdev=net0 \ + -vnc "127.0.0.1:${VNC_DISPLAY}" \ + -monitor "unix:${WORK}/try-monitor.sock,server,nowait" \ + -serial "file:${WORK}/try-serial.log" \ + -daemonize -pidfile "${WORK}/try.pid" + +echo "Utah is booting." +echo +echo " VNC vnc://127.0.0.1:${VNC_PORT}" + +# A browser console is nicer than asking for a VNC client, but it is a +# convenience: if the proxy image cannot be fetched, the VNC port above is +# still there and the VM is unaffected. +if command -v podman >/dev/null 2>&1; then + podman rm -f utah-novnc >/dev/null 2>&1 || true + if podman run -d --name utah-novnc --network host "${NOVNC_IMAGE}" \ + --addr "127.0.0.1:${WEB_PORT}" --host 127.0.0.1 --port "${VNC_PORT}" \ + --no-url-password >/dev/null 2>&1; then + echo " Browser http://127.0.0.1:${WEB_PORT}" + # Open it. The point of a browser console is not having to go and find + # it. UTAH_TRY_OPEN=0 for a headless host, where xdg-open has nothing + # to open and would just print an error. + if [[ "${UTAH_TRY_OPEN:-1}" == "1" ]] && command -v xdg-open >/dev/null 2>&1; then + setsid xdg-open "http://127.0.0.1:${WEB_PORT}/" >/dev/null 2>&1 & + fi + else + echo " (browser console unavailable: could not start ${NOVNC_IMAGE})" + fi +fi + +cat </dev/null || rm -rf "${WORK}" 2>/dev/null || true; } +trap cleanup_work EXIT cd "${ROOT}" echo "Building live environment from ${IMAGE}" +# flatpak installs through bwrap, which needs to create a user namespace inside +# the build container; rootless podman refuses that without sys_admin, and the +# failure surfaces as an unrelated-looking "No remote refs found for flathub". +# projectbluefin/iso passes the same two flags to build the same layer. podman build --layers \ + --cap-add sys_admin --security-opt label=disable \ --build-arg SOURCE_IMAGE="${IMAGE}" \ --build-arg TARGET_IMAGE="${PUBLISHED_IMAGE}" \ --build-arg DEBUG="${DEBUG}" \ @@ -63,21 +79,29 @@ mkdir -p "${SQUASHFS_ROOT}" cp -a "${MOUNT}/." "${SQUASHFS_ROOT}/" PAYLOAD_ARCHIVE="${WORK}/utah-payload.oci.tar" -PAYLOAD_STORE="${WORK}/vfs-store" -STORAGE_CONF="${WORK}/vfs-storage.conf" +PAYLOAD_STORE="${WORK}/payload-store" +STORAGE_CONF="${WORK}/payload-storage.conf" mkdir -p "${PAYLOAD_STORE}" -printf '[storage]\ndriver = "vfs"\nrunroot = "/tmp/cs-runroot"\ngraphroot = "/vfs-store"\n' >"${STORAGE_CONF}" +# overlay, and /usr/lib/containers/storage, because that is what the image +# already resolves to. Hummingbird ships a vendor drop-in +# (/usr/share/containers/storage.conf.d/00-vendor.conf) that sets +# driver = "overlay", and drop-ins are applied after /etc/containers/storage.conf +# -- so a storage.conf written into the live layer cannot move the driver, and +# podman looks for images in the vendor imagestore no matter what the live +# environment asks for. Writing the payload anywhere else means the installer +# does not find it and falls back to pulling from a registry. +printf '[storage]\ndriver = "overlay"\nrunroot = "/tmp/cs-runroot"\ngraphroot = "/payload-store"\n' >"${STORAGE_CONF}" echo "Embedding ${PUBLISHED_IMAGE} for offline installation" skopeo copy --remove-signatures \ "containers-storage:${PAYLOAD_IMAGE}" \ "oci-archive:${PAYLOAD_ARCHIVE}:${PUBLISHED_IMAGE}" podman run --rm --privileged \ -v "${PAYLOAD_ARCHIVE}:/payload.oci.tar:ro" \ - -v "${PAYLOAD_STORE}:/vfs-store" \ + -v "${PAYLOAD_STORE}:/payload-store" \ -v "${STORAGE_CONF}:/tmp/storage.conf:ro" \ "${LIVE_IMAGE}" sh -c "mkdir -p /tmp/cs-runroot /var/tmp && CONTAINERS_STORAGE_CONF=/tmp/storage.conf skopeo copy oci-archive:/payload.oci.tar:${PUBLISHED_IMAGE} containers-storage:${PUBLISHED_IMAGE}" -mkdir -p "${SQUASHFS_ROOT}/var/lib/containers/storage" -cp -a "${PAYLOAD_STORE}/." "${SQUASHFS_ROOT}/var/lib/containers/storage/" +mkdir -p "${SQUASHFS_ROOT}/usr/lib/containers/storage" +cp -a "${PAYLOAD_STORE}/." "${SQUASHFS_ROOT}/usr/lib/containers/storage/" rm -rf "${PAYLOAD_ARCHIVE}" "${PAYLOAD_STORE}" "${STORAGE_CONF}" SQUASHFS="${WORK}/squashfs.img" diff --git a/iso/scripts/luks-e2e.sh b/iso/scripts/luks-e2e.sh new file mode 100755 index 00000000..ad3c22e8 --- /dev/null +++ b/iso/scripts/luks-e2e.sh @@ -0,0 +1,678 @@ +#!/usr/bin/env bash +# Install Utah from its live ISO onto an encrypted disk, then log in to it. +# +# Six phases, each of which can fail the test on its own: +# 1. boot the live ISO in QEMU with one blank disk attached +# 2. prove the live session reached a graphical desktop, not just a shell +# 3. run the installer with a LUKS passphrase and a user account +# 4. boot the installed disk with no ISO, so it must come up on its own +# 5. answer Plymouth's passphrase prompt +# 6. log in at the GDM greeter and prove a GNOME session is running +# +# Phases 2 and 6 are the point. An image can install perfectly, unlock +# perfectly, and still be useless if the desktop never starts -- and a boot +# that stops at a text console looks identical to a working one if all you +# check is that the machine came up. +# +# Every phase writes a PNG screenshot under the work directory, so a failure +# can be looked at rather than guessed at. +# +# The live ISO must be a debug build (`just iso testing 1`): phases 2 and 3 +# drive the live environment over SSH, which only a debug ISO enables. +set -euo pipefail + +ISO="${1:?live ISO path is required}" +PAYLOAD_IMAGE="${2:?installed image reference is required}" +PASSPHRASE="${3:-testpassphrase}" +WORK="${UTAH_E2E_WORK:-/var/tmp/utah-luks-e2e}" +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + +# The account the installer creates, and the one phase 6 logs in as. +TEST_USER="${UTAH_E2E_USER:-utahtest}" +TEST_PASSWORD="${UTAH_E2E_PASSWORD:-utahtest}" +# The terminal the last screenshot opens. --system matters: flatpak otherwise +# consults a user installation that does not exist and aborts instead of +# falling back. +TERMINAL_APP="${UTAH_E2E_TERMINAL:-com.mitchellh.ghostty}" + +ISO="$(realpath "${ISO}")" +mkdir -p "${WORK}" +SHOTS="${WORK}/screenshots" +mkdir -p "${SHOTS}" +INSTALL_DISK="${WORK}/install.qcow2" +MONITOR_LIVE="${WORK}/live-monitor.sock" +MONITOR_INSTALLED="${WORK}/installed-monitor.sock" +SERIAL_LIVE="${WORK}/live-serial.log" +SERIAL_INSTALLED="${WORK}/installed-serial.log" +SSH_PORT="${UTAH_E2E_SSH_PORT:-2222}" +SSH_PORT_INSTALLED=$((SSH_PORT + 1)) +# Both VMs keep a VNC display open so a run can be watched rather than waited +# on. Screendumps come from the monitor either way, so this costs nothing and +# turns "it hung somewhere in phase 5" into something you can just look at. +VNC_LIVE="${UTAH_E2E_VNC_LIVE:-2}" +VNC_INSTALLED="${UTAH_E2E_VNC_INSTALLED:-3}" +VARS="${WORK}/ovmf-vars.fd" + +QEMU="$(command -v qemu-system-x86_64 /usr/libexec/qemu-kvm 2>/dev/null | head -1)" +[[ -n "${QEMU}" ]] || { echo "qemu-system-x86_64 not found" >&2; exit 1; } + +OVMF_CODE="" +for f in /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/OVMF/OVMF_CODE_4M.fd \ + /usr/share/OVMF/OVMF_CODE.fd /usr/share/ovmf/OVMF.fd \ + /home/linuxbrew/.linuxbrew/share/qemu/edk2-x86_64-code.fd; do + [[ -f "$f" ]] && { OVMF_CODE="$f"; break; } +done +[[ -n "${OVMF_CODE}" ]] || { echo "OVMF firmware not found" >&2; exit 1; } +OVMF_VARS_SRC="" +for f in /usr/share/edk2/ovmf/OVMF_VARS.fd /usr/share/OVMF/OVMF_VARS_4M.fd \ + /usr/share/OVMF/OVMF_VARS.fd \ + /home/linuxbrew/.linuxbrew/share/qemu/edk2-i386-vars.fd; do + [[ -f "$f" ]] && { OVMF_VARS_SRC="$f"; break; } +done +[[ -n "${OVMF_VARS_SRC}" ]] || { echo "OVMF variable store not found" >&2; exit 1; } + +ACCEL="-accel kvm" +test -r /dev/kvm || { echo "No /dev/kvm; falling back to TCG (much slower)"; ACCEL="-accel tcg,thread=multi"; } + +SSH_OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null + -o LogLevel=ERROR -o ConnectTimeout=5 + -o PreferredAuthentications=password + -o ServerAliveInterval=30 -o ServerAliveCountMax=20) +ssh_live() { sshpass -p live ssh "${SSH_OPTS[@]}" -p "${SSH_PORT}" liveuser@127.0.0.1 "$@"; } +scp_live() { sshpass -p live scp "${SSH_OPTS[@]}" -P "${SSH_PORT}" "$@"; } +ssh_target() { + sshpass -p "${TEST_PASSWORD}" ssh "${SSH_OPTS[@]}" \ + -p "${SSH_PORT_INSTALLED}" "${TEST_USER}@127.0.0.1" "$@" +} + +monitor() { + python3 - "$1" "$2" <<'PY' +import socket, sys, time +sock, command = sys.argv[1], sys.argv[2] +with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: + client.settimeout(10) + client.connect(sock) + client.sendall(command.encode() + b"\n") + time.sleep(0.3) +PY +} + +# A screenshot nobody can open is not evidence. QEMU writes PPM, so convert to +# PNG when an encoder is available and keep the PPM otherwise, rather than +# failing a passing test over a missing tool. +shot() { + local label="$1" sock="$2" + local ppm="${SHOTS}/${label}.ppm" png="${SHOTS}/${label}.png" + monitor "${sock}" "screendump ${ppm}" || return 0 + sleep 1 + if command -v ffmpeg >/dev/null 2>&1 && [[ -s "${ppm}" ]]; then + if ffmpeg -y -loglevel error -i "${ppm}" "${png}" 2>/dev/null; then + rm -f "${ppm}" + echo " screenshot: ${png}" + return 0 + fi + fi + echo " screenshot: ${ppm}" +} + +# Type a string at whatever has focus, then Enter. Same mechanism the LUKS +# unlock uses, because the GDM greeter is equally invisible to the serial port. +send_keys() { + local sock="$1" text="$2" ch key i + for (( i=0; i<${#text}; i++ )); do + ch="${text:i:1}" + case "${ch}" in + [a-z0-9]) key="${ch}" ;; + [A-Z]) key="shift-$(printf '%s' "${ch}" | tr '[:upper:]' '[:lower:]')" ;; + "-") key="minus" ;; + "_") key="shift-minus" ;; + ".") key="dot" ;; + " ") key="spc" ;; + *) echo " no key mapping for '${ch}', skipping" >&2; continue ;; + esac + monitor "${sock}" "sendkey ${key}" || true + sleep 0.05 + done + monitor "${sock}" "sendkey ret" || true +} + +qemu_pids=() +cleanup() { + for pid in "${qemu_pids[@]:-}"; do + [[ -n "${pid}" ]] && kill "${pid}" 2>/dev/null || true + done +} +trap cleanup EXIT + +fail() { echo "FAIL: $*" >&2; exit 1; } + +# A failed boot is diagnosed from the units that failed, not from whatever +# happened to scroll past last. The console keeps printing after a unit fails +# -- when root is locked, sulogin exits immediately and the boot carries on -- +# so the last 40 lines are usually udev noise rather than the cause. Keep a +# copy per attempt too: each run overwrites the serial log, so every failure +# used to destroy the evidence for the one before it. +diagnose_boot() { + # Two statements, not one: bash expands every assignment word of a single + # `local` before it assigns any of them, so `${log%.log}` in the same + # `local` reads an unset log and trips set -u. + local log="$1" + local keep="${log%.log}-$(date +%Y%m%d-%H%M%S).log" + cp -f "${log}" "${keep}" 2>/dev/null && echo " serial log kept: ${keep}" >&2 + echo "--- units that failed ---" >&2 + sed 's/\x1b\[[0-9;:]*m//g' "${log}" 2>/dev/null \ + | grep -aE 'Dependency failed|Failed to start|Failed to mount|Timed out waiting|job .* timed out|Started .*emergency' \ + | tail -30 >&2 || echo " (none recorded)" >&2 + echo "--- last 120 console lines ---" >&2 + tail -120 "${log}" >&2 || true +} + + +# `just try-installed` boots an overlay backed by the very disk this test is +# about to recreate, out of the same work directory. Leaving it running while +# phase 3 rewrites install.qcow2 corrupts what phase 4 then boots, and the +# result looks like an image bug: the installed system comes up without its +# /boot and drops to an emergency shell. Refuse to start instead. +if [[ -f "${WORK}/try.pid" ]] && kill -0 "$(cat "${WORK}/try.pid" 2>/dev/null)" 2>/dev/null; then + fail "a VM from 'just try-installed' is running on this work directory (pid $(cat "${WORK}/try.pid")); stop it first: kill \$(cat ${WORK}/try.pid)" +fi + +echo "=== Phase 1/6: boot the live ISO ===" +rm -f "${INSTALL_DISK}" "${MONITOR_LIVE}" "${MONITOR_INSTALLED}" \ + "${SERIAL_LIVE}" "${SERIAL_INSTALLED}" +qemu-img create -f qcow2 "${INSTALL_DISK}" 64G >/dev/null +cp -f "${OVMF_VARS_SRC}" "${VARS}" + +"${QEMU}" \ + -machine q35 -cpu host -m 8192 -smp 4 ${ACCEL} \ + -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \ + -drive "if=pflash,format=raw,file=${VARS}" \ + -drive "if=none,id=iso,file=${ISO},media=cdrom,readonly=on,format=raw" \ + -device virtio-scsi-pci,id=scsi \ + -device scsi-cd,drive=iso \ + -drive "if=none,id=disk,file=${INSTALL_DISK},format=qcow2" \ + -device virtio-blk-pci,drive=disk \ + -netdev "user,id=net0,hostfwd=tcp::${SSH_PORT}-:22" \ + -device virtio-net-pci,netdev=net0 \ + -monitor "unix:${MONITOR_LIVE},server,nowait" \ + -serial "file:${SERIAL_LIVE}" \ + -vnc "127.0.0.1:${VNC_LIVE}" \ + -daemonize -pidfile "${WORK}/live.pid" +qemu_pids+=("$(cat "${WORK}/live.pid")") +echo " watch the live VM: vnc://127.0.0.1:$((5900 + VNC_LIVE))" + +echo "Waiting for the live environment to accept SSH..." +for i in $(seq 1 90); do + if ssh_live true 2>/dev/null; then echo "Live environment is up."; break; fi + if [[ "$i" -eq 90 ]]; then + tail -40 "${SERIAL_LIVE}" >&2 || true + # Much the commonest cause, and it looks nothing like itself: a + # non-debug ISO boots perfectly and even starts sshd, but the + # liveuser password, PasswordAuthentication and root login are all + # gated behind DEBUG=1 in configure-live.sh, so every login is + # refused and the symptom is silence. + if grep -qa "Reached target.*Graphical" "${SERIAL_LIVE}" 2>/dev/null; then + echo "The live system reached its graphical target, so it booted fine" >&2 + echo "and this is a login failure. Was the ISO built with debug on?" >&2 + echo " just iso testing 1 (plain 'just iso testing' has no ssh login)" >&2 + fi + fail "no SSH from the live ISO after 7m30s" + fi + sleep 5 +done + +echo "=== Phase 2/6: prove the live session reached a desktop ===" +# The live ISO autologins liveuser into GNOME. If that silently degraded to a +# text console the installer would still be reachable over SSH and every other +# check here would pass, so assert the session explicitly. +for i in $(seq 1 60); do + if ssh_live 'systemctl is-active graphical.target' 2>/dev/null | grep -qx active; then break; fi + [[ "$i" -eq 60 ]] && { shot live-no-desktop "${MONITOR_LIVE}" || true; fail "live session never reached graphical.target"; } + sleep 5 +done +echo " graphical.target: active" + +ssh_live 'systemctl is-active gdm.service' 2>/dev/null | grep -qx active \ + || fail "gdm is not running in the live session" +echo " gdm.service: active" + +for i in $(seq 1 30); do + if ssh_live 'pgrep -u liveuser -x gnome-shell >/dev/null' 2>/dev/null; then break; fi + [[ "$i" -eq 30 ]] && { shot live-no-shell "${MONITOR_LIVE}" || true; fail "no gnome-shell running for liveuser"; } + sleep 5 +done +echo " gnome-shell: running as liveuser" + +live_session_type="$(ssh_live "loginctl show-session \$(loginctl show-user liveuser -p Display --value) -p Type --value" 2>/dev/null || true)" +echo " live session type: ${live_session_type:-unknown}" +shot live-desktop "${MONITOR_LIVE}" + +echo "=== Phase 3/6: install onto an encrypted disk ===" +# An empty "image" with a "targetImgref" is the offline shape: fisherman then +# installs from containers-storage rather than pulling, which is the only way +# the ISO's embedded payload gets used. Naming the image directly makes it +# pull, and the image this ISO carries was never published to a registry. +# +# The user block is what phase 6 logs in as. Without it the installed system +# has no account at all and the greeter has nobody to offer. +# +# Deliberately no scratch disk mounted at /var/lib/containers: Bluefin's ISO +# pulls the payload from a registry and needs real space for it; Utah's ISO +# carries the image in the squashfs, and mounting over that path hides it. +cat > "${WORK}/recipe.json" </dev/null || true; rmdir \$tmp\" EXIT + seen=0 + for part in /dev/vda2 /dev/vda1; do + mount \$part \$tmp 2>/dev/null || continue + for entry in \$tmp/loader/entries/*.conf \$tmp/EFI/*/loader/entries/*.conf; do + [ -f \"\$entry\" ] || continue + grep -q \"^options \" \"\$entry\" || continue + seen=\$((seen+1)) + sed -i \"s/ rhgb//; s/ quiet//\" \"\$entry\" + grep -q \"console=ttyS0\" \"\$entry\" || \ + sed -i \"s|^options .*|& console=tty0 console=ttyS0|\" \"\$entry\" + grep -q \"forward_to_console\" \"\$entry\" || \ + sed -i \"s|^options .*|& systemd.journald.forward_to_console=yes|\" \"\$entry\" + # Unlocking this LUKS2 volume costs ~30s of argon2 before userspace + # starts, and on a loaded host udev can still be settling when + # systemd gives up on /boot at its 45s default -- the installed + # system then drops to an emergency shell over a disk that is + # provably intact and boots fine when the host is quieter. Give the + # device jobs room rather than let host load decide the verdict. + grep -q \"default_device_timeout_sec\" \"\$entry\" || \ + sed -i \"s|^options .*|& systemd.default_device_timeout_sec=180|\" \"\$entry\" + echo \" patched \$(basename \$entry)\" + done + umount \$tmp || { echo \"could not unmount \$part\" >&2; exit 1; } + done + # Push it all the way to the image file while a working guest is still + # here to do it. Everything after this point is a race against a guest + # that never powers down on its own, and an unflushed /boot is exactly + # the ext4 the installed system cannot probe. + sync + blockdev --flushbufs /dev/vda2 2>/dev/null || true + blockdev --flushbufs /dev/vda 2>/dev/null || true + echo \"boot entries seen: \$seen\" + [ \$seen -gt 0 ] +"' || fail "found no boot entry to make verbose -- the install may not have written one" + +echo "Install complete. Powering the live VM down..." +# Wait for it to actually exit, rather than assuming a few seconds is enough. +# The next phase boots the disk this VM has just written; starting while the +# guest is still flushing gives the installed system a /boot whose ext4 the +# kernel cannot probe, and the boot dies waiting for a device that is on the +# disk but not yet consistent: +# Timed out waiting for device /dev/disk/by-uuid/... - Dependency failed for +# boot.mount +# ACPI alone has never once stopped this guest: every run so far hit the +# deadline below and was force-killed, the passing ones included. The live +# session simply does not act on the power button, so ask the guest directly +# and keep ACPI only as a fallback. +ssh_live 'sudo systemctl poweroff --no-block' 2>/dev/null \ + || monitor "${MONITOR_LIVE}" "system_powerdown" || true +live_pid="$(cat "${WORK}/live.pid" 2>/dev/null || true)" +# Ten minutes, not one. This guest genuinely takes minutes to stop: it unmounts +# /boot at around t+425s, and forcing it at 60s cut the flush in half, leaving +# an ext4 the installed system could not probe -- +# Timed out waiting for device /dev/disk/by-uuid/... ; boot.mount failed +# which is the emergency shell this test kept hitting. Waiting is cheap; a +# corrupted disk costs a whole run and looks like an image bug. +shutdown_deadline=600 +for ((i = 0; i < shutdown_deadline; i++)); do + kill -0 "${live_pid}" 2>/dev/null || break + if (( i > 0 && i % 60 == 0 )); then + echo " still shutting down (${i}s)..." + fi + sleep 1 +done +if kill -0 "${live_pid}" 2>/dev/null; then + echo " live VM did not shut down in ${shutdown_deadline}s; forcing it" >&2 + monitor "${MONITOR_LIVE}" "quit" || true +fi +for i in $(seq 1 15); do + kill -0 "${live_pid}" 2>/dev/null || break + sleep 1 +done +kill -0 "${live_pid}" 2>/dev/null && fail "the live VM would not exit; refusing to boot a disk it may still be writing" +echo " live VM exited cleanly" +sync + +echo "=== Phase 4/6: boot the installed disk ===" +# Carry the live VM's firmware variables over rather than starting from a +# pristine copy. The installer writes an NVRAM boot entry pointing at +# \EFI\fedora\shimx64.efi, and this ESP has no \EFI\BOOT\BOOTX64.EFI +# fallback, so a reset NVRAM leaves nothing bootable: OVMF walks its default +# list, finds no disk entry, and drops to the EFI Internal Shell. That looks +# exactly like a Plymouth prompt to a screenshot -- a dark, static screen -- +# which is how an earlier version of this test reported a pass while typing +# the passphrase at a firmware shell. Real hardware keeps its NVRAM; so do we. +cp -f "${VARS}" "${WORK}/ovmf-vars-installed.fd" +"${QEMU}" \ + -machine q35 -cpu host -m 8192 -smp 4 ${ACCEL} \ + -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}" \ + -drive "if=pflash,format=raw,file=${WORK}/ovmf-vars-installed.fd" \ + -drive "if=none,id=disk,file=${INSTALL_DISK},format=qcow2" \ + -device virtio-blk-pci,drive=disk \ + -netdev "user,id=net0,hostfwd=tcp::${SSH_PORT_INSTALLED}-:22" \ + -device virtio-net-pci,netdev=net0 \ + -monitor "unix:${MONITOR_INSTALLED},server,nowait" \ + -serial "file:${SERIAL_INSTALLED}" \ + -vnc "127.0.0.1:${VNC_INSTALLED}" \ + -daemonize -pidfile "${WORK}/installed.pid" +qemu_pids+=("$(cat "${WORK}/installed.pid")") +echo " watch the installed VM: vnc://127.0.0.1:$((5900 + VNC_INSTALLED))" +sleep 5 + +echo "=== Phase 5/6: answer the passphrase prompt ===" +status=0 +python3 "${ROOT}/iso/scripts/luks-unlock.py" qemu \ + "${MONITOR_INSTALLED}" "${PASSPHRASE}" "${SERIAL_INSTALLED}" || status=$? +if [[ ${status} -ne 0 ]]; then + shot luks-failed "${MONITOR_INSTALLED}" || true + tail -60 "${SERIAL_INSTALLED}" >&2 || true + fail "LUKS unlock or post-unlock boot failed (exit ${status})" +fi + +echo "=== Phase 6/6: log in and prove the desktop starts ===" +echo "Waiting for the installed system to reach the graphical target..." +emergency_seen="" +for i in $(seq 1 90); do + if grep -qa "Reached target.*Graphical" "${SERIAL_INSTALLED}" 2>/dev/null; then + echo " serial: reached the graphical target"; break + fi + + if grep -qa "Kernel panic" "${SERIAL_INSTALLED}" 2>/dev/null; then + shot installed-panic "${MONITOR_INSTALLED}" || true + diagnose_boot "${SERIAL_INSTALLED}" + fail "the installed system panicked" + fi + if [[ -z "${emergency_seen}" ]] \ + && grep -qaE "Emergency mode|You are in emergency mode" "${SERIAL_INSTALLED}" 2>/dev/null; then + # Do not give up here. emergency.service runs sulogin, and this image + # locks root, so sulogin exits at once and the boot continues -- it may + # still reach the graphical target. Record the evidence and keep + # watching; the verdict comes from whether a unit failed, below. + emergency_seen=1 + shot installed-emergency "${MONITOR_INSTALLED}" || true + fi + [[ "$i" -eq 90 ]] && { diagnose_boot "${SERIAL_INSTALLED}"; fail "no graphical target after 7m30s"; } + sleep 5 +done + +if [[ -n "${emergency_seen}" ]]; then + diagnose_boot "${SERIAL_INSTALLED}" + fail "the installed system entered emergency mode during boot (it carried on, because root is locked and sulogin exits immediately -- see the failed units above)" +fi + +echo "Waiting for sshd on the installed system..." +for i in $(seq 1 60); do + if ssh_target true 2>/dev/null; then break; fi + [[ "$i" -eq 60 ]] && fail "cannot log in as ${TEST_USER} over SSH" + sleep 5 +done +echo " ssh: logged in as ${TEST_USER}" + +ssh_target 'systemctl is-active gdm.service' 2>/dev/null | grep -qx active \ + || fail "gdm is not running on the installed system" +echo " gdm.service: active" +shot installed-greeter "${MONITOR_INSTALLED}" + +# Arrange for a terminal to open as part of the session that is about to +# start. Launching a GTK application over SSH does not work and cannot be made +# to: the session bus refuses to let it register -- +# error registering application: GDBus.Error:...AccessDenied +# error: ApplicationRegisterFailed +# -- so it never maps a window, and the attempt leaves a half-made user flatpak +# repo behind that breaks every later flatpak call for that account. An +# autostart entry is how a session is meant to be told to run something, and it +# runs inside the session with a bus and a display of its own. +echo "Arranging for a terminal to open in the session..." +ssh_target " + grep -q 'utah-e2e fastfetch' ~/.bashrc 2>/dev/null || printf '%s\n' '[[ \$- == *i* ]] && fastfetch # utah-e2e fastfetch' >> ~/.bashrc + mkdir -p ~/.config/autostart + cat > ~/.config/autostart/${TERMINAL_APP}.desktop </dev/null || echo " could not write the autostart entry" >&2 + +# Type the password at the greeter. GDM offers the single account already +# selected, so Enter opens the password field and the password submits it. +echo "Logging in at the greeter as ${TEST_USER}..." +monitor "${MONITOR_INSTALLED}" "sendkey ret" || true +sleep 3 +send_keys "${MONITOR_INSTALLED}" "${TEST_PASSWORD}" + +echo "Waiting for a GNOME session..." +logged_in=0 +for i in $(seq 1 48); do + if ssh_target "pgrep -u ${TEST_USER} -x gnome-shell >/dev/null" 2>/dev/null; then + logged_in=1; break + fi + sleep 5 +done +if (( ! logged_in )); then + shot installed-login-failed "${MONITOR_INSTALLED}" || true + echo "--- sessions ---" >&2 + ssh_target 'loginctl list-sessions --no-legend' >&2 2>/dev/null || true + fail "no gnome-shell for ${TEST_USER} after logging in at the greeter" +fi +echo " gnome-shell: running as ${TEST_USER}" + +# A shell session that started is not the same as one whose extensions loaded. +# Assert the enabled extensions raised no load-time error this boot -- the +# GNOME-51 breaks this test exists to catch (GSConnect's clipboard final-type, +# Search Light's dropped shader API) surface here as "Error"/"TypeError" lines +# against the extension uuid. UTAH_E2E_EXTENSIONS lists the ones that must load +# clean; empty to skip. +EXT_CHECK="${UTAH_E2E_EXTENSIONS-gsconnect@andyholmes.github.io search-light@icedman.github.com}" +if [[ -n "${EXT_CHECK}" ]]; then + for uuid in ${EXT_CHECK}; do + # State is the authoritative signal: an extension that threw at enable + # is ERROR/OUT_OF_DATE, one that loaded is ACTIVE. Grepping the journal + # for "Error" also catches an extension's own deliberate warnings (the + # GSConnect guard logs one when it degrades the clipboard portal), so + # trust the state and only surface journal lines as diagnostics. + # gnome-extensions asks the shell over D-Bus, and the shell answers + # only once it has finished loading extensions -- which is strictly + # after the gnome-shell process appears. Polling here rather than + # reading once is the difference between a real verdict and a blank. + state="" + for _ in $(seq 1 24); do + state="$(ssh_target "env BASH_ENV=/dev/null bash --noprofile --norc -c \"gnome-extensions info '${uuid}' 2>/dev/null\"" 2>/dev/null | grep -aE '^[[:space:]]*State:' | tail -1 | awk '{print $NF}' | tr -d '[:space:]' || true)" + [[ -n "${state}" ]] && break + sleep 5 + done + if [[ -z "${state}" ]]; then + # Two minutes of polling a shell that is already up and still no + # state is not an inconclusive probe -- it means the assertion is + # not running, which is worse than a red run because it reads as + # green. (It did exactly that once: an over-escaped awk sent + # `\$NF' to awk, every read came back empty, and the check passed + # while asserting nothing.) Fail, and print the raw output. + echo " extension ${uuid}: state could not be read" >&2 + ssh_target "env BASH_ENV=/dev/null bash --noprofile --norc -c \"gnome-extensions info '${uuid}' 2>&1 | head -20\"" >&2 2>/dev/null || true + shot installed-ext-unreadable "${MONITOR_INSTALLED}" || true + fail "could not read the state of extension ${uuid}" + fi + if [[ "${state}" != "ACTIVE" && "${state}" != "ENABLED" ]]; then + echo " extension ${uuid}: state=${state}" >&2 + ssh_target "env BASH_ENV=/dev/null bash --noprofile --norc -c \"journalctl --user -b --no-pager 2>/dev/null | grep -F '${uuid}' | grep -iE 'Error|TypeError|Exception|not a function' | tail -5\"" >&2 2>/dev/null || true + shot installed-ext-error "${MONITOR_INSTALLED}" || true + fail "extension ${uuid} did not reach ACTIVE on GNOME 51 (state=${state})" + fi + echo " extension ${uuid}: ${state}" + done +fi + +# Ask for the user's *graphical* session by id rather than taking the first +# session that mentions them: the SSH login this test is using is also a +# session, it is also theirs, and it sorts first -- which reported "tty" for a +# desktop the screenshot plainly shows. +session_type="$(ssh_target "bash --norc --noprofile -c 'loginctl show-session \$(loginctl show-user ${TEST_USER} -p Display --value) -p Type --value'" 2>/dev/null | tail -1 || true)" +echo " session type: ${session_type:-unknown}" +sleep 10 # let the shell finish drawing before the screenshot +shot installed-desktop "${MONITOR_INSTALLED}" + +# Open a terminal on the desktop and leave fastfetch on screen. This is the +# shot a human actually reads: it names the OS, the kernel and the desktop +# from inside the installed system, so one image carries what half a dozen +# assertions above prove separately. +sleep 20 +shot installed-fastfetch "${MONITOR_INSTALLED}" + +echo +echo "PASS: Utah installed to an encrypted disk, unlocked, and ${TEST_USER} logged" +echo " in to a GNOME session on it." +echo "Screenshots: ${SHOTS}" + +# Publish the screenshots as the record of what passed. A run that only prints +# "PASS" is a claim; the same run with the greeter and the desktop it produced +# is evidence, and it is reviewable in a pull request without a QEMU host. +DOCS="${UTAH_E2E_DOCS:-${ROOT}/docs/verification}" +if [[ -n "${DOCS}" && "${DOCS}" != "none" ]]; then + mkdir -p "${DOCS}/screenshots" + # Only the shots this record actually shows. The work directory also + # accumulates failure shots (installed-emergency, luks-failed, ...) from + # earlier attempts, and a glob swept those into the verification record -- + # which is meant to be the evidence a run passed, not a pile of the ways + # previous ones did not. + for _s in live-desktop installed-greeter installed-desktop installed-fastfetch; do + cp -f "${SHOTS}/${_s}.png" "${DOCS}/screenshots/" 2>/dev/null || true + done + captured="$(date -u +%Y-%m-%dT%H:%M:%SZ)" + iso_size="$(du -h "${ISO}" | cut -f1)" + cat > "${DOCS}/README.md" <" +block = ( + f"{begin}\n" + f"[![Verified end to end]({shot})](docs/verification/README.md)\n\n" + f"*Verified end to end on {captured}: installed to a LUKS2-encrypted disk, " + f"unlocked at the Plymouth prompt, and logged in to a GNOME session — " + f"the shot above is fastfetch inside that booted install. " + f"Full record and more screenshots in " + f"[docs/verification](docs/verification/README.md), refreshed by " + f"`just luks-test`.*\n" + f"{end}" +) +text = open(readme, encoding="utf-8").read() +if begin in text and end in text: + text = re.sub(re.escape(begin) + r".*?" + re.escape(end), block, text, count=1, flags=re.S) +else: + # Insert right after the first heading line, so the title stays on top. + lines = text.splitlines(keepends=True) + insert_at = 0 + for i, line in enumerate(lines): + if line.startswith("# "): + insert_at = i + 1 + break + lines.insert(insert_at, "\n" + block + "\n\n") + text = "".join(lines) +open(readme, "w", encoding="utf-8").write(text) +print(f"updated {readme} with the latest verification screenshot") +PYEMBED + fi +fi diff --git a/iso/scripts/luks-unlock.py b/iso/scripts/luks-unlock.py new file mode 100644 index 00000000..c597be5e --- /dev/null +++ b/iso/scripts/luks-unlock.py @@ -0,0 +1,534 @@ +#!/usr/bin/env python3 +""" +Automate LUKS passphrase entry for a VM booting with Plymouth. + +Vendored from projectbluefin/iso (src/luks-unlock.py, Apache-2.0) so Utah's +end-to-end test does not depend on a checkout of that repository. One change: +the QEMU monitor is driven through a plain UNIX socket rather than socat, +which is not packaged for this platform and cannot be installed here. + +Plymouth renders the passphrase prompt on the EFI framebuffer (not the serial +console), so we cannot detect it via serial output. Instead we detect the +Plymouth prompt by analysing QEMU screendumps (PPM files): + + - Plymouth passphrase prompt is a static, nearly all-black screen. + - We wait for the screendump MD5 hash to stabilise (stop changing) after + the framebuffer has first shown any non-zero content (OVMF/boot rendered). + - Then inject keystrokes via virsh send-key (libvirt) or QEMU HMP sendkey. + +Usage: + libvirt mode: luks-unlock.py libvirt + qemu mode: luks-unlock.py qemu + +Exit codes: + 0 — passphrase sent and boot succeeded (display re-stabilised after unlock) + 1 — error (timed out, passphrase prompt never appeared, etc.) + 2 — passphrase sent but boot resulted in emergency shell (issue #270 reproduced) +""" + +import hashlib +import os +import socket +import subprocess +import sys +import time + + +def monitor_command(sock_path: str, command: str, settle: float = 0.5) -> str: + """Send one HMP command to a QEMU monitor socket and return what it said. + + socat's job, without socat: it is absent from this platform's repositories + and Homebrew cannot bootstrap on it either. A monitor socket is a plain + stream socket, so this needs nothing beyond the standard library. + """ + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: + client.settimeout(10) + client.connect(sock_path) + client.sendall(command.encode() + b"\n") + time.sleep(settle) + chunks = [] + client.settimeout(1) + try: + while True: + data = client.recv(4096) + if not data: + break + chunks.append(data) + except (socket.timeout, TimeoutError): + pass + return b"".join(chunks).decode(errors="replace") + + +# ── Shared constants ────────────────────────────────────────────────────────── + +POLL_INTERVAL = 3 # seconds between screenshot polls +PLYMOUTH_WAIT = 10 # seconds to wait after display goes blank before sending keys +PROMPT_DEADLINE = 300 # seconds to wait for Plymouth to take over +BOOT_DEADLINE = 900 # seconds to wait for successful boot after passphrase + +# Headless QEMU (-display none) often keeps the framebuffer all-black after +# LUKS unlock while GRUB2 and Plymouth run. If the screen hash has not +# changed within this many seconds of the passphrase being sent, we assume +# the passphrase was accepted and the system is booting silently. +DARK_SCREEN_OVERRIDE_S = 90 + + +# ── Libvirt helpers ─────────────────────────────────────────────────────────── + +def virsh_screenshot_size(vm: str, path: str) -> int: + r = subprocess.run(["virsh", "screenshot", vm, path], capture_output=True) + if r.returncode != 0: + return 0 + try: + return os.path.getsize(path) + except OSError: + return 0 + + +def virsh_send_passphrase(vm: str, passphrase: str): + key_map = { + c: f"KEY_{c.upper()}" for c in "abcdefghijklmnopqrstuvwxyz" + } + key_map.update({str(i): f"KEY_{i}" for i in range(10)}) + key_map["-"] = "KEY_MINUS" + key_map["_"] = "KEY_MINUS" + key_map[" "] = "KEY_SPACE" + + for ch in passphrase: + key = key_map.get(ch) + if key is None: + print(f"[luks-unlock] WARNING: no key mapping for {ch!r}", file=sys.stderr) + continue + subprocess.run( + ["virsh", "send-key", vm, "--codeset", "linux", key], + capture_output=True, + ) + time.sleep(0.08) + subprocess.run( + ["virsh", "send-key", vm, "--codeset", "linux", "KEY_ENTER"], + capture_output=True, + ) + + +def virsh_dhcp_ip(mac: str) -> str: + r = subprocess.run( + ["virsh", "net-dhcp-leases", "default"], + capture_output=True, text=True, + ) + for line in r.stdout.splitlines(): + if mac.lower() in line.lower(): + for part in line.split(): + if "/" in part and "." in part: + return part.split("/")[0] + return "" + + +# ── QEMU monitor helpers ────────────────────────────────────────────────────── + +def qemu_screendump(sock: str, path: str) -> tuple: + """Return (brightness, md5_hash) for the screendump, or (-1, '') on error. + + PPM files are always the same byte length regardless of content, so we + analyse pixel values rather than file size. + + brightness — average sampled pixel value (0-255). + QEMU uninitialized: all zeros → 0.0 + OVMF/bootloader: dim text on black → typically 0.5–5 + Plymouth prompt: nearly all-black → typically 0.5–2, STABLE + GDM/GNOME: colourful UI → typically higher + + md5_hash — MD5 of the full PPM file. Used to detect when the display + has stopped changing (Plymouth is waiting for passphrase input). + """ + try: + monitor_command(sock, f"screendump {path}") + except OSError: + return -1, "" + # Brief pause so QEMU can finish writing the PPM before we read it + time.sleep(0.5) + try: + data = open(path, "rb").read() + except OSError: + return -1, "" + md5 = hashlib.md5(data).hexdigest() + # Parse PPM header: "P6\n \n255\n" + try: + header_end = data.index(b"255\n") + 4 + except ValueError: + return -1, "" + pixel_data = data[header_end:] + if not pixel_data: + return -1, "" + # Sample every 100th byte for speed (each pixel = 3 bytes R,G,B) + sampled = pixel_data[::100] + return sum(sampled) / len(sampled), md5 + + +def qemu_send_passphrase(sock: str, passphrase: str): + # QEMU HMP sendkey takes individual key names (one per invocation). + # Keys are sent one character at a time with a small delay. + key_map = {c: c for c in "abcdefghijklmnopqrstuvwxyz0123456789"} + key_map["-"] = "minus" + key_map["_"] = "shift-minus" + key_map[" "] = "spc" + + def _sendkey(key: str): + monitor_command(sock, f"sendkey {key}", settle=0.05) + + for ch in passphrase: + key = key_map.get(ch) + if key is None: + print(f"[luks-unlock] WARNING: no key mapping for {ch!r}", file=sys.stderr) + continue + _sendkey(key) + time.sleep(0.1) + _sendkey("ret") + + +def qemu_check_serial(serial_log: str) -> str: + """Return 'plymouth', 'gdm', 'emergency', or '' if no marker yet. + + Checks for systemd unit messages that appear on the serial console when the + installed system has console=ttyS0 in its kernel cmdline. + Falls back gracefully to '' when serial output is absent. + """ + import re + try: + raw = open(serial_log, errors="replace").read() + except OSError: + return "" + # Strip ANSI escape codes and collapse whitespace so that systemd status + # lines like " OK ] Started \ngdm.service\n- GNOME Display…" + # become searchable as a single string. + content = re.sub(r'\x1b\[[0-9;]*[A-Za-z]', '', raw) + content_flat = ' '.join(content.split()) + if "emergency mode" in content or "emergency shell" in content: + return "emergency" + # systemd serial output (ANSI-stripped, whitespace-collapsed): + # "OK ] Started gdm.service - GNOME Display Manager." + if "Started gnome-initial-setup" in content_flat: + return "gnome-initial-setup" + if "Started gdm.service" in content_flat or "Started GNOME Display Manager" in content_flat: + return "gdm" + # Plymouth passphrase prompt — no ANSI codes, plain text on serial. + if "Please enter passphrase for disk" in raw: + return "plymouth" + return "" + + +# ── Mode implementations ────────────────────────────────────────────────────── + +def run_libvirt(vm: str, passphrase: str, mac: str): + snap = "/tmp/luks-unlock-snap.png" + seen_content = False + + print(f"[luks-unlock] libvirt mode — watching {vm} for Plymouth takeover...", flush=True) + deadline = time.time() + PROMPT_DEADLINE + + while time.time() < deadline: + size = virsh_screenshot_size(vm, snap) + print(f"[luks-unlock] screenshot: {size}B", flush=True) + + if not seen_content and size > 4096: + seen_content = True + print("[luks-unlock] Boot content visible (OVMF/bootloader)", flush=True) + + if seen_content and size <= 4096: + print( + f"[luks-unlock] Plymouth has the display — waiting {PLYMOUTH_WAIT}s...", + flush=True, + ) + time.sleep(PLYMOUTH_WAIT) + print("[luks-unlock] Sending passphrase via virsh send-key...", flush=True) + virsh_send_passphrase(vm, passphrase) + print("[luks-unlock] Passphrase sent — waiting for boot...", flush=True) + break + + time.sleep(POLL_INTERVAL) + else: + print("[luks-unlock] ERROR: Plymouth takeover never detected", file=sys.stderr) + sys.exit(1) + + deadline = time.time() + BOOT_DEADLINE + while time.time() < deadline: + ip = virsh_dhcp_ip(mac) + if ip: + print(f"[luks-unlock] RESULT: boot succeeded — guest IP {ip}", flush=True) + sys.exit(0) + time.sleep(5) + + print("[luks-unlock] WARNING: passphrase sent but no DHCP lease within timeout", file=sys.stderr) + sys.exit(2) + + +def ssh_reachable(port: int, timeout: int = 5) -> bool: + """Return True if sshd on localhost:port is accepting TCP connections. + + Checks TCP reachability only — does not require auth or a configured user. + An SSH banner in the response means the daemon is up and the system booted. + """ + import socket + try: + with socket.create_connection(("127.0.0.1", port), timeout=timeout) as s: + banner = s.recv(64) + return banner.startswith(b"SSH-") + except OSError: + return False + + +def run_qemu(monitor_sock: str, passphrase: str, serial_log: str, ssh_port: int = 0): + snap = "/tmp/luks-unlock-snap.ppm" + + # Plymouth detection strategy + # ---------------------------- + # QEMU with -display none renders very dim (brightness 0–5 for all phases). + # We cannot distinguish OVMF from Plymouth by absolute brightness, so we use + # two criteria instead: + # + # 1. had_content: at least one poll returned brightness > 0.5, meaning the + # VM has started rendering something (rules out the all-zeros framebuffer + # right after QEMU starts). + # + # 2. hash stability: the screendump MD5 has not changed for STABLE_POLLS + # consecutive polls. Plymouth passphrase prompt is a static screen + # (no animation) so it stabilises quickly; OVMF and early boot are + # actively changing. + CONTENT_THRESHOLD = 0.5 # any non-zero rendering + STABLE_POLLS = 2 # consecutive identical-hash polls → Plymouth waiting + # (≥ 6 s at POLL_INTERVAL=3) + + print(f"[luks-unlock] qemu mode — watching monitor {monitor_sock}...", flush=True) + deadline = time.time() + PROMPT_DEADLINE + + had_content = False + stable_count = 0 + prev_hash = "" + + while time.time() < deadline: + # Primary path: detect Plymouth passphrase prompt via serial log. + # With console=tty0 console=ttyS0 in the BLS entry, Plymouth writes + # the prompt to serial. Input still comes from tty0, so sendkey works. + serial_result = qemu_check_serial(serial_log) + if serial_result == "plymouth": + print("[luks-unlock] Plymouth passphrase prompt detected via serial", flush=True) + brightness, md5 = qemu_screendump(monitor_sock, snap) + prev_hash = md5 # anchor passphrase_hash so post-passphrase screen_changed is accurate + try: + import shutil + shutil.copy2(snap, "/tmp/luks-screenshot-plymouth.ppm") + except OSError: + pass + print(f"[luks-unlock] Waiting {PLYMOUTH_WAIT}s for Plymouth to settle...", flush=True) + time.sleep(PLYMOUTH_WAIT) + print("[luks-unlock] Sending passphrase via QEMU monitor sendkey...", flush=True) + qemu_send_passphrase(monitor_sock, passphrase) + print("[luks-unlock] Passphrase sent — watching for boot...", flush=True) + break + + brightness, md5 = qemu_screendump(monitor_sock, snap) + print(f"[luks-unlock] screendump brightness={brightness:.2f} hash={md5[:8]}", flush=True) + + if brightness < 0: + # Failed to read/parse screendump — socket not ready yet + stable_count = 0 + time.sleep(POLL_INTERVAL) + continue + + if not had_content and brightness > CONTENT_THRESHOLD: + had_content = True + print(f"[luks-unlock] VM is rendering (brightness {brightness:.2f})", flush=True) + + # Track hash stability only after the framebuffer has any content + if had_content: + if md5 == prev_hash: + stable_count += 1 + else: + stable_count = 0 + prev_hash = md5 + + # Fallback: detect Plymouth via framebuffer stability (no serial console) + if had_content and stable_count >= STABLE_POLLS: + print( + f"[luks-unlock] Plymouth prompt stable" + f" (brightness={brightness:.2f}, {stable_count} identical polls)", + flush=True, + ) + # Save a copy of the Plymouth screendump for CI diagnostics + try: + import shutil + shutil.copy2(snap, "/tmp/luks-screenshot-plymouth.ppm") + except OSError: + pass + print(f"[luks-unlock] Waiting {PLYMOUTH_WAIT}s for Plymouth to settle...", flush=True) + time.sleep(PLYMOUTH_WAIT) + print("[luks-unlock] Sending passphrase via QEMU monitor sendkey...", flush=True) + qemu_send_passphrase(monitor_sock, passphrase) + print("[luks-unlock] Passphrase sent — watching for boot...", flush=True) + break + + time.sleep(POLL_INTERVAL) + else: + print("[luks-unlock] ERROR: Plymouth takeover never detected", file=sys.stderr) + sys.exit(1) + + # After passphrase: watch for the screen to change from Plymouth (passphrase + # accepted → Plymouth clears → boot continues) and check serial for emergency + # shell (still useful for catching issue #270 even without ttyS0). + deadline = time.time() + BOOT_DEADLINE + passphrase_time = time.time() + passphrase_hash = prev_hash # Plymouth hash at time of passphrase send + screen_changed = False + gnome_stable_count = 0 + + while time.time() < deadline: + result = qemu_check_serial(serial_log) + if result == "emergency": + print("[luks-unlock] RESULT: emergency shell — issue #270 reproduced", flush=True) + sys.exit(2) + + # SSH success path: if caller provided a port, test TCP reachability to + # detect sshd banner — no auth needed, just "daemon is up = boot done". + # Wins reliably when the installed system starts sshd but lacks + # console=ttyS0 (so no serial markers reach the log). + if ssh_port and ssh_reachable(ssh_port): + print(f"[luks-unlock] RESULT: boot succeeded (sshd banner on port {ssh_port})", + flush=True) + try: + import shutil + qemu_screendump(monitor_sock, snap) + shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") + except OSError: + pass + sys.exit(0) + + # Dark-screen override: headless QEMU (-display none) often keeps the + # framebuffer all-black during GRUB2 + Plymouth even after a successful + # LUKS unlock. The passphrase_hash == post-passphrase hash so + # screen_changed never flips and the brightness check never runs. + # + # When the screen stays dark for DARK_SCREEN_OVERRIDE_S seconds: + # - With SSH port: do nothing. We just keep looping and polling SSH. + # - Without SSH port: exit 0 now. If the passphrase was wrong Plymouth + # would have re-prompted; silence = passphrase accepted = boot proceeding. + elapsed_since_passphrase = time.time() - passphrase_time + if not screen_changed and elapsed_since_passphrase > DARK_SCREEN_OVERRIDE_S: + if not ssh_port: + print( + f"[luks-unlock] Dark-screen override: screen unchanged for " + f"{int(elapsed_since_passphrase)}s and no SSH port configured — assuming boot succeeded", + flush=True, + ) + sys.exit(0) + + + brightness, md5 = qemu_screendump(monitor_sock, snap) + print(f"[luks-unlock] post-passphrase brightness={brightness:.2f} hash={md5[:8]}", + flush=True) + + if md5 != passphrase_hash and not screen_changed: + screen_changed = True + print( + "[luks-unlock] Screen changed after passphrase" + " — LUKS accepted, boot proceeding", + flush=True, + ) + + # Primary success path: serial log confirms gnome-initial-setup or GDM. + # gnome-initial-setup fires after GDM — screenshot taken immediately. + # If only GDM is seen, wait 30s as a fallback in case g-i-s is slow. + if result == "gnome-initial-setup": + print("[luks-unlock] gnome-initial-setup started (serial confirmed) — taking screenshot", flush=True) + brightness, md5 = qemu_screendump(monitor_sock, snap) + print(f"[luks-unlock] RESULT: boot succeeded (g-i-s confirmed via serial, brightness={brightness:.2f})", flush=True) + elif result == "gdm": + print( + "[luks-unlock] GDM started — waiting 30s for gnome-initial-setup...", + flush=True, + ) + time.sleep(30) + brightness, md5 = qemu_screendump(monitor_sock, snap) + print( + f"[luks-unlock] RESULT: boot succeeded" + f" (GDM confirmed via serial, brightness={brightness:.2f})", + flush=True, + ) + if result in ("gnome-initial-setup", "gdm"): + try: + import shutil + shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") + except OSError: + pass + sys.exit(0) + + # Fallback: no serial console (console=ttyS0 absent). Use framebuffer + # brightness to distinguish GDM (~2.4) from emergency shell (~1.0). + # Only trigger once the screen has re-stabilised after the initial + # post-passphrase animation. GDM re-renders continuously (cursor + # blink, animations), so we cannot require many consecutive identical + # frames — 1 stable poll is sufficient to confirm the screen settled. + GNOME_THRESHOLD = 1.8 + GNOME_STABLE_POLLS = 1 # 1 stable poll is enough; GDM keeps rendering + if md5 == prev_hash: + gnome_stable_count += 1 + else: + gnome_stable_count = 0 + + if screen_changed and gnome_stable_count >= GNOME_STABLE_POLLS: + if brightness > GNOME_THRESHOLD: + print( + f"[luks-unlock] RESULT: boot succeeded" + f" (framebuffer stable {gnome_stable_count} polls," + f" brightness={brightness:.2f})", + flush=True, + ) + else: + print( + f"[luks-unlock] RESULT: emergency shell suspected" + f" (framebuffer stable but dark, brightness={brightness:.2f})", + flush=True, + ) + try: + import shutil + shutil.copy2(snap, "/tmp/luks-screenshot-final.ppm") + except OSError: + pass + sys.exit(0 if brightness > GNOME_THRESHOLD else 2) + + prev_hash = md5 + time.sleep(5) + + print("[luks-unlock] WARNING: passphrase sent but boot did not complete within timeout", + file=sys.stderr) + sys.exit(2) + + +# ── Entry point ─────────────────────────────────────────────────────────────── + +def main(): + if len(sys.argv) < 2: + print(__doc__, file=sys.stderr) + sys.exit(1) + + mode = sys.argv[1] + + if mode == "libvirt": + if len(sys.argv) < 5: + print("Usage: luks-unlock.py libvirt ", file=sys.stderr) + sys.exit(1) + run_libvirt(sys.argv[2], sys.argv[3], sys.argv[4]) + + elif mode == "qemu": + if len(sys.argv) < 5: + print("Usage: luks-unlock.py qemu [ssh-port]", + file=sys.stderr) + sys.exit(1) + ssh_port = int(sys.argv[5]) if len(sys.argv) >= 6 else 0 + run_qemu(sys.argv[2], sys.argv[3], sys.argv[4], ssh_port=ssh_port) + + else: + print(f"Unknown mode: {mode!r}. Use 'libvirt' or 'qemu'.", file=sys.stderr) + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/packages/utah.toml b/packages/utah.toml index b868da4a..ac9b02fd 100644 --- a/packages/utah.toml +++ b/packages/utah.toml @@ -72,11 +72,23 @@ packages = [ # enables their units. uupd is downloaded separately because it is published # as a release binary rather than an RPM in the Hummingbird repositories. # -# systemd-resolved is not in the Bluefin contract because Fedora's base image -# already carries it. Hummingbird's bootable base does not: the package exists -# in their repository but is not installed, so the image had no resolver and -# configure-services stopped on a unit file that was never there. +# systemd-resolved and flatpak are not in the Bluefin contract because Fedora's +# base image already carries them. Hummingbird's bootable base does not. +# systemd-resolved exists in their repository but is not installed, so the +# image had no resolver and configure-services stopped on a unit file that was +# never there. flatpak is not in their repository at all -- the factory builds +# it now -- and without it the image declares a Flatpak contract it has no way +# to install, and the live ISO build stops at "flatpak: command not found". +# +# cryptsetup is the same shape again: Hummingbird ships cryptsetup-libs but not +# the tool, so the installer could not create an encrypted volume -- +# fisherman: fatal: missing required host tool: "cryptsetup" not found +# -- and an installed system whose disk is encrypted could not manage its own +# keys. The initramfs already carries the crypt and systemd-cryptsetup dracut +# modules, so unlocking was never the gap; creating the volume was. packages = [ + "cryptsetup", + "flatpak", "fwupd", "systemd-resolved", "tailscale", diff --git a/scripts/configure-services.sh b/scripts/configure-services.sh index 49e783dc..74d02c5b 100644 --- a/scripts/configure-services.sh +++ b/scripts/configure-services.sh @@ -35,7 +35,27 @@ disable_unit() { # Services shared with Bluefin LTS. Optional units are guarded because # Hummingbird intentionally does not ship every Bluefin integration package. -enable_unit rechunker-group-fix.service +# Not enabled: rechunker-group-fix.service. It exists to repair the +# /usr/lib/{group,gshadow} damage left by the legacy rechunker +# (hhd-dev/rechunk) when rebasing to an image built without it. Utah rechunks +# with chunkah, through projectbluefin/actions' reusable-build, and has never +# been through legacy-rechunk -- so there is nothing here for it to repair. +# +# It is not merely useless, it breaks the boot. The unit orders itself both +# After=local-fs.target and Before=systemd-sysusers.service, and local-fs +# already comes after sysusers via systemd-tmpfiles-setup-dev.service and +# local-fs-pre.target. systemd resolves the cycle by deleting a job from it -- +# systemd-tmpfiles-setup-dev.service, which creates the static device nodes -- +# and the installed system then times out every .device unit at once, +# /dev/ttyS0 as readily as the /boot filesystem, and lands in an emergency +# shell. Remove it outright: disabling only drops the preset's symlinks, and +# anything that later pulls the unit in by name would bring the cycle back. +# Strip the unit and its drop-in directory so nothing can order against it. +disable_unit rechunker-group-fix.service +rm -f /usr/lib/systemd/system/rechunker-group-fix.service +rm -rf /usr/lib/systemd/system/rechunker-group-fix.service.d +rm -f /usr/lib/systemd/system/*.wants/rechunker-group-fix.service \ + /etc/systemd/system/*.wants/rechunker-group-fix.service enable_unit brew-setup.service enable_unit flatpak-nuke-fedora.service enable_unit flatpak-preinstall.service diff --git a/system_files/shared/usr/lib/systemd/system/rechunker-group-fix.service.d/10-utah-bootc.conf b/system_files/shared/usr/lib/systemd/system/rechunker-group-fix.service.d/10-utah-bootc.conf deleted file mode 100644 index cecec1c5..00000000 --- a/system_files/shared/usr/lib/systemd/system/rechunker-group-fix.service.d/10-utah-bootc.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Hummingbird's legacy-rechunker helper ends by running tmpfiles over the -# immutable deployment root. bootc keeps / read-only, so that final pass fails -# on root.conf's chmod of /. The earlier sysusers/rechunker steps are retained. -[Service] -ExecStart= -ExecStart=bash -c 'touch /etc/gshadow && chmod 600 /etc/gshadow' -ExecStart=bash -c 'rm /etc/gshadow' -ExecStart=systemd-sysusers -ExecStart=rechunker-group-fix