xuexiaolei / 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
moddir=$3
fa4e14
123434
modules=`find $moddir -type f -name '*.ko'`
fa4e14
123434
NPROC=`nproc`
123434
[ -z "$NPROC" ] && NPROC=1
fa4e14
123434
# NB: this loop runs 2000+ iterations. Try to be fast.
123434
echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
123434
for mod; do
123434
    ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
123434
    rm -f \$mod.sig \$mod.dig
fa4e14
done
123434
" DUMMYARG0   # xargs appends ARG1 ARG2..., which go into $mod in for loop.
fa4e14
123434
RANDOMMOD=$(echo "$modules" | 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