Build: a grep -q behind pipefail inverts every positive check

The bundle verifier reported libarmsx3-core.so missing from a bundle that
plainly contained it, at base/lib/arm64-v8a/libarmsx3-core.so.

Under `set -o pipefail`, `unzip -l "$AAB" | grep -q x` fails whenever x IS
present: grep exits at the first match, closes the pipe, and unzip takes
SIGPIPE, so the pipeline reports failure. Every check for something that must
be there was inverted, and every check for something that must be absent passed
for the wrong reason -- grep found nothing, read to the end, and no signal was
raised.

Capturing the listing first and piping printf into grep instead only moved
which process took the signal. The listing is matched with `case` now, which
has no subprocess to kill.

Worth stating plainly: this was a verifier that would have reported a clean
bundle whatever went wrong, which is the failure mode the script exists to
prevent. It only surfaced because the one check that should have passed was the
one that failed.
This commit is contained in:
jpolo1224
2026-08-20 12:00:21 -04:00
parent d02079f7c8
commit 05e4547f67
+17 -2
View File
@@ -110,7 +110,22 @@ check_absent_manifest "RECORD_AUDIO" "would add Microphone to the li
check_absent_manifest "updateprovider" "the updater FileProvider must not ship"
# Native libraries are entries in the archive, so check the listing rather than the bytes.
if unzip -l "$AAB" | grep -q "libarmsx3_lsfg.so"; then
#
# Captured ONCE into a variable rather than piped into each grep. Under `set -o pipefail`,
# `unzip -l | grep -q x` fails whenever x IS found: grep exits at the first match, closes the
# pipe, unzip takes SIGPIPE, and the pipeline reports failure. That inverted every positive
# check -- it reported the core library missing from a bundle that plainly contained it, while
# the absence checks passed for the wrong reason, because grep read to the end and found
# nothing.
LISTING="$(unzip -l "$AAB")"
# Matched with `case`, not with a pipe into grep. Under `set -o pipefail` any `... | grep -q x`
# FAILS when x is found: grep exits at the first match, closes the pipe, and whatever is feeding
# it takes SIGPIPE. That inverted every positive check -- the core library was reported missing
# from a bundle that plainly contained it, while the absence checks passed for the wrong reason,
# because grep read to the end and found nothing. Piping printf instead of unzip moved the
# broken pipe rather than removing it; case has no subprocess to signal.
if [[ "$LISTING" == *libarmsx3_lsfg.so* ]]; then
echo "FAIL: libarmsx3_lsfg.so is in the bundle -- frame generation is not shipped through Play" >&2
fail=1
else
@@ -125,7 +140,7 @@ else
fail=1
fi
if unzip -l "$AAB" | grep -q "libarmsx3-core.so"; then
if [[ "$LISTING" == *libarmsx3-core.so* ]]; then
echo " ok: core library present"
else
echo "FAIL: libarmsx3-core.so missing from the bundle" >&2