From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH 4/5]: dist-kernel-utils.eclass: optionally sign the kernels
Date: Fri, 14 Jul 2023 10:44:59 +0200 [thread overview]
Message-ID: <7e76519f-b10d-8b0e-81e9-fd34f6c1aa25@gentoo.org> (raw)
From e6d996555a460e9082c6b108fa038b84bf88bcd4 Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Date: Tue, 11 Jul 2023 13:20:12 +0200
Subject: [PATCH 04/13] dist-kernel-utils.eclass: optionally sign the kernels
We put this behind a KERNEL_IUSE_SECUREBOOT var so we can enable this
only if KERNEL_IUSE_MODULES_SIGN is also enabled in kernel-build.eclass
Signed kernel modules is required for the kernel to actually boot with
Secure Boot enabled.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
eclass/dist-kernel-utils.eclass | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/eclass/dist-kernel-utils.eclass
b/eclass/dist-kernel-utils.eclass
index 1ef3104245c6..cb0021f8b3a7 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -12,6 +12,13 @@
# This eclass provides various utility functions related to Distribution
# Kernels.
+# @ECLASS_VARIABLE: KERNEL_IUSE_SECUREBOOT
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-null value, inherits secureboot.eclass
+# and allows signing of generated kernel images.
+
if [[ ! ${_DIST_KERNEL_UTILS} ]]; then
case ${EAPI} in
@@ -19,6 +26,10 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
+if [[ ${KERNEL_IUSE_SECUREBOOT} ]]; then
+ inherit secureboot
+fi
+
# @FUNCTION: dist-kernel_build_initramfs
# @USAGE: <output> <version>
# @DESCRIPTION:
@@ -104,7 +115,7 @@ dist-kernel_install_kernel() {
if [[ ${magic} == MZ ]]; then
einfo "Combined UEFI kernel+initramfs executable found"
# install the combined executable in place of kernel
- image=${initrd}.efi
+ image=${initrd%/*}/uki.efi
mv "${initrd}" "${image}" || die
# We moved the generated initrd, prevent dracut from running again
# https://github.com/dracutdevs/dracut/pull/2405
@@ -122,6 +133,11 @@ dist-kernel_install_kernel() {
export KERNEL_INSTALL_PLUGINS="${KERNEL_INSTALL_PLUGINS} ${plugins[@]}"
fi
+ if [[ ${KERNEL_IUSE_SECUREBOOT} ]]; then
+ # Kernel-install requires uki's are named uki.efi, sign in-place
+ secureboot_sign_efi_file "${image}" "${image}"
+ fi
+
ebegin "Installing the kernel via installkernel"
# note: .config is taken relatively to System.map;
# initrd relatively to bzImage
--
2.41.0
reply other threads:[~2023-07-14 8:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7e76519f-b10d-8b0e-81e9-fd34f6c1aa25@gentoo.org \
--to=andrewammerlaan@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox