diff --git a/scripts/lsphp-apt-upgrade.sh b/scripts/lsphp-apt-upgrade.sh index 377cd73..6f59090 100755 --- a/scripts/lsphp-apt-upgrade.sh +++ b/scripts/lsphp-apt-upgrade.sh @@ -49,11 +49,16 @@ echo "lsphp-apt-upgrade: base image lsphp${PHPVER}=$(dpkg-query -W -f='${Version # The candidate for lsphpNN must come from the LiteSpeed repo — not "none", and # not merely whatever is already installed. -if ! apt-cache madison "lsphp${PHPVER}" | grep -q 'rpms.litespeedtech.com'; then +# Read each output into a variable and match in the shell: piping into an +# early-exit reader (grep -q, awk ... exit) under pipefail can SIGPIPE the writer +# and report "missing" for a package that is there (scripts/tests/lsphp-info-probe.test.sh). +MADISON=$(apt-cache madison "lsphp${PHPVER}") +if [[ "$MADISON" != *rpms.litespeedtech.com* ]]; then apt-cache policy "lsphp${PHPVER}" >&2 || true die "the LiteSpeed apt repo does not offer lsphp${PHPVER} (repo missing from sources, or its index is empty)." fi -CAND=$(apt-cache policy "lsphp${PHPVER}" | awk '/Candidate:/ {print $2; exit}') +POLICY=$(apt-cache policy "lsphp${PHPVER}") +CAND=$(awk '/Candidate:/ {print $2; exit}' <<<"$POLICY") echo "lsphp-apt-upgrade: repo candidate lsphp${PHPVER}=${CAND}" if [ "$OS_UPGRADE" = 1 ]; then