From bd233d7b27a33036a84d9e4b97082c0a4b2fdc4f Mon Sep 17 00:00:00 2001 From: Kemal Yaylali Date: Sun, 16 Aug 2026 18:37:51 +0100 Subject: [PATCH] Fix image build: register static qemu with the F flag Second failure was debootstrap dying with 'E: Unable to execute target architecture'. qemu-user-binfmt registers a dynamically linked emulator, which cannot run once debootstrap chroots into a rootfs that has no loader for it. The fix is the static binary registered with the F flag, which preloads the interpreter so it survives the chroot. Registration runs after apt, because installing binfmt-support re-registers the dynamic handlers over the top, and the workflow now asserts the F flag is present rather than discovering its absence an hour into a build. --- .github/workflows/image.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 2e9d027..6e1fa78 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -51,10 +51,30 @@ jobs: quilt parted coreutils qemu-user-binfmt debootstrap zerofree zip \ dosfstools e2fsprogs libcap2-bin libarchive-tools grep rsync \ xz-utils curl xxd file git kmod bc gpg pigz arch-test - # Prove the handler is actually registered before spending an hour. - test -f /proc/sys/fs/binfmt_misc/qemu-aarch64 \ - || sudo systemctl restart systemd-binfmt || true - ls /proc/sys/fs/binfmt_misc/ | head + # qemu-user-static too: qemu-user-binfmt registers a dynamically linked + # emulator, which cannot run once debootstrap chroots into a rootfs + # that has no loader for it. That fails as "E: Unable to execute + # target architecture" several steps later. + sudo apt-get install -y --no-install-recommends qemu-user-static binfmt-support + + # Registers the static handlers with the F flag, which preloads the + # emulator so it survives the chroot. Run after apt, because installing + # binfmt-support re-registers the dynamic handlers over the top. + - name: Register qemu binfmt handlers + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + + - name: Verify the aarch64 handler is usable in a chroot + run: | + F=/proc/sys/fs/binfmt_misc/qemu-aarch64 + test -f "$F" || { echo "no aarch64 binfmt handler registered"; exit 1; } + cat "$F" + # The F flag is the whole point: without it the interpreter is resolved + # inside the chroot, where it does not exist. + grep -q 'flags:.*F' "$F" || { echo "handler lacks the F flag; chroot will fail"; exit 1; } + echo "aarch64 handler OK" + # Pinned to a commit, not a branch. An image other people flash should not # change because an upstream branch moved between builds.