[readonly/geninitrd: 544/1068] - find_depmod() implemented using modprobe info - shell constructs where possible
draenog
draenog at pld-linux.org
Sat Nov 2 19:58:08 CET 2013
commit 7ffba53467f20d5d9bf1f1e6af24344788cf3838
Author: Elan Ruusamäe <glen at pld-linux.org>
Date: Wed Dec 26 01:13:30 2007 +0000
- find_depmod() implemented using modprobe info
- shell constructs where possible
svn-id: @9161
geninitrd | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 6bc22b2..cdc8a01 100755
--- a/geninitrd
+++ b/geninitrd
@@ -263,7 +263,42 @@ busybox_applet() {
fi
}
-find_depmod () {
+# Finds module dependencies
+#
+# @param $mode silent | normal
+# @param $module
+#
+# Outputs each dependant module full path including the module itself.
+find_depmod() {
+ local mode="$1"
+ local module="$2"
+
+ # backwards compatible, process $mode
+ local modfile
+ if [ "$mode" = silent ]; then
+ modfile=$(modinfo -n $module 2>/dev/null)
+ else
+ modfile=$(modinfo -n $module)
+ fi
+ if [ ! -f "$modfile" ]; then
+ if [ "$mode" != silent ]; then
+ warn "$module: module not found for $kernel kernel"
+ fi
+ if ! is_no "$EXIT_IF_MISSING"; then
+ exit 1
+ else
+ warn "If $module isn't compiled in kernel then this initrd may not start your system."
+ fi
+ fi
+
+ # This works when user has module-init-tools installed even on 2.4 kernels
+ modprobe --set-version $kernel --show-depends $module | \
+ while read insmod modpath; do
+ echo $modpath
+ done
+}
+
+find_depmod_old () {
typeset mods module f level depfile first
depfile=/lib/modules/$kernel/modules.dep
@@ -337,6 +372,7 @@ addmodule() {
if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
if [ -n "$skiperrors" ]; then
+ # XXX should not ignore here errors
return
fi
@@ -344,9 +380,11 @@ addmodule() {
fi
# only need to add each module once
- # quote /
- local tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
- if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}'; then
+ local m have=0
+ for m in $MODULES; do
+ [ $m = $fmPath ] && have=1
+ done
+ if [ $have = 0 ]; then
MODULES="$MODULES $fmPath"
fi
}
@@ -371,7 +409,7 @@ findmodule() {
fi
local mod allModulesToFind
- if [ -n "$skiperrors" ]; then
+ if [ "$skiperrors" = 1 ]; then
allModulesToFind=$(find_depmod silent $modName)
else
allModulesToFind=$(find_depmod normal $modName)
@@ -381,7 +419,7 @@ findmodule() {
fi
for mod in $allModulesToFind; do
- mod=$(echo $mod | awk '{sub(/^\/lib\/modules\/[^\/]*\//, ""); print}')
+ mod=${mod#/lib/modules/$kernel/}
addmodule $mod "$skiperrors"
done
}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090
More information about the pld-cvs-commit
mailing list