2012-09-25 16:02:24 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2013-01-25 18:53:02 +00:00
|
|
|
# The modules_sign target checks for corresponding .o files for every .ko that
|
|
|
|
# is signed. This doesn't work for package builds which re-use the same build
|
2021-05-04 14:57:52 +00:00
|
|
|
# directory for every variant, and the .config may change between variants.
|
2013-01-25 18:53:02 +00:00
|
|
|
# So instead of using this script to just sign lib/modules/$KernelVer/extra,
|
|
|
|
# sign all .ko in the buildroot.
|
2012-09-25 16:02:24 +00:00
|
|
|
|
|
|
|
# This essentially duplicates the 'modules_sign' Kbuild target and runs the
|
|
|
|
# same commands for those modules.
|
|
|
|
|
2013-03-28 19:01:42 +00:00
|
|
|
MODSECKEY=$1
|
|
|
|
MODPUBKEY=$2
|
|
|
|
moddir=$3
|
2012-09-25 16:02:24 +00:00
|
|
|
|
2020-08-31 13:06:52 +00:00
|
|
|
modules=$(find "$moddir" -type f -name '*.ko')
|
2012-09-25 16:02:24 +00:00
|
|
|
|
2020-08-31 13:06:52 +00:00
|
|
|
NPROC=$(nproc)
|
2019-12-02 19:34:55 +00:00
|
|
|
[ -z "$NPROC" ] && NPROC=1
|
2012-09-25 16:02:24 +00:00
|
|
|
|
2019-12-02 19:34:55 +00:00
|
|
|
# NB: this loop runs 2000+ iterations. Try to be fast.
|
2023-08-22 12:04:59 +00:00
|
|
|
echo "$modules" | xargs -r -n16 -P "$NPROC" sh -c "
|
2019-12-02 19:34:55 +00:00
|
|
|
for mod; do
|
|
|
|
./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
|
|
|
|
rm -f \$mod.sig \$mod.dig
|
2012-09-25 16:02:24 +00:00
|
|
|
done
|
2019-12-02 19:34:55 +00:00
|
|
|
" DUMMYARG0 # xargs appends ARG1 ARG2..., which go into $mod in for loop.
|
2013-03-24 14:44:30 +00:00
|
|
|
|
2019-12-02 19:34:55 +00:00
|
|
|
RANDOMMOD=$(echo "$modules" | sort -R | head -n 1)
|
2020-08-31 13:06:52 +00:00
|
|
|
if [ "~Module signature appended~" != "$(tail -c 28 "$RANDOMMOD")" ]; then
|
2013-03-24 14:44:30 +00:00
|
|
|
echo "*****************************"
|
|
|
|
echo "*** Modules are unsigned! ***"
|
|
|
|
echo "*****************************"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|