source: MondoRescue/branches/2.2.9/mindi-busybox/examples/depmod@ 2725

Last change on this file since 2725 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/sh
2#
3# Simple depmod, use to generate modprobe.conf
4#
5# Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
6#
7# Licensed under GPLv2, see file LICENSE in this source tree.
8#
9
10local BASE="${1:-/usr/lib/modules}"
11
12find "$BASE" -name '*.ko.gz' | while read I ; do
13 N=`basename "$I" '.ko.gz'`
14 echo -n "@$N"
15 zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g'
16done | awk '
17{
18 # modules which has no dependencies are resolved
19 if ( NF == 1 ) { res[$1] = ""; next }
20 # others have to be resolved based on those which already resolved
21 i = $1; $1 = ""; deps[i] = $0; ++ndeps
22}
23END {
24 # resolve implicit dependencies
25 while ( ndeps ) for (mod in deps) {
26 if ( index(deps[mod], "@") > 0 ) {
27 $0 = deps[mod]
28 for ( i=1; i<=NF; ++i ) {
29 if ( substr($i,1,1) == "@" ) {
30 if ( $i in res ) {
31 $i = res[$i] " " substr($i,2)
32 }
33 }
34 }
35 deps[mod] = $0
36 } else {
37 res[mod] = deps[mod]
38 delete deps[mod]
39 --ndeps
40 }
41 }
42
43 # output dependencies in modules.dep format
44 for ( mod in res ) {
45 $0 = res[mod]
46 s = ""
47 delete a
48 for ( i=1; i<=NF; ++i ) {
49 if ( ! ($i in a) ) {
50 a[$i] = $i
51 s = " ," $i s
52 }
53 }
54 print "," substr(mod,2) ":" s
55 }
56}
57' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g"
Note: See TracBrowser for help on using the repository browser.