diff --git a/.github/scripts/qemu/run-qemu-build.sh b/.github/scripts/qemu/run-qemu-build.sh index 0c536f5964..75f856a887 100755 --- a/.github/scripts/qemu/run-qemu-build.sh +++ b/.github/scripts/qemu/run-qemu-build.sh @@ -25,7 +25,8 @@ # MESON_ARGS, MESON_TEST_ARGS, FDO_CI_CONCURRENT (passed into the rootfs) # # Run as root (workflow uses `sudo`). The runner's own OS stays untouched: -# only qemu-user-static/binfmt-support/debootstrap get installed on it. +# only qemu-user-static (or qemu-user + qemu-user-binfmt), binfmt-support and +# debootstrap get installed on it. set -e set -x # Debug: print every command @@ -54,11 +55,23 @@ echo "=== [$(date)] Starting QEMU build for $ARCH ($QEMU, $SUITE, $MIRROR) ===" # --- host side: prepare the emulator + debootstrap ------------------------- echo "=== [$(date)] Installing host packages ===" apt-get update -apt-get install -y \ - qemu-user-static \ - binfmt-support \ - debootstrap \ - wget +# Ubuntu 26.04 dropped qemu-user-static: qemu-user now ships the static +# binaries (without the -static suffix) and qemu-user-binfmt registers them. +if ! apt-get install -y qemu-user-static binfmt-support debootstrap wget; then + apt-get install -y qemu-user qemu-user-binfmt binfmt-support debootstrap wget +fi + +QEMU_BIN=/usr/bin/$QEMU +[ -x "$QEMU_BIN" ] || QEMU_BIN=/usr/bin/${QEMU%-static} +# binfmt_misc runs the interpreter at its registered path inside the chroot +QEMU_BINFMT=/proc/sys/fs/binfmt_misc/$(basename "${QEMU%-static}") +[ -e "$QEMU_BINFMT" ] || systemctl restart systemd-binfmt || true +if [ ! -x "$QEMU_BIN" ] || [ ! -e "$QEMU_BINFMT" ]; then + echo "ERROR: no $QEMU_BIN or no binfmt_misc entry $QEMU_BINFMT" >&2 + exit 1 +fi +cat "$QEMU_BINFMT" +QEMU_INTERP=$(grep '^interpreter ' "$QEMU_BINFMT" | cut -d' ' -f2) # debian-ports (sparc64/alpha) needs the ports archive keyring. The one # shipped by the runner's distro (Ubuntu) is routinely out of date and misses @@ -100,7 +113,8 @@ debootstrap \ # --- register the emulator inside the rootfs and finish the bootstrap ------- echo "=== [$(date)] Copying qemu binary and running --second-stage ===" -cp "/usr/bin/$QEMU" "$ROOTFS/usr/bin/" +mkdir -p "$ROOTFS$(dirname "${QEMU_INTERP:-$QEMU_BIN}")" +cp "$QEMU_BIN" "$ROOTFS${QEMU_INTERP:-$QEMU_BIN}" chroot "$ROOTFS" /debootstrap/debootstrap --second-stage # Copy debian-ports keyring into chroot for apt verification. apt only trusts