pgreco / rpms / kernel

Forked from rpms/kernel 4 years ago
Clone
6c3baf
#! /bin/bash
6c3baf
6c3baf
MODSECKEY="./signing_key.priv"
6c3baf
MODPUBKEY="./signing_key.x509"
6c3baf
moddir=$1
6c3baf
6c3baf
modules=`find $moddir -type f -name '*.ko'`
6c3baf
6c3baf
NPROC=`nproc`
6c3baf
[ -z "$NPROC" ] && NPROC=1
6c3baf
6c3baf
# NB: this loop runs 2000+ iterations. Try to be fast.
6c3baf
echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
6c3baf
for mod; do
6c3baf
    ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
6c3baf
    rm -f \$mod.sig \$mod.dig
6c3baf
done
6c3baf
" DUMMYARG0   # xargs appends ARG1 ARG2..., which go into $mod in for loop.
6c3baf
6c3baf
RANDOMMOD=$(echo "$modules" | sort -R | tail -n 1)
6c3baf
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
6c3baf
	echo "*** Modules are unsigned! ***"
6c3baf
	exit 1
6c3baf
fi
6c3baf
6c3baf
exit 0