Josh Boyer f0f4ff2
#! /bin/bash
Josh Boyer 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.
Josh Boyer f0f4ff2
Josh Boyer f0f4ff2
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
Josh Boyer f0f4ff2
# same commands for those modules.
Josh Boyer f0f4ff2
Josh Boyer f0f4ff2
moddir=$1
Josh Boyer f0f4ff2
Josh Boyer f0f4ff2
modules=`find $moddir -name *.ko`
Josh Boyer f0f4ff2
Josh Boyer f0f4ff2
MODSECKEY="./signing_key.priv"
Josh Boyer f0f4ff2
MODPUBKEY="./signing_key.x509"
Josh Boyer f0f4ff2
Josh Boyer f0f4ff2
for mod in $modules
Josh Boyer f0f4ff2
do
Josh Boyer f0f4ff2
    dir=`dirname $mod`
Josh Boyer f0f4ff2
    file=`basename $mod`
Josh Boyer f0f4ff2
Josh Boyer ab465cb
    ./scripts/sign-file sha256 ${MODSECKEY} ${MODPUBKEY} ${dir}/${file} \
Josh Boyer f0f4ff2
       ${dir}/${file}.signed
Josh Boyer f0f4ff2
    mv ${dir}/${file}.signed ${dir}/${file}
Josh Boyer f0f4ff2
    rm -f ${dir}/${file}.{sig,dig}
Josh Boyer f0f4ff2
done