dingjian / rpms / kernel-rt

Forked from rpms/kernel-rt 4 years ago
Clone

Blame SOURCES/mod-sign.sh

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