Merge branch 'copy-firmware' into 'main'

copy-firmware: various improvements

See merge request kernel-firmware/linux-firmware!487
main
Mario Limonciello 2025-03-18 00:45:21 +00:00
commit 588505068c
1 changed files with 25 additions and 0 deletions

View File

@ -11,8 +11,13 @@ compext=
destdir=
num_jobs=1

usage() {
echo "Usage: $0 [-v] [-jN] [--xz|--zstd] <destination directory>"
}

err() {
printf "ERROR: %s\n" "$*"
usage
exit 1
}

@ -22,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
@ -39,6 +51,7 @@ while test $# -gt 0; do

-j*)
num_jobs=$(echo "$1" | sed 's/-j//')
num_jobs=${num_jobs:-1}
if [ "$num_jobs" -gt 1 ] && ! has_gnu_parallel; then
err "the GNU parallel command is required to use -j"
fi
@ -66,6 +79,18 @@ while test $# -gt 0; do
shift
;;

-h|--help)
usage
exit 1
;;

-*)
# Ignore anything else that begins with - because that confuses
# the "test" command below
warn "ignoring option $1"
shift
;;

*)
if test -n "$destdir"; then
err "unknown command-line options: $*"