Blame SOURCES/mod-sign.sh

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