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); \