From 5dbc496313478446127a97378667cd55800f9470 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Fri, 20 Nov 2026 07:39:38 -0800 Subject: [PATCH] fix(lsphp): ext-build survives LiteSpeed's empty lsphpNN-dev maintainer scripts under BuildKit's QEMU arm64-attach run 5815 (cac-lsphp:php85) failed in the ext-build apt step: dpkg could not run the 0-byte postinst of lsphp85-dev ("Error while loading ...postinst: Exec format error", the QEMU emulator wrapper does not give dpkg the ENOEXEC/sh fallback). Retry once after giving empty maintainer scripts a shebang. Throwaway builder stage only; never taken on amd64. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6 --- Dockerfile.lsphp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Dockerfile.lsphp b/Dockerfile.lsphp index 9c71f29..a8dfc4b 100644 --- a/Dockerfile.lsphp +++ b/Dockerfile.lsphp @@ -108,11 +108,27 @@ ARG PKG_CACHE= COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/ COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh +## arm64 under BuildKit's QEMU emulator: LiteSpeed ships 0-byte postinst/prerm scripts in +## lsphpNN-dev. A native kernel (and QEMU via binfmt) answers ENOEXEC and dpkg's execvp falls back +## to /bin/sh, but the emulator wrapper execs the file itself and dies with "Error while loading +## ...postinst: Exec format error", so dpkg --configure fails. Only if the first install fails, +## give every empty maintainer script a shebang (no behaviour change: they were empty) and finish +## the configure, then re-run the same install so every check in it still runs. amd64 and QEMU +## setups that handle this never take the branch. RUN set -e; \ /usr/local/sbin/pkg-cache-repos.sh apt; \ - /usr/local/sbin/lsphp-apt-upgrade.sh --no-os-upgrade "${PHPVER}" \ - build-essential autoconf pkg-config \ - lsphp${PHPVER}-dev; \ + install_dev() { \ + /usr/local/sbin/lsphp-apt-upgrade.sh --no-os-upgrade "${PHPVER}" \ + build-essential autoconf pkg-config \ + lsphp${PHPVER}-dev; \ + }; \ + if ! install_dev; then \ + echo "install of lsphp${PHPVER}-dev failed: repairing empty maintainer scripts, then retrying once" >&2; \ + find /var/lib/dpkg/info -type f \( -name '*.preinst' -o -name '*.postinst' -o -name '*.prerm' -o -name '*.postrm' \) -size 0 \ + -exec sh -c 'printf "#!/bin/sh\nexit 0\n" > "$1"' _ {} \; ; \ + dpkg --configure -a; \ + install_dev; \ + fi; \ /usr/local/sbin/pkg-cache-repos.sh restore; \ RTV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}); \ DEVV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-dev); \