zhang / rpms / kernel

Forked from rpms/kernel 5 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
ba564c
moddir=$3
ba564c
ba564c
modules=`find $moddir -name *.ko`
ba564c
ba564c
for mod in $modules
ba564c
do
ba564c
    dir=`dirname $mod`
ba564c
    file=`basename $mod`
ba564c
ba564c
    ./scripts/sign-file sha256 ${MODSECKEY} ${MODPUBKEY} ${dir}/${file}
ba564c
    rm -f ${dir}/${file}.{sig,dig}
ba564c
done
ba564c
ba564c
RANDOMMOD=$(find $moddir -type f -name '*.ko' | 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