diff options
author | Dmitry Baranov <reagentoo@gmail.com> | 2023-09-09 13:37:38 +0300 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-10-28 02:58:52 +0100 |
commit | 5bd81ee6cbbe582c60f0f9971dbb0b60b061b6a4 (patch) | |
tree | 260a3e79588c3bdc96a508042bfc61acb171619b | |
parent | gen_moddeps.sh: don't use echo/printf inside the cycle (diff) | |
download | genkernel-5bd81ee6cbbe582c60f0f9971dbb0b60b061b6a4.tar.gz genkernel-5bd81ee6cbbe582c60f0f9971dbb0b60b061b6a4.tar.bz2 genkernel-5bd81ee6cbbe582c60f0f9971dbb0b60b061b6a4.zip |
gen_moddeps.sh: introduce xbasename()
Introduce xbasename() wrapper to use it instead of xargs basename.
It guards from two cases:
- zero count of module names is passing from pipe
- module name starting with "-" interprets as option
Signed-off-by: Dmitry Baranov <reagentoo@gmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
-rwxr-xr-x | gen_moddeps.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gen_moddeps.sh b/gen_moddeps.sh index 69157460..556751da 100755 --- a/gen_moddeps.sh +++ b/gen_moddeps.sh @@ -10,6 +10,17 @@ mod_dep_list() { cat "${TEMP}/moddeps" } +xbasename() { + local -a moddeplist=( $( </dev/stdin ) ) + + if (( ${#moddeplist[@]} > 0 )) + then + # prepend slash to each moddeplist element + # to avoid passing elements as basename options + basename -s "${KEXT}" "${moddeplist[@]/#/\/}" + fi +} + gen_dep_list() { local moddir="${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}" @@ -60,5 +71,5 @@ gen_dep_list() { ) printf '%s\n' "${moddeplist[@]}" - fi | xargs basename -s "${KEXT}" | sort | uniq + fi | xbasename | sort | uniq } |