diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-24 20:54:14 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-24 20:54:14 +0000 |
commit | bd23fbbd0a0491e00bac89fc30f31972525d95bb (patch) | |
tree | 526e7e8a52ccb222a4bbf6d5e4b567a8e908139f | |
parent | 8e2c9e1518d42320ebd4b3ff09220d79a199e8ff (diff) |
docs/depmod: and example of depmod in shell/sed/awk...
-rw-r--r-- | docs/depmod | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/docs/depmod b/docs/depmod new file mode 100644 index 000000000..d8c4cc5aa --- /dev/null +++ b/docs/depmod @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Simple depmod, use to generate modprobe.conf +# +# Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com> +# +# Licensed under GPLv2 +# + +local BASE="${1:-/usr/lib/modules}" + +find "$BASE" -name '*.ko.gz' | while read I ; do + N=`basename "$I" '.ko.gz'` + echo -n "@$N" + zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g' +done | awk ' +{ + # modules which has no dependencies are resolved + if ( NF == 1 ) { res[$1] = ""; next } + # others have to be resolved based on those which already resolved + i = $1; $1 = ""; deps[i] = $0; ++ndeps +} +END { + # resolve implicit dependencies + while ( ndeps ) for (mod in deps) { + if ( index(deps[mod], "@") > 0 ) { + $0 = deps[mod] + for ( i=1; i<=NF; ++i ) { + if ( substr($i,1,1) == "@" ) { + if ( $i in res ) { + $i = res[$i] " " substr($i,2) + } + } + } + deps[mod] = $0 + } else { + res[mod] = deps[mod] + delete deps[mod] + --ndeps + } + } + + # output dependencies in modules.dep format + for ( mod in res ) { + $0 = res[mod] + s = "" + delete a + for ( i=1; i<=NF; ++i ) { + if ( ! ($i in a) ) { + a[$i] = $i + s = " ," $i s + } + } + print "," substr(mod,2) ":" s + } +} +' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g" |