Blame SOURCES/mod-extra.sh

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