f0f4ff2
#! /bin/bash
f0f4ff2
Kyle McMartin d0a8cf5
# The modules_sign target checks for corresponding .o files for every .ko that
Kyle McMartin d0a8cf5
# is signed. This doesn't work for package builds which re-use the same build
Kyle McMartin d0a8cf5
# directory for every flavour, and the .config may change between flavours.
Kyle McMartin d0a8cf5
# So instead of using this script to just sign lib/modules/$KernelVer/extra,
Kyle McMartin d0a8cf5
# sign all .ko in the buildroot.
f0f4ff2
f0f4ff2
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
f0f4ff2
# same commands for those modules.
f0f4ff2
f0f4ff2
moddir=$1
f0f4ff2
f0f4ff2
modules=`find $moddir -name *.ko`
f0f4ff2
f0f4ff2
MODSECKEY="./signing_key.priv"
f0f4ff2
MODPUBKEY="./signing_key.x509"
f0f4ff2
f0f4ff2
for mod in $modules
f0f4ff2
do
f0f4ff2
    dir=`dirname $mod`
f0f4ff2
    file=`basename $mod`
f0f4ff2
ef06d4b
    ./scripts/sign-file ${MODSECKEY} ${MODPUBKEY} ${dir}/${file} \
f0f4ff2
       ${dir}/${file}.signed
f0f4ff2
    mv ${dir}/${file}.signed ${dir}/${file}
f0f4ff2
    rm -f ${dir}/${file}.{sig,dig}
f0f4ff2
done