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