fedoraproject@6speed.de / rpms / kernel

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