]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
- depmod support added
authorMichal Moskal <michal@moskal.me>
Tue, 29 Jan 2002 11:19:51 +0000 (11:19 +0000)
committerMichal Moskal <michal@moskal.me>
Tue, 29 Jan 2002 11:19:51 +0000 (11:19 +0000)
- needs testing!

svn-id: @1225

geninitrd

index 475963d913534de3a618f7c461f900118b843362..055fb933144db5374ce563afa4a87b1cde24ff26 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -6,7 +6,7 @@
 #
 # based on mkinitrd from RedHat
 
-RCSID='$Id: geninitrd,v 2.11 2002/01/17 20:14:55 gotar Exp $'
+RCSID='$Id: geninitrd,v 2.12 2002/01/29 11:19:51 malekith Exp $'
 PATH=/sbin:$PATH
 export PATH
 
@@ -18,8 +18,9 @@ COMPRESS="yes"
 FS="rom"
 USEBSP="yes"
 USERAIDSTART="no"
-PRESCSIMODS="scsi_mod unknown sd_mod"
-PREIDEMODS="ide-mod ide-probe ide-probe-mod ide-disk"
+# it should be safe to remove scsi_mod from here, but I'm not sure...
+PRESCSIMODS="-scsi_mod unknown -sd_mod"
+PREIDEMODS="-ide-probe -ide-probe-mod -ide-disk"
 target=""
 kernel=""
 force=""
@@ -40,33 +41,87 @@ usage () {
 }
 
 
-my_find() {
-       for name in `ls`
-       do
-               if [ -d $name ]; then
-                       if [ "$name" != "build" ]; then
-                               (cd $name;my_find $1/$name $2)
-                       fi
+my_dirname() {
+       echo $1|awk -F/ '{print substr($0, 0, length($0) - length($NF));}'
+}
+
+find_depmod () {
+       typeset mods module f level depfile first
+
+       depfile=/lib/modules/$kernel/modules.dep
+       # prepend / if no path given, append .o if not given,
+       # quote /
+       module=$(echo "$2" | \
+                awk '/\// {print;next} {print "/" $0}' | \
+                awk '/\.o$/ {print;next} {print $0 ".o"}' |
+                awk '{gsub("/","\\/");print}')
+       mods=$(awk '
+BEGIN { here = 0 }
+/'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
+/:/ { here = 0 }
+/(.*)/ { gsub(/\\/," "); if (here) print }
+' $depfile | xargs)
+
+       if [ "$mods" = "" ] ; then
+               if [ "$1" != silent ] ; then
+                       echo "$module: module not found in $depfile" 1>&2
+               fi
+               exit 1
+       fi
+       
+       level=$3
+       if [ "$level" = "" ] ; then
+               level=0
+       fi
+       level=$(awk "BEGIN{print $level + 1}")
+       if [ $level -gt 20 ] ; then
+               echo "$module: cycle in $depfile" 1>&2
+               exit 1
+       fi
+       
+       first=
+       for f in $mods ; do
+               if [ "$first" = "" ] ; then
+                       first=$f
                else
-                       if [ -f $name -a "$name" = "$2" ]; then
-                               echo $1/$name
-                       fi
+                       find_depmod $1 $f $level
                fi
        done
+       
+       echo $first
 }
 
-my_dirname() {
-       echo $1|awk -F/ '{print substr($0, 0, length($0) - length($NF));}'
+addmodule() {
+       fmPath=$1
+       skiperrors=$2
+
+       if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
+               if [ -n "$skiperrors" ]; then
+                       return
+               fi
+
+               echo "module $fmPath present in modules.dep, but not in filesystem (kernel = $kernel)" 1>&2
+               exit 1
+       fi
+
+       # only need to add each module once
+       # quote /
+       tmpFmPath=$(echo $fmPath | awk '{gsub(/\//,"\\/");print}')
+       if echo "$MODULES" | awk '/'"$tmpFmPath"'/ {exit 1}' ; then
+               MODULES="$MODULES $fmPath"
+       fi
 }
 
 findmodule() {
        skiperrors=""
        modName=$1
+
        if [ "$(echo $modName | awk '{print(substr($0,1,1));}')" = "-" ]; then
                skiperrors=1
                modName="$(echo $modName | awk '{print(substr($0,2));}')"
        fi
 
+       # what's that?
        if [ "$modName" = "pluto" ]; then
                findmodule fc4
                findmodule soc
@@ -76,36 +131,20 @@ findmodule() {
                findmodule socal
        fi
 
-       fmPath="`(cd /lib/modules/$kernel; my_find . "$modName.o")`"
-
-       if [ ! -f "/lib/modules/$kernel/$fmPath" ]; then
-               if [ -n "$skiperrors" ]; then
-                       return
+       if [ -n "$skiperrors" ]; then
+               allModulesToFind=`find_depmod silent $modName`
+       else
+               allModulesToFind=`find_depmod normal $modName`
+               if [ $? != 0 ] ; then
+                       exit 1
                fi
-
-               # ignore the absence of the scsi modules
-               for n in $PRESCSIMODS; do
-                       if [ "$n" = "$modName" ]; then
-                               return;
-                       fi
-               done;
-
-               # ignore the absence of the ide modules
-               for n in $PREIDEMODS; do
-                       if [ "$n" = "$modName" ]; then
-                               return;
-                       fi
-               done;
-
-               echo "No module $modName found for kernel $kernel" 1>&2
-               exit 1
-       fi
-
-       # only need to add each module once
-       tmpFmPath="`echo "$fmPath"|awk -F/ '{for(i=1;i<NF;i++) { printf("%s\\\\/",$i); } { print $NF; }}'`"
-       if is_yes "`echo "$MODULES" | awk '/"'$tmpFmPath'"/ { print "yes"; }' `" ; then : ; else
-               MODULES="$MODULES $fmPath"
        fi
+       
+       for mod in $allModulesToFind ; do
+               mod=$(echo $mod | \
+                     awk '{sub(/^\/lib\/modules\/[^\/]*\//,"");print}')
+               addmodule $mod "$skiperrors"
+       done
 }
 
 inst() {
@@ -434,7 +473,7 @@ fi
 if is_yes "$ADDSCSI" || is_yes "$(echo "$rootdev" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
 
     for n in $PRESCSIMODS; do
-       if [ "$n" = "unknown" ] ; then
+       if [ "X$n" = "Xunknown" ] ; then
                if [ ! -f "$modulefile" ]; then
                        modulefile=/etc/conf.modules
                fi
This page took 0.519256 seconds and 4 git commands to generate.