build: use -o pipefail in license_extract.sh

The portable mkfifo approach works fine locally and worked fine in
initial GHA testing, but now it started to run into various stalling
issues on GHA. Presumably depending on whether the pipe is first written
to or read from and attempts to find a simple workaround for it failed.
Sometimes (but not always!) this is accompanied by an error like this:
  cannot open ./__LICENSE_EXTRACT_QUEUE.tmp: Interrupted system call

So convert the script to bash and just use set -o pipefail.

Cherry-picked from: 94cfe111f8
This commit is contained in:
Oneric 2022-12-04 23:19:09 +01:00 committed by Dmitry Lyzo
parent 0d3ffb7f5e
commit 780b0734be

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Copyright 2021 Oneric
# SPDX-License-Identifier: ISC
@ -40,17 +40,12 @@ else
exit 2
fi
FIFO="$base_dir"/__LICENSE_EXTRACT_QUEUE.tmp
mkfifo "$FIFO"
# We want to be able to clean up the named pipe on error
# and will check the exit codes ourselves
set +e
# Do not ignore licensecheck errors
set -o pipefail
find "$base_dir" $FINDOPTS -type f -regextype egrep -regex '.*\.(c|h|cpp|hpp|js)$' -print0 \
| xargs -0 -P1 licensecheck --machine --copyright --deb-fmt --encoding UTF-8 > "$FIFO"\
& scan_pid="$!"
awk -F"$tabulator" -v base_dir="$base_dir" \
| xargs -0 -P1 licensecheck --machine --copyright --deb-fmt --encoding UTF-8 \
| awk -F"$tabulator" -v base_dir="$base_dir" \
-v def_license="$def_license" -v def_copy="$def_copy" '
BEGIN {
split("", lcfiles) # Clear array with only pre-Issue 8 POSIX
@ -107,10 +102,4 @@ awk -F"$tabulator" -v base_dir="$base_dir" \
printf "\n"
}
}
' \
< "$FIFO"
fret="$?"
wait "$scan_pid"
sret="$?"
rm "$FIFO"
exit "$((fret | sret))"
'