fix(lsphp): per-package pins so an inconsistent LiteSpeed 8.4 set still builds [skip ci]
Stage 2 pinned lsphp84, -common and -ldap to one version; LiteSpeed's repo offers lsphp84 8.4.27-2 but lsphp84-common only 8.4.27-3 (run 5691 job 18704: E: Version '8.4.27-2+noble' for 'lsphp84-common' was not found). New scripts/lsphp-pin-resolve.sh resolves -common/-ldap to the exact version when offered (unchanged for 82/83/85), else a same-PHP-version, same-distro, >= revision; never a different PHP release. lsphp84 itself stays exact and the post-install check requires same upstream + >=. Fixture test added to CI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
d792a6549b
commit
40f62c2b64
4 files changed
+132
-2
No files matched your search
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
## lsphp-pin-resolve.sh — BUILD-TIME ONLY. Run (Dockerfile RUN is dash, so this is
|
||||
## a bash executable) or source it:
|
||||
## lsphp-pin-resolve.sh resolve PKG WANT # prints the version to pin PKG at
|
||||
## lsphp-pin-resolve.sh ok INSTALLED WANT # exit 0 if INSTALLED is an acceptable pin
|
||||
##
|
||||
## Why: stage 2 of Dockerfile.lsphp pins lsphpNN, lsphpNN-common and
|
||||
## lsphpNN-ldap to the ONE version ext-build compiled against. LiteSpeed's repo
|
||||
## is occasionally published inconsistently (2026-11-19: lsphp84 8.4.27-2+noble
|
||||
## but lsphp84-common 8.4.27-3+noble only), so a single shared pin makes apt say
|
||||
## "Version '8.4.27-2+noble' for 'lsphp84-common' was not found".
|
||||
##
|
||||
## Rule (fail closed, nothing weakened):
|
||||
## 1. WANT itself is offered for PKG -> WANT (the normal case; 82/83/85).
|
||||
## 2. else the highest version that has the SAME upstream PHP version (the
|
||||
## text before the first '-') and the same distro suffix (after '+') as
|
||||
## WANT and is >= WANT (a packaging-revision bump; every lsphp package
|
||||
## Depends on -common only as ">= WANT", so >= is always satisfiable).
|
||||
## 3. else exit 1 — a different PHP release is never silently substituted.
|
||||
## The caller still asserts lsphpNN (the binary the extension was built for)
|
||||
## equals WANT exactly and -common has the same upstream version and is >= WANT.
|
||||
##
|
||||
## LSPHP_MADISON_CMD (default "apt-cache madison") is overridable for tests.
|
||||
|
||||
lsphp_resolve_pin() {
|
||||
local pkg="$1" want="$2" cmd="${LSPHP_MADISON_CMD:-apt-cache madison}"
|
||||
local out v best="" up="${want%%-*}" suf=""
|
||||
[[ "$want" == *+* ]] && suf="+${want#*+}"
|
||||
out=$($cmd "$pkg") || { echo "lsphp-pin-resolve: '$cmd $pkg' failed" >&2; return 1; }
|
||||
while read -r v; do
|
||||
[ -n "$v" ] || continue
|
||||
if [ "$v" = "$want" ]; then printf '%s\n' "$want"; return 0; fi
|
||||
[ "${v%%-*}" = "$up" ] || continue
|
||||
[ "$suf" = "" ] || [[ "$v" == *"$suf" ]] || continue
|
||||
dpkg --compare-versions "$v" ge "$want" || continue
|
||||
if [ -z "$best" ] || dpkg --compare-versions "$v" gt "$best"; then best="$v"; fi
|
||||
done < <(awk -F'|' '{gsub(/ /,"",$2); print $2}' <<<"$out")
|
||||
if [ -z "$best" ]; then
|
||||
echo "lsphp-pin-resolve: $pkg offers no version of PHP $up compatible with $want" >&2
|
||||
return 1
|
||||
fi
|
||||
printf '%s\n' "$best"
|
||||
}
|
||||
|
||||
## lsphp_pin_ok INSTALLED WANT — post-install assertion for the -common/-ldap
|
||||
## packages: same upstream PHP version as WANT and not older than it.
|
||||
lsphp_pin_ok() {
|
||||
local inst="$1" want="$2"
|
||||
[ "${inst%%-*}" = "${want%%-*}" ] && dpkg --compare-versions "$inst" ge "$want"
|
||||
}
|
||||
|
||||
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||||
set -u
|
||||
case "${1:-}" in
|
||||
resolve) lsphp_resolve_pin "${2:?pkg}" "${3:?want}" ;;
|
||||
ok) lsphp_pin_ok "${2:?installed}" "${3:?want}" ;;
|
||||
*) echo "usage: $0 resolve PKG WANT | ok INSTALLED WANT" >&2; exit 2 ;;
|
||||
esac
|
||||
fi
|
||||
Reference in new issue
Block a user