tleleu / rpms / kernel

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