summaryrefslogtreecommitdiffstats
path: root/mod-sign.sh
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2019-12-02 14:34:55 -0500
committerLaura Abbott <labbott@redhat.com>2019-12-02 14:34:55 -0500
commit276fd645956290ab3a432aba71c311a597edeb1f (patch)
tree25fbb10095fd42407f740f078289a7c0b7ccdbf9 /mod-sign.sh
parentaa92e83bbbe79026d32233778371a7fb1ed6c5d1 (diff)
downloadkernel-276fd645956290ab3a432aba71c311a597edeb1f.tar.gz
kernel-276fd645956290ab3a432aba71c311a597edeb1f.tar.xz
kernel-276fd645956290ab3a432aba71c311a597edeb1f.zip
Clean up and parallelize mod-sign.sh
Thanks to Denys Vlasenko for this work
Diffstat (limited to 'mod-sign.sh')
-rwxr-xr-xmod-sign.sh19
1 files changed, 10 insertions, 9 deletions
diff --git a/mod-sign.sh b/mod-sign.sh
index 5081e77dc..ed2bd62b6 100755
--- a/mod-sign.sh
+++ b/mod-sign.sh
@@ -11,21 +11,22 @@
MODSECKEY=$1
MODPUBKEY=$2
-
moddir=$3
-modules=`find $moddir -name *.ko`
+modules=`find $moddir -type f -name '*.ko'`
-for mod in $modules
-do
- dir=`dirname $mod`
- file=`basename $mod`
+NPROC=`nproc`
+[ -z "$NPROC" ] && NPROC=1
- ./scripts/sign-file sha256 ${MODSECKEY} ${MODPUBKEY} ${dir}/${file}
- rm -f ${dir}/${file}.{sig,dig}
+# NB: this loop runs 2000+ iterations. Try to be fast.
+echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
+for mod; do
+ ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
+ rm -f \$mod.sig \$mod.dig
done
+" DUMMYARG0 # xargs appends ARG1 ARG2..., which go into $mod in for loop.
-RANDOMMOD=$(find $moddir -type f -name '*.ko' | sort -R | head -n 1)
+RANDOMMOD=$(echo "$modules" | sort -R | head -n 1)
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
echo "*****************************"
echo "*** Modules are unsigned! ***"