]> git.ipfire.org Git - thirdparty/linux-firmware.git/commitdiff
copy-firmware: fail gracefully if moreutils parallel is installed
authorTimur Tabi <ttabi@nvidia.com>
Mon, 17 Mar 2025 19:01:02 +0000 (14:01 -0500)
committerTimur Tabi <ttabi@nvidia.com>
Mon, 17 Mar 2025 22:45:37 +0000 (17:45 -0500)
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>
copy-firmware.sh

index cd5a689392334ff2dd95907b98bbf2e90c35c370..6a32127e77cc35f8c15b3adc7030fa671d555b80 100755 (executable)
@@ -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