Josh Boyer f0f4ff
#! /bin/bash
Josh Boyer f0f4ff
Josh Boyer f0f4ff
# We need to sign modules we've moved from <path>/kernel/ to <path>/extra/
Josh Boyer f0f4ff
# during mod-extra processing by hand.  The 'modules_sign' Kbuild target can
Josh Boyer f0f4ff
# "handle" out-of-tree modules, but it does that by not signing them.  Plus,
Josh Boyer f0f4ff
# the modules we've moved aren't actually out-of-tree.  We've just shifted
Josh Boyer f0f4ff
# them to a different location behind Kbuild's back because we are mean.
Josh Boyer f0f4ff
Josh Boyer f0f4ff
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
Josh Boyer f0f4ff
# same commands for those modules.
Josh Boyer f0f4ff
Josh Boyer f0f4ff
moddir=$1
Josh Boyer f0f4ff
Josh Boyer f0f4ff
modules=`find $moddir -name *.ko`
Josh Boyer f0f4ff
Josh Boyer f0f4ff
MODSECKEY="./signing_key.priv"
Josh Boyer f0f4ff
MODPUBKEY="./signing_key.x509"
Josh Boyer f0f4ff
Josh Boyer f0f4ff
for mod in $modules
Josh Boyer f0f4ff
do
Josh Boyer f0f4ff
    dir=`dirname $mod`
Josh Boyer f0f4ff
    file=`basename $mod`
Josh Boyer f0f4ff
Josh Boyer ef06d4
    ./scripts/sign-file ${MODSECKEY} ${MODPUBKEY} ${dir}/${file} \
Josh Boyer f0f4ff
       ${dir}/${file}.signed
Josh Boyer f0f4ff
    mv ${dir}/${file}.signed ${dir}/${file}
Josh Boyer f0f4ff
    rm -f ${dir}/${file}.{sig,dig}
Josh Boyer f0f4ff
done