commit:     9722fb1b99011c720459fa5f11e9b78929b060ac
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 15 00:03:43 2021 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Mon Mar 15 00:03:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=9722fb1b

Change --firmware-files handling

- Move from space-separated list to comma-separated list
  to add support for firmware files with spaces.

- Add support for firmware files with spaces.

- Check for specified firmware files in determine_real_args() which
  will allow us to error out early.

- Clarify documentation.

Fixes: c576f99b0b ("Misc improvements for FIRMWARE* handling")
Bug: https://bugs.gentoo.org/775221
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 doc/genkernel.8.txt  |  4 ++--
 gen_determineargs.sh | 12 ++++++++----
 gen_initramfs.sh     |  4 ++--
 genkernel.conf       |  4 ++--
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 44f3d59..aa18496 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -571,8 +571,8 @@ NOTE: System.map filename and System.map symlink name must 
be different.
     Specify directory to copy firmware from (defaults to '/lib/firmware').
 
 *--firmware-files*=<files>::
-    Specifies specific firmware files to copy. This overrides *--firmware-dir*.
-    For multiple files, separate the filenames with a comma.
+    Specifies specific firmware files or directories to copy, relative to
+    *--firmware-dir*. For multiple files, separate the filenames with a comma.
 
 *--*[*no-*]*firmware-install*::
     Enable or disables installation of firmware onto root filesystem.

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 265c557..3e6e4dd 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -1240,10 +1240,14 @@ determine_real_args() {
 
        if isTrue "${FIRMWARE}"
        then
-               for ff in ${FIRMWARE_FILES}; do
-                       [[ ${ff} = /* ]] && gen_die "FIRMWARE_FILES should list 
paths relative to FIRMWARE_DIR, not absolute."
+               IFS=',' read -r -a FIRMWARE_FILES <<< "${FIRMWARE_FILES}"
+               pushd "${FIRMWARE_DIR}" &>/dev/null || gen_die "Failed to chdir 
to '${FIRMWARE_DIR}'!"
+               local ff
+               for ff in "${FIRMWARE_FILES[@]}"
+               do
+                       [[ ${ff} = /* ]] && gen_die "--firmware-files contains 
value '${ff}' which is not a relative path from '${FIRMWARE_DIR}'!"
+                       [[ ! -e "${ff}" ]] && gen_die "--firmware-files 
contains value '${ff}' which was not found in '${FIRMWARE_DIR}'!"
                done
-
-               [[ "${FIRMWARE_FILES}" = *,* ]] && gen_die "FIRMWARE_FILES 
should be a space-separated list."
+               popd &>/dev/null || gen_die "Failed to chdir!"
        fi
 }

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 65a966d..9c030c5 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -1652,10 +1652,10 @@ append_firmware() {
 
        mkdir -p "${TDIR}"/lib/firmware || gen_die "Failed to create 
'${TDIR}/lib/firmware'!"
 
-       if [ -n "${FIRMWARE_FILES}" ]
+       if [ ${#FIRMWARE_FILES[@]} -gt 0 ]
        then
                pushd "${FIRMWARE_DIR}" &>/dev/null || gen_die "Failed to chdir 
to '${FIRMWARE_DIR}'!"
-               cp -rL --parents --target-directory="${TDIR}/lib/firmware" 
${FIRMWARE_FILES} 2>/dev/null \
+               cp -rL --parents --target-directory="${TDIR}/lib/firmware" 
"${FIRMWARE_FILES[@]}" 2>/dev/null \
                        || gen_die "Failed to copy firmware files 
(${FIRMWARE_FILES}) to '${TDIR}/lib/firmware'!"
                popd &>/dev/null || gen_die "Failed to chdir!"
        else

diff --git a/genkernel.conf b/genkernel.conf
index a8507d1..6c350a6 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -147,9 +147,9 @@ NOCOLOR="false"
 # Specify directory to pull from
 #FIRMWARE_DIR="/lib/firmware"
 
-# Specify a space-separated list of firmware files or directories to include,
+# Specify a comma-separated list of firmware files or directories to include,
 # relative to FIRMWARE_DIR.  If empty or unset, the full contents of 
-# FIRMWARE_DIR will be included.
+# FIRMWARE_DIR will be included (if FIRMWARE option above is set to YES).
 #FIRMWARE_FILES=""
 
 # Add new kernel to grub

Reply via email to