husy394 / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
f2c60e
#! /bin/bash
f2c60e
f2c60e
# The modules_sign target checks for corresponding .o files for every .ko that
f2c60e
# is signed. This doesn't work for package builds which re-use the same build
f2c60e
# directory for every flavour, and the .config may change between flavours.
f2c60e
# So instead of using this script to just sign lib/modules/$KernelVer/extra,
f2c60e
# sign all .ko in the buildroot.
f2c60e
f2c60e
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
f2c60e
# same commands for those modules.
f2c60e
f2c60e
MODSECKEY=$1
f2c60e
MODPUBKEY=$2
f2c60e
f2c60e
moddir=$3
f2c60e
f2c60e
modules=`find $moddir -name *.ko`
f2c60e
f2c60e
for mod in $modules
f2c60e
do
f2c60e
    dir=`dirname $mod`
f2c60e
    file=`basename $mod`
f2c60e
f2c60e
    ./scripts/sign-file sha256 ${MODSECKEY} ${MODPUBKEY} ${dir}/${file}
f2c60e
    rm -f ${dir}/${file}.{sig,dig}
f2c60e
done
f2c60e
f2c60e
RANDOMMOD=$(find $moddir -type f -name '*.ko' | sort -R | head -n 1)
f2c60e
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
f2c60e
    echo "*****************************"
f2c60e
    echo "*** Modules are unsigned! ***"
f2c60e
    echo "*****************************"
f2c60e
    exit 1
f2c60e
fi
f2c60e
f2c60e
exit 0