zwp10758 / rpms / kernel

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