aboutsummaryrefslogtreecommitdiffstats
path: root/kmod.prov
blob: 2f0dd0292d4e56302bf4ca4db2c499e79df4c8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

provideslist=`sed "s/['\"]/\\\&/g"`
modulelist=$(echo "$provideslist" | egrep '^.*(/lib/modules/|/var/lib/dkms/).*\.ko(\.gz)?$')
echo $modulelist | xargs -r /sbin/modinfo | \
        perl -lne '
$name = $1 if m!^filename:\s*(?:.*/)?([^/]+)\.k?o!;
$ver = $1 if /^version:\s*[a-zA-Z]{0,6}\-?(\d+[\.\:\-\[\]]?\d*[\.\:\-\[\]]?\d*[\.\:\-\[\]]?\d*[\.\:\-\[\]]?\d*-?[a-zA-Z]{0,6}\d?).*/;
$ver =~ s/(\[|\]|\:|-)/_/;
if (/^vermagic:/) {
  print "kmod\($name\)" . ($ver ? " = $ver" : "") if $name;
  undef $name; undef $ver;
}
'
dkmslist=$(echo "$provideslist" | egrep '(/var/lib/dkms-binary/[^/]+/[^/]+|/usr/src)/[^/]+/dkms.conf$')
[ -n "$dkmslist" ] && for d in $dkmslist; do
    VERSION=`sed -rne 's/^PACKAGE_VERSION="?([^"]+)"?$/\1/;T;p' $d`
    [ -z "$VERSION" ] && continue
    PACKAGE_NAME=`sed -rne 's/^PACKAGE_NAME="?([^"]+)"?$/\1/;T;p' $d`
    MODULES=`sed -rne 's/^DEST_MODULE_NAME\[[0-9]+\]="?([^"]+)"?$/\1/;T;p' $d`
    [ -z "$MODULES" ] && MODULES=`sed -rne 's/^BUILT_MODULE_NAME\[[0-9]+\]="?([^"]+)"?$/\1/;T;p' $d`
    # default on PACKAGE_NAME if no BUILT_MODULE_NAME is specified
    [ -z "$MODULES" ] && MODULES=$PACKAGE_NAME
    echo "$MODULES" | sed -re "s/\\\$PACKAGE_NAME/$PACKAGE_NAME/" | while read m; do
	echo "kmod($m) = $VERSION"
    done
done