Version 2 moves all of the logic into the eclass, reducing code
duplication at the cost of potentially having to adjust the
CONFIG_MODULE_SIG_* logic at some later stage if this changes upstream.
We now also unset KBUILD_SIGN_PIN, as is done in linux-mod-r1.eclass as
well.
From b0e42a34469c3799b2c2c636d794a95040549133 Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <
[email protected]>
Date: Thu, 15 Jun 2023 11:50:10 +0200
Subject: [PATCH] kernel-build.eclass: add IUSE="+strip modules-sign",
install
generated keys
- Let the kernel build system handle stripping of the modules.
This is necessary for successfully signing and compressing modules.
Inspired by linux-mod-r1.eclass.
- If the build system has generated keys or certificates, install them.
This is required to successfully sign external kernel modules.
- Enable module signing configure options if requested by the user.
- Define the user variables MODULES_SIGN_HASH and MODULES_SIGN_KEY.
For controlling the used hashing algorithm and allowing the use of
external keys. These variables are the same as in linux-mod-r1.eclass
- Warn the user if we are letting the kernel build system generate the
signing
key. This key will end up binary packages. Plus external modules will
have to
be resigned if gentoo-kernel is re-emerged (i.e. a new key was generated).
Closes:
https://bugs.gentoo.org/814344
Closes:
https://bugs.gentoo.org/881651
Signed-off-by: Andrew Ammerlaan <
[email protected]>
---
eclass/kernel-build.eclass | 115 +++++++++++++++++++++++++++++++++++--
1 file changed, 111 insertions(+), 4 deletions(-)
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index da215a055a467..7634a4445350f 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -1,4 +1,4 @@
-# Copyright 2020-2022 Gentoo Authors
+# Copyright 2020-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: kernel-build.eclass
@@ -41,6 +41,50 @@ BDEPEND="
app-alternatives/yacc
"
+IUSE="+strip"
+
+# @ECLASS_VARIABLE: ALLOW_MODULES_SIGN
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, adds IUSE=modules-sign and required
+# logic to manipulate the kernel config while respecting the
+# MODULES_SIGN_HASH and MODULES_SIGN_KEY user variables.
+
+# @ECLASS_VARIABLE: MODULES_SIGN_HASH
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Used with USE=modules-sign. Can be set