aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baranov <reagentoo@gmail.com>2022-06-01 20:21:18 +0300
committerSam James <sam@gentoo.org>2023-08-30 07:18:18 +0100
commit08b4f191c9fb064f8564d888e3969a02b0384a32 (patch)
treeb267a76b8c6a1f8d2f0eaa622670297c2cc0d0ae /gen_moddeps.sh
parentChanged firmware and modules requirements to warnings. (diff)
downloadgenkernel-08b4f191c9fb064f8564d888e3969a02b0384a32.tar.gz
genkernel-08b4f191c9fb064f8564d888e3969a02b0384a32.tar.bz2
genkernel-08b4f191c9fb064f8564d888e3969a02b0384a32.zip
firmware: copy only the necessary firmware(s) into initramfs
FIRMWARE=yes behavior is changed: Only the minimum number of firmware files will be copied. The list is generated using the `modinfo -F firmware [modules]...` command. The ability to copy all firmware(s) is also available with a new ALLFIRMWARE setting (see the modified genkernel.conf for more details). As for changes in the source code: gen_moddeps.sh: Significantly redesigned module list generation. To get a list of modules, use the `mod_dep_list()` function instead of `gen_dep_list()`. Modules that are not in the kernel (=n or invalid) will be filtered out. Aliases will be replaced with real names (including dependencies). Signed-off-by: Dmitry Baranov <reagentoo@gmail.com> Closes: https://github.com/gentoo/genkernel/pull/40 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'gen_moddeps.sh')
-rwxr-xr-xgen_moddeps.sh98
1 files changed, 46 insertions, 52 deletions
diff --git a/gen_moddeps.sh b/gen_moddeps.sh
index 89a562b..f175b72 100755
--- a/gen_moddeps.sh
+++ b/gen_moddeps.sh
@@ -1,69 +1,63 @@
#!/bin/bash
# $Id$
+mod_dep_list() {
+ if [ ! -f "${TEMP}/moddeps" ]
+ then
+ gen_dep_list > "${TEMP}/moddeps"
+ fi
+
+ cat "${TEMP}/moddeps"
+}
+
gen_dep_list() {
+ local moddir="${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}"
+
if isTrue "${ALLRAMDISKMODULES}"
then
- strip_mod_paths $(find "${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}" -name "*${KEXT}") | sort
+ cat "${moddir}/modules.builtin"
+ cat "${moddir}/modules.order"
else
- rm -f "${TEMP}/moddeps" >/dev/null
+ local -a modlist=()
- local group_modules
- for group_modules in ${!MODULES_*} GK_INITRAMFS_ADDITIONAL_KMODULES
+ local mygroups
+ for mygroups in ${!MODULES_*} GK_INITRAMFS_ADDITIONAL_KMODULES
do
- gen_deps ${!group_modules}
+ modlist+=( ${!mygroups} )
done
- # Only list each module once
- if [ -f "${TEMP}/moddeps" ]
- then
- cat "${TEMP}/moddeps" | sort | uniq
- fi
- fi
-}
+ modlist=( $(printf '%s\n' "${modlist[@]}" | sort | uniq) )
-gen_deps() {
- local modlist
- local deps
+ modlist+=( $(
+ local -a rxargs=( "${modlist[@]}" )
- local x
- for x in ${*}
- do
- echo ${x} >> "${TEMP}/moddeps"
- modlist=$(modules_dep_list ${x})
- if [ "${modlist}" != "" -a "${modlist}" != " " ]
- then
- deps=$(strip_mod_paths ${modlist})
- else
- deps=""
- fi
+ rxargs=( "${rxargs[@]/#/-ealias\ }" )
+ rxargs=( "${rxargs[@]/%/\ }" )
- local y
- for y in ${deps}
- do
- echo ${y} >> "${TEMP}/moddeps"
- done
- done
-}
-
-modules_dep_list() {
- if [ -f "${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}/modules.dep" ]
- then
- grep -F -- "/${1}${KEXT}:" "${KERNEL_MODULES_PREFIX%/}/lib/modules/${KV}/modules.dep" | cut -d\: -f2
- fi
-}
+ cat "${moddir}/modules.alias" \
+ | grep -F "${rxargs[@]}" \
+ | cut -d' ' -f3-
+ ) )
-# Pass module deps list
-strip_mod_paths() {
- local x
- local ret
- local myret
+ modlist=( $(printf '%s\n' "${modlist[@]}" | sort | uniq) )
- for x in ${*}
- do
- ret=$(basename ${x} | cut -d. -f1)
- myret="${myret} ${ret}"
- done
-
- echo "${myret}"
+ local mydeps mymod
+ while IFS=" " read -r -u 3 mymod mydeps
+ do
+ echo ${mymod%:}
+ printf '%s\n' ${mydeps}
+ done 3< <(
+ local -a rxargs=( "${modlist[@]}" )
+
+ rxargs=( "${rxargs[@]/#/-e\/}" )
+ rxargs=( "${rxargs[@]/%/${KEXT}:}" )
+
+ cat "${moddir}/modules.builtin" \
+ | xargs printf '%s:\n' \
+ | grep -F "${rxargs[@]}"
+
+ cat "${moddir}/modules.dep" \
+ | grep -F "${rxargs[@]}"
+ )
+ fi | xargs basename -s "${KEXT}" | sort | uniq
}