]> git.pld-linux.org Git - projects/geninitrd.git/blob - mod-depmod24.sh
Version 12531.
[projects/geninitrd.git] / mod-depmod24.sh
1 #!/bin/sh
2 DEPMOD24_RCSID='$Revision$ $Date::                            $'
3
4 # geninitrd mod: depmod for 2.4 kernel
5
6 # Finds module dependencies
7 #
8 # @param        $module
9 # @param        $mode   [silent]
10 #
11 # Outputs each dependant module full path.
12 find_depmod() {
13         local module="$1"
14         local mode="$2"
15
16         typeset mods module f level depfile first
17
18         depfile=/lib/modules/$kernel/modules.dep
19
20         if [ ! -f $depfile ]; then
21                 die "No $depfile! Run depmod and rerun $PROGRAM."
22         fi
23
24         # prepend / if no path given, append $modext.gz if not given,
25         # quote /
26         origmodule="$2"
27         module=$(echo "$2" | \
28                 awk '/\// {print;next} {print "/" $0}' | \
29                 awk '/\./ {print;next} {print $0 "'$modext'.gz"}' |
30                 awk '{gsub("/","\\/");print}')
31         mods=$(awk '
32 BEGIN { here = 0 }
33 /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
34 /:/ { here = 0 }
35 /(.*)/ { gsub(/\\/," "); if (here) print }
36 ' $depfile | xargs)
37
38         # fallback to $modext
39         if [ "$mods" = "" ]; then
40                 module=$(echo "$module" | awk '{gsub("\'$modext'\.gz$","\'$modext'",$0);print}')
41                 # ") - vim
42         fi
43
44         mods=$(awk '
45 BEGIN { here = 0 }
46 /'"$module"':(.*)/ { gsub(/:/," "); gsub(/\\/," "); print; here = 1; next }
47 /:/ { here = 0 }
48 /(.*)/ { gsub(/\\/," "); if (here) print }
49 ' $depfile | xargs)
50
51         if [ "$mods" = "" ]; then
52                 if [ "$1" != silent ]; then
53                         warn "$origmodule: module not found in $depfile"
54                 fi
55                 if ! is_no "$EXIT_IF_MISSING"; then
56                         exit 1
57                 else
58                         warn "If $origmodule isn't compiled in kernel then this initrd may not start your system."
59                 fi
60         fi
61
62         level=$3
63         if [ "$level" = "" ]; then
64                 level=0
65         fi
66         level=$((level + 1))
67         if [ $level -gt 20 ]; then
68                 die "$origmodule: cycle in $depfile"
69         fi
70
71         first=
72         for f in $mods; do
73                 if [ "$first" = "" ]; then
74                         first=$f
75                 else
76                         find_depmod $1 $f $level
77                 fi
78         done
79
80         echo $first
81 }
This page took 0.597292 seconds and 3 git commands to generate.