igneum/tools/ci/signer-pipe-check.sh

16 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Fails when a script pipes a Rust binary's output into `head` (5 October 2026 night, C4 fix round: `igneum-ota-sign
# embedded | head -1` under `set -o pipefail`; the signer prints two lines, `head` closes the pipe after the first, and
# on a loaded Mac the second print lands after the close: SIGPIPE, "failed printing to stdout: Broken pipe", exit 101,
# and publish-jobs.sh died before the job was published). A Rust binary panics on a closed stdout; `sed -n 1p` reads to
# the end. The class: the signer (`$SIGNER` or `igneum-ota-sign`, the one binary here whose output is longer than the
# line a script wants) piped into head; `igneumd --version | head -1` prints one line and is left alone.
set -euo pipefail
cd "$(dirname "$0")/../.."
bad=$(grep -rnE '(\$SIGNER"?|igneum-ota-sign)[^|]*\| *head( |$)' packaging tools infra --include='*.sh' --include='*.mjs' 2>/dev/null | grep -v 'tools/ci/signer-pipe-check.sh' || true)
if [ -n "$bad" ]; then
echo "a Rust binary piped into head (SIGPIPE panics the binary; use sed -n 1p):" >&2
echo "$bad" >&2
exit 1
fi
echo "signer-pipe-check: ok"