copy-firmware: fail gracefully if moreutils parallel is installed

The copy-firmware.sh script can use the "parallel" command to
parallelize some operations, but it needs the GNU version of
parallel.  There is another, simpler version of parallel that is part
of the moreutils package, but that version confuses the
has_gnu_parallel() function.  So first test to make sure that
the --version parameter is even recognized before trying to use it.

If in the future, moreutils parallel adds support for --version, this
script should still work because that version should never report
"GNU parallel".

Signed-off-by: Timur Tabi <ttabi@nvidia.com>
main
Timur Tabi 2025-03-17 14:01:02 -05:00
parent 142c0a7143
commit dd90046b70
1 changed files with 7 additions and 0 deletions

View File

@ -27,6 +27,13 @@ warn() {

has_gnu_parallel() {
if command -v parallel > /dev/null; then
# The moreutils package comes with a simpler version of "parallel"
# that does not support the --version or -a options. Check for
# that first. In some distros, installing the "parallel" package
# will replace the moreutils version with the GNU version.
if ! parallel --version > /dev/null 2>&1; then
return 1
fi
if parallel --version | grep -Fqi 'gnu parallel'; then
return 0
fi