tleleu / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
ba564c
#! /bin/bash
ba564c
ba564c
Dir=$1
ba564c
List=$2
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.
ba564c
rm -rf dep.list dep2.list
ba564c
rm -rf req.list req2.list
ba564c
touch dep.list req.list
ba564c
cp $2 .
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;
ba564c
  echo $modpath >> dep.list
ba564c
done
ba564c
ba564c
sort -u dep.list > dep2.list
ba564c
ba564c
# now move the modules into the extra/ directory
ba564c
for mod in `cat dep2.list`
ba564c
do
ba564c
  newpath=`dirname $mod | sed -e 's/kernel\//extra\//'`
ba564c
  mkdir -p $newpath
ba564c
  mv $mod $newpath
ba564c
done
ba564c
ba564c
popd
ba564c
ba564c
# If we're signing modules, we can't leave the .mod files for the .ko files
ba564c
# we've moved in .tmp_versions/.  Remove them so the Kbuild 'modules_sign'
ba564c
# target doesn't try to sign a non-existent file.  This is kinda ugly, but
ba564c
# so is modules-extra.
ba564c
ba564c
for mod in `cat ${Dir}/dep2.list`
ba564c
do
ba564c
  modfile=`basename $mod | sed -e 's/.ko/.mod/'`
ba564c
  rm .tmp_versions/$modfile
ba564c
done
ba564c
ba564c
pushd $Dir
ba564c
rm modnames dep.list dep2.list req.list req2.list
ba564c
rm mod-extra.list mod-extra2.list mod-extra3.list
ba564c
popd