hiromitsuhanada / rpms / kernel-rt

Forked from rpms/kernel-rt 4 years ago
Clone

Blame SOURCES/mod-sign.sh

f70460
#! /bin/bash
f70460
f70460
# The modules_sign target checks for corresponding .o files for every .ko that
f70460
# is signed. This doesn't work for package builds which re-use the same build
f70460
# directory for every flavour, and the .config may change between flavours.
f70460
# So instead of using this script to just sign lib/modules/$KernelVer/extra,
f70460
# sign all .ko in the buildroot.
f70460
f70460
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
f70460
# same commands for those modules.
f70460
f70460
MODSECKEY=$1
f70460
MODPUBKEY=$2
f70460
moddir=$3
f70460
f70460
modules=`find $moddir -type f -name '*.ko'`
f70460
f70460
NPROC=`nproc`
f70460
[ -z "$NPROC" ] && NPROC=1
f70460
f70460
# NB: this loop runs 2000+ iterations. Try to be fast.
f70460
echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
f70460
for mod; do
f70460
    ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
f70460
    rm -f \$mod.sig \$mod.dig
f70460
done
f70460
" DUMMYARG0   # xargs appends ARG1 ARG2..., which go into $mod in for loop.
f70460
f70460
RANDOMMOD=$(echo "$modules" | sort -R | head -n 1)
f70460
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
f70460
    echo "*****************************"
f70460
    echo "*** Modules are unsigned! ***"
f70460
    echo "*****************************"
f70460
    exit 1
f70460
fi
f70460
f70460
exit 0