chengshan / rpms / kernel

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