Author: glen
Date: Wed Dec 26 02:13:30 2007
New Revision: 9161

Modified:
   geninitrd/trunk/geninitrd
Log:
- find_depmod() implemented using modprobe info
- shell constructs where possible

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd   (original)
+++ geninitrd/trunk/geninitrd   Wed Dec 26 02:13:30 2007
@@ -263,7 +263,42 @@
        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 @@
 
        if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
                if [ -n "$skiperrors" ]; then
+                       # XXX should not ignore here errors
                        return
                fi
 
@@ -344,9 +380,11 @@
        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 @@
        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 @@
        fi
 
        for mod in $allModulesToFind; do
-               mod=$(echo $mod | awk '{sub(/^\/lib\/modules\/[^\/]*\//, ""); 
print}')
+               mod=${mod#/lib/modules/$kernel/}
                addmodule $mod "$skiperrors"
        done
 }
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to