hiromitsuhanada / rpms / kernel-rt

Forked from rpms/kernel-rt 4 years ago
Clone

Blame SOURCES/mod-sign.sh

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