husy394 / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
f2c60e
#! /bin/bash
f2c60e
f2c60e
Dir=$1
f2c60e
List=$2
f2c60e
f2c60e
pushd $Dir
f2c60e
rm -rf modnames
f2c60e
find . -name "*.ko" -type f > modnames
f2c60e
# Look through all of the modules, and throw any that have a dependency in
f2c60e
# our list into the list as well.
f2c60e
rm -rf dep.list dep2.list
f2c60e
rm -rf req.list req2.list
f2c60e
touch dep.list req.list
f2c60e
cp $2 .
f2c60e
f2c60e
for dep in `cat modnames`
f2c60e
do
f2c60e
  depends=`modinfo $dep | grep depends| cut -f2 -d":" | sed -e 's/^[ \t]*//'`
f2c60e
  [ -z "$depends" ] && continue;
f2c60e
  for mod in `echo $depends | sed -e 's/,/ /g'`
f2c60e
  do
f2c60e
    match=`grep "^$mod.ko" mod-extra.list` ||:
f2c60e
    if [ -z "$match" ]
f2c60e
    then
f2c60e
      continue
f2c60e
    else
f2c60e
      # check if the module we're looking at is in mod-extra too.  if so
f2c60e
      # we don't need to mark the dep as required
f2c60e
      mod2=`basename $dep`
f2c60e
      match2=`grep "^$mod2" mod-extra.list` ||:
f2c60e
      if [ -n "$match2" ]
f2c60e
      then
f2c60e
        continue
f2c60e
          #echo $mod2 >> notreq.list
f2c60e
        else
f2c60e
          echo $mod.ko >> req.list
f2c60e
      fi
f2c60e
    fi
f2c60e
  done
f2c60e
done
f2c60e
f2c60e
sort -u req.list > req2.list
f2c60e
sort -u mod-extra.list > mod-extra2.list
f2c60e
join -v 1 mod-extra2.list req2.list > mod-extra3.list
f2c60e
f2c60e
for mod in `cat mod-extra3.list`
f2c60e
do
f2c60e
  # get the path for the module
f2c60e
  modpath=`grep /$mod modnames` ||:
f2c60e
  [ -z "$modpath" ]  && continue;
f2c60e
  echo $modpath >> dep.list
f2c60e
done
f2c60e
f2c60e
sort -u dep.list > dep2.list
f2c60e
f2c60e
# now move the modules into the extra/ directory
f2c60e
for mod in `cat dep2.list`
f2c60e
do
f2c60e
  newpath=`dirname $mod | sed -e 's/kernel\//extra\//'`
f2c60e
  mkdir -p $newpath
f2c60e
  mv $mod $newpath
f2c60e
done
f2c60e
f2c60e
popd
f2c60e
f2c60e
# If we're signing modules, we can't leave the .mod files for the .ko files
f2c60e
# we've moved in .tmp_versions/.  Remove them so the Kbuild 'modules_sign'
f2c60e
# target doesn't try to sign a non-existent file.  This is kinda ugly, but
f2c60e
# so is modules-extra.
f2c60e
f2c60e
for mod in `cat ${Dir}/dep2.list`
f2c60e
do
f2c60e
  modfile=`basename $mod | sed -e 's/.ko/.mod/'`
f2c60e
  rm .tmp_versions/$modfile
f2c60e
done
f2c60e
f2c60e
pushd $Dir
f2c60e
rm modnames dep.list dep2.list req.list req2.list
f2c60e
rm mod-extra.list mod-extra2.list mod-extra3.list
f2c60e
popd