From 2d0e25111c7efba9653626e2a35d4bb6d3a8ea37 Mon Sep 17 00:00:00 2001 From: Ugochukwu Mmaduekwe Date: Sun, 25 Oct 2026 08:51:06 +0100 Subject: [PATCH] Fix the PowerPC64 QEMU setup on Ubuntu 26.04 runners --- .github/workflows/ci/ppc64-be-images.env | 8 ++++---- .github/workflows/ci/ppc64-qemu-setup.sh | 25 +++++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci/ppc64-be-images.env b/.github/workflows/ci/ppc64-be-images.env index 18f2b32b..deb4db48 100644 --- a/.github/workflows/ci/ppc64-be-images.env +++ b/.github/workflows/ci/ppc64-be-images.env @@ -1,12 +1,12 @@ # Pinned image for the linux-powerpc64-be CI flow (sourced by ppc64-be-build.sh). # # QEMU (the ppc64 big-endian emulator) is NOT pinned here: it is installed from -# the Ubuntu runner's apt as qemu-user-static (currently QEMU ~8.2) by -# ppc64-qemu-setup.sh. Rationale: +# the Ubuntu runner's apt (qemu-user-static, or qemu-user + qemu-user-binfmt where +# that package is gone) by ppc64-qemu-setup.sh. Rationale: # - multiarch/qemu-user-static is abandoned (frozen at QEMU 7.2.0, Jan 2023). # - tonistiigi/binfmt ships only little-endian ppc64le, not big-endian ppc64. -# The distro package gives us a current big-endian qemu-ppc64 and auto-registers -# its binfmt handler with the F (fix-binary) flag. See ppc64-qemu-setup.sh. +# The distro packages give us a current big-endian qemu-ppc64 and register its +# binfmt handler with the F (fix-binary) flag. See ppc64-qemu-setup.sh. # # Runtime rootfs: Debian-ports ppc64 (big-endian) exists only in sid, so there is # no stable release to track. We currently track the rolling tag and let the diff --git a/.github/workflows/ci/ppc64-qemu-setup.sh b/.github/workflows/ci/ppc64-qemu-setup.sh index e4de5709..f0add636 100644 --- a/.github/workflows/ci/ppc64-qemu-setup.sh +++ b/.github/workflows/ci/ppc64-qemu-setup.sh @@ -5,28 +5,39 @@ set -euo pipefail # `docker run --platform linux/ppc64 ...` (ppc64-be-build.sh) transparently # executes big-endian binaries under QEMU user-mode. # -# We install QEMU from the Ubuntu runner's apt (qemu-user-static, currently -# ~8.2) rather than multiarch/qemu-user-static (abandoned at 7.2.0) or -# tonistiigi/binfmt (little-endian ppc64le only). The package's postinst -# registers each handler with the F (fix-binary) flag via update-binfmts, so -# the interpreter fd is preserved into the container and qemu does not need to +# We install QEMU from the Ubuntu runner's apt rather than +# multiarch/qemu-user-static (abandoned at 7.2.0) or tonistiigi/binfmt +# (little-endian ppc64le only). Older images ship qemu-user-static, which +# registers each handler with the F (fix-binary) flag via update-binfmts; newer +# ones replace it with qemu-user (static binaries) plus qemu-user-binfmt, which +# installs binfmt.d entries (also with F) for systemd-binfmt to load. With F +# the interpreter fd is preserved into the container, so qemu does not need to # exist inside the rootfs. See ppc64-be-images.env for the rationale. export DEBIAN_FRONTEND=noninteractive sudo apt-get update -qq -sudo apt-get install -y -qq qemu-user-static binfmt-support +if apt-cache policy qemu-user-static | grep -q 'Candidate: [^(]'; then + sudo apt-get install -y -qq qemu-user-static binfmt-support +else + sudo apt-get install -y -qq qemu-user qemu-user-binfmt binfmt-support +fi # Idempotent: enable the handler in case it was installed but left disabled. sudo update-binfmts --enable qemu-ppc64 2>/dev/null || true BINFMT_FILE=/proc/sys/fs/binfmt_misc/qemu-ppc64 +# qemu-user-binfmt only drops binfmt.d entries; load them if nothing registered yet. +if [ ! -e "$BINFMT_FILE" ]; then + sudo systemctl restart systemd-binfmt 2>/dev/null || true +fi if [ ! -e "$BINFMT_FILE" ]; then echo "::error::qemu-ppc64 binfmt handler not registered" ls /proc/sys/fs/binfmt_misc/ || true exit 1 fi -echo "qemu-ppc64-static: $(qemu-ppc64-static --version 2>/dev/null | head -1 || echo 'unknown')" +QEMU_PPC64="$(command -v qemu-ppc64-static || command -v qemu-ppc64 || true)" +echo "${QEMU_PPC64:-qemu-ppc64}: $("${QEMU_PPC64:-qemu-ppc64}" --version 2>/dev/null | head -1 || echo 'unknown')" echo "binfmt handler ${BINFMT_FILE}:" cat "$BINFMT_FILE"