summaryrefslogtreecommitdiff
path: root/scripts/package-build/linux-kernel/sign-modules.sh
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-07-08 20:45:13 +0200
committerChristian Breunig <christian@breunig.cc>2026-07-08 20:45:13 +0200
commit21c7e66112d3ec360a9902037d086fdb15e4ebeb (patch)
tree696d40eea8b9b201c8784ed49c7466ff4a16afe6 /scripts/package-build/linux-kernel/sign-modules.sh
parent12038e88d4fe42617f9cd39ccfd1184a52e5810a (diff)
downloadvyos-build-21c7e66112d3ec360a9902037d086fdb15e4ebeb.tar.gz
vyos-build-21c7e66112d3ec360a9902037d086fdb15e4ebeb.zip
Kernel: T5641: enable module compression to save disk space
After signing the Linux Kernel modules with the ephemeral key, proceed by compressing the Kernel modules with xz to reduce the final ISO image size. Initial tests have shown a size reduction by 60MiB.
Diffstat (limited to 'scripts/package-build/linux-kernel/sign-modules.sh')
-rwxr-xr-xscripts/package-build/linux-kernel/sign-modules.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/package-build/linux-kernel/sign-modules.sh b/scripts/package-build/linux-kernel/sign-modules.sh
index cfb368eb..1fb82165 100755
--- a/scripts/package-build/linux-kernel/sign-modules.sh
+++ b/scripts/package-build/linux-kernel/sign-modules.sh
@@ -1,15 +1,28 @@
-#!/bin/sh
+#!/bin/sh -x
BASE_DIR=$(dirname $0)
MODULE_DIR=$1
+# Pass "--keep" as $2 to retain the uncompressed, signed .ko next to the
+# .ko.xz it produces. Needed by callers whose build system tracks the
+# uncompressed .ko as a build output (e.g. CMake custom commands) and
+# would otherwise consider it missing and regenerate an unsigned copy.
+KEEP_UNCOMPRESSED=$2
. ${BASE_DIR}/kernel-vars
SIGN_FILE="${KERNEL_DIR}/scripts/sign-file"
+CONFIG_FILE="${KERNEL_DIR}/.config"
if [ -f ${EPHEMERAL_KEY} ] && [ -f ${EPHEMERAL_CERT} ]; then
find ${MODULE_DIR} -type f -name \*.ko | while read MODULE; do
echo "I: Signing ${MODULE} ..."
${SIGN_FILE} sha512 ${EPHEMERAL_KEY} ${EPHEMERAL_CERT} ${MODULE}
+ if [ -f "$CONFIG_FILE" ] && grep -qx "CONFIG_MODULE_COMPRESS_XZ=y" "$CONFIG_FILE"; then
+ if [ "${KEEP_UNCOMPRESSED}" = "--keep" ]; then
+ xz --compress --keep ${MODULE}
+ else
+ xz --compress ${MODULE}
+ fi
+ fi
done
+ find ${MODULE_DIR}
fi
-