dracutlogfile=/tmp/dracut.log
[[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
>"$dracutlogfile"
-fi
+ fi
dwarning() {
echo "W: $@" >&2
done
}
-# install kernel modules, and handle installing all their dependencies as well.
+# Install a single kernel module along with any firmware it may require.
+# $1 = full path to kernel module to install
+install_kmod_with_fw() {
+ local modname=${1##*/} fwdir found
+ modname=${modname%.ko}
+ inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
+ for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
+ found=''
+ for fwdir in $fw_dir; do
+ if [[ -d $fwdir && -f $fwdir/$fw ]]; then
+ inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
+ found=yes
+ fi
+ done
+ if [[ $found != yes ]]; then
+ dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
+ fi
+ done
+}
+
+# Do something with all the dependencies of a kernel module.
+# Note that kernel modules depend on themselves using the technique we use
+# $1 = function to call for each dependency we find
+# It will be passed the full path to the found kernel module
+# $2 = module to get dependencies for
+# rest of args = arguments to modprobe
+for_each_kmod_dep() {
+ local func=$1 kmod=$2 cmd modpapth options
+ shift 2
+ modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
+ while read cmd modpath options; do
+ [[ $cmd = insmod ]] || continue
+ $func $modpath
+ done
+}
+
+# install kernel modules along with all their dependencies.
instmods() {
[[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd
}
# ok, load the module, all its dependencies, and any firmware
# it may require
- modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
- --show-depends $mod 2>/dev/null | \
- while read cmd modpath options; do
- [[ $cmd = insmod ]] || continue
- modname=${modpath##*/}
- modname=${modname%.ko}
- if [[ ${mod/-/_} != ${modname/-/_} ]]; then
- dinfo "Installing dependencies for $mod ($modpath)"
- instmods $mpargs $modname
- fi
- inst_simple "$modpath" "/lib/modules/$kernel/${modpath##*/lib/modules/$kernel/}"
- for fw in $(modinfo -k $kernel -F firmware $modpath 2>/dev/null); do
- unset found
- IFS=:
- for fwdir in $fw_dir; do
- if [ -d "$fwdir" -a -f $fwdir/$fw ]; then
- inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
- found=yes
- fi
- done
- if [[ $found != yes ]]; then
- dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
- fi
- done
- done
+ for_each_kmod_dep install_kmod_with_fw $mod \
+ --set-version $kernel -d ${srcmods%%/lib/modules/*}/
;;
esac
shift