zhang / rpms / kernel

Forked from rpms/kernel 5 years ago
Clone
ba564c
#! /bin/bash
ba564c
4eb337
Rpmdir=$1
4eb337
Dir=$Rpmdir/$2
4eb337
List=$3
ba564c
ba564c
pushd $Dir
ba564c
rm -rf modnames
ba564c
find . -name "*.ko" -type f > modnames
ba564c
# Look through all of the modules, and throw any that have a dependency in
ba564c
# our list into the list as well.
4eb337
rm -rf dep.list
ba564c
rm -rf req.list req2.list
ba564c
touch dep.list req.list
4eb337
cp $List .
ba564c
ba564c
for dep in `cat modnames`
ba564c
do
ba564c
  depends=`modinfo $dep | grep depends| cut -f2 -d":" | sed -e 's/^[ \t]*//'`
ba564c
  [ -z "$depends" ] && continue;
ba564c
  for mod in `echo $depends | sed -e 's/,/ /g'`
ba564c
  do
ba564c
    match=`grep "^$mod.ko" mod-extra.list` ||:
ba564c
    if [ -z "$match" ]
ba564c
    then
ba564c
      continue
ba564c
    else
ba564c
      # check if the module we're looking at is in mod-extra too.  if so
ba564c
      # we don't need to mark the dep as required
ba564c
      mod2=`basename $dep`
ba564c
      match2=`grep "^$mod2" mod-extra.list` ||:
ba564c
      if [ -n "$match2" ]
ba564c
      then
ba564c
        continue
ba564c
          #echo $mod2 >> notreq.list
ba564c
        else
ba564c
          echo $mod.ko >> req.list
ba564c
      fi
ba564c
    fi
ba564c
  done
ba564c
done
ba564c
ba564c
sort -u req.list > req2.list
ba564c
sort -u mod-extra.list > mod-extra2.list
ba564c
join -v 1 mod-extra2.list req2.list > mod-extra3.list
ba564c
ba564c
for mod in `cat mod-extra3.list`
ba564c
do
ba564c
  # get the path for the module
ba564c
  modpath=`grep /$mod modnames` ||:
ba564c
  [ -z "$modpath" ]  && continue;
4eb337
  echo /lib/modules/$(basename $Dir)/${modpath#"./"} >> dep.list
ba564c
done
ba564c
4eb337
sort -u dep.list > $Rpmdir/modules-extra.list
4eb337
rm modnames dep.list req.list req2.list
ba564c
rm mod-extra.list mod-extra2.list mod-extra3.list
ba564c
popd
4eb337
4eb337
sed -i "s|^\/||g" $Rpmdir/modules-extra.list