mod-extra.sh 1.91 KB
Newer Older
Rocky Automation's avatar
Rocky Automation committed
1
2
#! /bin/bash

Rocky Automation's avatar
Rocky Automation committed
3
4
Dir=$1
List=$2
Rocky Automation's avatar
Rocky Automation committed
5
6
7
8
9
10

pushd $Dir
rm -rf modnames
find . -name "*.ko" -type f > modnames
# Look through all of the modules, and throw any that have a dependency in
# our list into the list as well.
Rocky Automation's avatar
Rocky Automation committed
11
rm -rf dep.list dep2.list
Rocky Automation's avatar
Rocky Automation committed
12
13
rm -rf req.list req2.list
touch dep.list req.list
Rocky Automation's avatar
Rocky Automation committed
14
cp $2 .
Rocky Automation's avatar
Rocky Automation committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

for dep in `cat modnames`
do
  depends=`modinfo $dep | grep depends| cut -f2 -d":" | sed -e 's/^[ \t]*//'`
  [ -z "$depends" ] && continue;
  for mod in `echo $depends | sed -e 's/,/ /g'`
  do
    match=`grep "^$mod.ko" mod-extra.list` ||:
    if [ -z "$match" ]
    then
      continue
    else
      # check if the module we're looking at is in mod-extra too.  if so
      # we don't need to mark the dep as required
      mod2=`basename $dep`
      match2=`grep "^$mod2" mod-extra.list` ||:
      if [ -n "$match2" ]
      then
        continue
          #echo $mod2 >> notreq.list
        else
          echo $mod.ko >> req.list
      fi
    fi
  done
done

sort -u req.list > req2.list
sort -u mod-extra.list > mod-extra2.list
join -v 1 mod-extra2.list req2.list > mod-extra3.list

for mod in `cat mod-extra3.list`
do
  # get the path for the module
  modpath=`grep /$mod modnames` ||:
  [ -z "$modpath" ]  && continue;
Rocky Automation's avatar
Rocky Automation committed
51
52
53
54
55
56
57
58
59
60
61
  echo $modpath >> dep.list
done

sort -u dep.list > dep2.list

# now move the modules into the extra/ directory
for mod in `cat dep2.list`
do
  newpath=`dirname $mod | sed -e 's/kernel\//extra\//'`
  mkdir -p $newpath
  mv $mod $newpath
Rocky Automation's avatar
Rocky Automation committed
62
63
64
done

popd
65

Rocky Automation's avatar
Rocky Automation committed
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# If we're signing modules, we can't leave the .mod files for the .ko files
# we've moved in .tmp_versions/.  Remove them so the Kbuild 'modules_sign'
# target doesn't try to sign a non-existent file.  This is kinda ugly, but
# so is modules-extra.

for mod in `cat ${Dir}/dep2.list`
do
  modfile=`basename $mod | sed -e 's/.ko/.mod/'`
  rm .tmp_versions/$modfile
done

pushd $Dir
rm modnames dep.list dep2.list req.list req2.list
rm mod-extra.list mod-extra2.list mod-extra3.list
popd