public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs
@ 2024-05-14 11:59 Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 2/7] profiles/use.desc: add new global flag "initramfs" Andrew Ammerlaan
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

Adds a new variable that adds the "initramfs" flag when set. This new
flag controls whether or not the modules that were built should be
included in the initramfs. If the modules should be included, then we
also rebuild the initramfs/uki in post_install using installkernel.

Bug: https://bugs.gentoo.org/923025
Bug: https://bugs.gentoo.org/928271
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/linux-mod-r1.eclass | 54 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index 4b267aae4db1..d9651f962604 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -131,6 +131,15 @@ IDEPEND="
 	sys-apps/kmod[tools]
 "
 
+if [[ ${MODULES_INITRAMFS_IUSE} ]]; then
+	IUSE+=" ${MODULES_INITRAMFS_IUSE}"
+	IDEPEND+="
+		${MODULES_INITRAMFS_IUSE#+}? (
+			sys-kernel/installkernel
+		)
+	"
+fi
+
 if [[ -n ${MODULES_OPTIONAL_IUSE} ]]; then
 	: "${MODULES_OPTIONAL_IUSE#+}? ( | )"
 	RDEPEND=${_/|/${RDEPEND}} DEPEND=${_/|/${DEPEND}} \
@@ -179,6 +188,22 @@ fi
 #
 # May want to look at KERNEL_CHOST before considering this.
 
+# @ECLASS_VARIABLE: MODULES_INITRAMFS_IUSE
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# If set, adds the specified USE flag. When this flag is enabled the
+# installed kernel modules are registered for inclusion in the dracut
+# initramfs. Additionally, if distribution kernels are used
+# (USE="dist-kernel") then these kernels are re-installed.
+#
+# The typical recommended value is "initramfs" or "+initramfs" (global
+# IUSE).
+#
+# If MODULES_INITRAMFS_IUSE is not set, or the specified flag is not
+# enabled, then the installed kernel modules are omitted from the
+# dracut initramfs.
+
 # @ECLASS_VARIABLE: MODULES_SIGN_HASH
 # @USER_VARIABLE
 # @DEFAULT_UNSET
@@ -471,6 +496,19 @@ linux-mod-r1_pkg_postinst() {
 	dist-kernel_compressed_module_cleanup "${EROOT}/lib/modules/${KV_FULL}"
 	_modules_update_depmod
 
+	if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] &&
+		use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+}
+	then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+	fi
+
+	if has_version virtual/dist-kernel && ! use dist-kernel; then
+		ewarn "virtual/dist-kernel is installed, but USE=\"dist-kernel\""
+		ewarn "is not enabled for ${CATEGORY}/${PN}."
+		ewarn "It's recommended to globally enable the dist-kernel USE flag"
+		ewarn "to automatically trigger initramfs rebuilds on kernel updates"
+	fi
+
 	# post_process ensures modules were installed and that the eclass' USE
 	# are likely not no-ops (unfortunately postinst itself may be missed)
 	[[ -v _MODULES_GLOBAL[ran:post_process] ]] ||
@@ -550,6 +588,7 @@ modules_post_process() {
 	# which can lead to unnecessarily increased size or stale modules)
 #	_modules_process_depmod.d "${mods[@]#"${path}/"}"
 
+	_modules_process_dracut.conf.d "${mods[@]##*/}"
 	_modules_process_strip "${mods[@]}"
 	_modules_process_sign "${mods[@]}"
 	_modules_sanity_modversion "${mods[@]}" # after strip/sign in case broke it
@@ -904,6 +943,21 @@ _modules_process_depmod.d() {
 	)
 }
 
+# @FUNCTION: _modules_process_dracut.conf.d
+# @USAGE: <module>...
+# @INTERNAL
+# @DESCRIPTION:
+# Create dracut.conf.d snippet defining if module should be included in the
+# initramfs.
+_modules_process_dracut.conf.d() {
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		[[ ${MODULES_INITRAMFS_IUSE} ]] && use ${MODULES_INITRAMFS_IUSE#+} &&
+			: add || : omit
+		newins - 10-${PN}.conf <<<"${_}_drivers+=\" ${*%.ko} \""
+	)
+}
+
 # @FUNCTION: _modules_process_sign
 # @USAGE: <module>...
 # @INTERNAL
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 2/7] profiles/use.desc: add new global flag "initramfs"
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 3/7] sys-fs/zfs-kmod: add USE=initramfs, and enable by default Andrew Ammerlaan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 profiles/use.desc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/use.desc b/profiles/use.desc
index d00e21ff01e2..0b96f6add385 100644
--- a/profiles/use.desc
+++ b/profiles/use.desc
@@ -142,6 +142,7 @@ imagemagick - Enable optional support for the ImageMagick or GraphicsMagick imag
 imap - Add support for IMAP (Internet Mail Application Protocol)
 imlib - Add support for imlib, an image loading and rendering library
 infiniband - Enable Infiniband RDMA transport support
+initramfs - Include kernel modules in the initramfs, and re-install the kernel (only effective for distribution kernels)
 inotify - Enable inotify filesystem monitoring support
 introspection - Add support for GObject based introspection
 iodbc - Add support for iODBC library
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 3/7] sys-fs/zfs-kmod: add USE=initramfs, and enable by default
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 2/7] profiles/use.desc: add new global flag "initramfs" Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 4/7] sys-firmware/intel-microcode: add USE=dist-kernel Andrew Ammerlaan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 sys-fs/zfs-kmod/zfs-kmod-2.1.14.ebuild   | 16 +++-------------
 sys-fs/zfs-kmod/zfs-kmod-2.1.15.ebuild   | 14 ++------------
 sys-fs/zfs-kmod/zfs-kmod-2.2.2-r1.ebuild | 14 ++------------
 sys-fs/zfs-kmod/zfs-kmod-2.2.2.ebuild    | 14 ++------------
 sys-fs/zfs-kmod/zfs-kmod-2.2.3.ebuild    | 14 ++------------
 sys-fs/zfs-kmod/zfs-kmod-2.2.4.ebuild    | 14 ++------------
 sys-fs/zfs-kmod/zfs-kmod-9999.ebuild     | 14 ++------------
 7 files changed, 15 insertions(+), 85 deletions(-)

diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.1.14.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.1.14.ebuild
index c698d195b168..5b5d9f647ee9 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.1.14.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.1.14.ebuild
@@ -1,9 +1,10 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -64,13 +65,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -152,10 +146,6 @@ src_install() {
 pkg_postinst() {
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.1.15.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.1.15.ebuild
index 91038f073b54..b5ce1e2929b3 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.1.15.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.1.15.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -64,13 +65,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -152,10 +146,6 @@ src_install() {
 pkg_postinst() {
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.2.2-r1.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.2.2-r1.ebuild
index 7b28bf3a94ab..6f4cf5107e3f 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.2.2-r1.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.2.2-r1.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -66,13 +67,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -194,10 +188,6 @@ pkg_postinst() {
 
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.2.2.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.2.2.ebuild
index 944c90fac889..b46dea36c184 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.2.2.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.2.2.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -65,13 +66,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -193,10 +187,6 @@ pkg_postinst() {
 
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.2.3.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.2.3.ebuild
index e2c8f5dfec1b..5e595114c70a 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.2.3.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.2.3.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -64,13 +65,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -192,10 +186,6 @@ pkg_postinst() {
 
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.2.4.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.2.4.ebuild
index fe2cc8b18efb..79b2c443b06d 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.2.4.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.2.4.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -64,13 +65,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -192,10 +186,6 @@ pkg_postinst() {
 
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild b/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
index fe2cc8b18efb..79b2c443b06d 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=8
 
-inherit autotools dist-kernel-utils flag-o-matic linux-mod-r1 multiprocessing
+MODULES_INITRAMFS_IUSE=+initramfs
+inherit autotools flag-o-matic linux-mod-r1 multiprocessing
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -64,13 +65,6 @@ PATCHES=(
 
 pkg_pretend() {
 	use rootfs || return 0
-
-	if has_version virtual/dist-kernel && ! use dist-kernel; then
-		ewarn "You have virtual/dist-kernel installed, but"
-		ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
-		ewarn "It's recommended to globally enable dist-kernel USE flag"
-		ewarn "to auto-trigger initrd rebuilds with kernel updates"
-	fi
 }
 
 pkg_setup() {
@@ -192,10 +186,6 @@ pkg_postinst() {
 
 	linux-mod-r1_pkg_postinst
 
-	if [[ -z ${ROOT} ]] && use dist-kernel ; then
-		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
-	fi
-
 	if use x86 || use arm ; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 4/7] sys-firmware/intel-microcode: add USE=dist-kernel
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 2/7] profiles/use.desc: add new global flag "initramfs" Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 3/7] sys-fs/zfs-kmod: add USE=initramfs, and enable by default Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 5/7] sys-kernel/linux-firmware: " Andrew Ammerlaan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

The /boot/intel-uc.img is useless when we use a dist-kernel since dracut is
responsible for generating the initramfs, and it (by default) includes the
microcode.

Instead add USE=dist-kernel and enable USE=initramfs by default. The
initramfs flag toggles the early_microcode setting of dracut, and if both flags
are enabled we trigger initramfs re-installation. This ensures that when we
update this package, we also get the latest microcode in our dist-kernel
initramfs or UKI.

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 .../intel-microcode-20221108_p20221102.ebuild | 43 ++++++++++++++-----
 .../intel-microcode-20230214_p20230212.ebuild | 41 ++++++++++++++----
 .../intel-microcode-20230512_p20230512.ebuild | 41 ++++++++++++++----
 .../intel-microcode-20230613_p20230520.ebuild | 40 +++++++++++++----
 .../intel-microcode-20230808_p20230804.ebuild | 40 +++++++++++++----
 .../intel-microcode-20230808_p20231007.ebuild | 40 +++++++++++++----
 .../intel-microcode-20231114_p20231114.ebuild | 40 +++++++++++++----
 .../intel-microcode-20240312_p20240312.ebuild | 38 +++++++++++++---
 8 files changed, 256 insertions(+), 67 deletions(-)

diff --git a/sys-firmware/intel-microcode/intel-microcode-20221108_p20221102.ebuild b/sys-firmware/intel-microcode/intel-microcode-20221108_p20221102.ebuild
index 006f4811618a..a8cf0d39ff33 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20221108_p20221102.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20221108_p20221102.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="7"
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -23,13 +23,20 @@ SRC_URI="https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/arc
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
-
-BDEPEND=">=sys-apps/iucode_tool-2.3"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 
+BDEPEND="
+	>=sys-apps/iucode_tool-2.3
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
 
 RESTRICT="binchecks strip"
 
@@ -132,9 +139,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -188,7 +204,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -259,7 +277,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20230214_p20230212.ebuild b/sys-firmware/intel-microcode/intel-microcode-20230214_p20230212.ebuild
index d0d809679e8d..2602f9f0e3ea 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20230214_p20230212.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20230214_p20230212.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -23,13 +23,20 @@ SRC_URI="https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/arc
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
-
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 RESTRICT="binchecks strip"
 
@@ -132,9 +139,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -188,7 +204,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -259,7 +277,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20230512_p20230512.ebuild b/sys-firmware/intel-microcode/intel-microcode-20230512_p20230512.ebuild
index d0d809679e8d..2602f9f0e3ea 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20230512_p20230512.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20230512_p20230512.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -23,13 +23,20 @@ SRC_URI="https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/arc
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
-
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 RESTRICT="binchecks strip"
 
@@ -132,9 +139,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -188,7 +204,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -259,7 +277,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20230613_p20230520.ebuild b/sys-firmware/intel-microcode/intel-microcode-20230613_p20230520.ebuild
index 5d1ff1e7f4be..957da662f92e 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20230613_p20230520.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20230613_p20230520.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -44,13 +44,21 @@ S="${WORKDIR}"
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 # Blacklist bad microcode here.
 # 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
@@ -138,9 +146,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -194,7 +211,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -265,7 +284,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20230808_p20230804.ebuild b/sys-firmware/intel-microcode/intel-microcode-20230808_p20230804.ebuild
index 5d1ff1e7f4be..957da662f92e 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20230808_p20230804.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20230808_p20230804.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -44,13 +44,21 @@ S="${WORKDIR}"
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 # Blacklist bad microcode here.
 # 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
@@ -138,9 +146,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -194,7 +211,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -265,7 +284,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20230808_p20231007.ebuild b/sys-firmware/intel-microcode/intel-microcode-20230808_p20231007.ebuild
index 5d1ff1e7f4be..957da662f92e 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20230808_p20231007.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20230808_p20231007.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -44,13 +44,21 @@ S="${WORKDIR}"
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 # Blacklist bad microcode here.
 # 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
@@ -138,9 +146,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -194,7 +211,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -265,7 +284,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20231114_p20231114.ebuild b/sys-firmware/intel-microcode/intel-microcode-20231114_p20231114.ebuild
index 5d1ff1e7f4be..957da662f92e 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20231114_p20231114.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20231114_p20231114.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -44,13 +44,21 @@ S="${WORKDIR}"
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 # Blacklist bad microcode here.
 # 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
@@ -138,9 +146,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -194,7 +211,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -265,7 +284,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
diff --git a/sys-firmware/intel-microcode/intel-microcode-20240312_p20240312.ebuild b/sys-firmware/intel-microcode/intel-microcode-20240312_p20240312.ebuild
index 5992eadefd5f..957da662f92e 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20240312_p20240312.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20240312_p20240312.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit linux-info mount-boot
+inherit dist-kernel-utils linux-info mount-boot
 
 # Find updates by searching and clicking the first link (hopefully it's the one):
 # https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
@@ -44,13 +44,21 @@ S="${WORKDIR}"
 LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* amd64 x86"
-IUSE="hostonly initramfs +split-ucode vanilla"
-REQUIRED_USE="|| ( initramfs split-ucode )"
+IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
+REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
-RDEPEND="hostonly? ( sys-apps/iucode_tool )"
+RDEPEND="
+	dist-kernel? ( virtual/dist-kernel )
+	hostonly? ( sys-apps/iucode_tool )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 # Blacklist bad microcode here.
 # 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
@@ -138,9 +146,18 @@ src_install() {
 		--list
 	)
 
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	# Use here 15 instead of 10, intel-microcode overwrites linux-firmware
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 15-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
 	# The earlyfw cpio needs to be in /boot because it must be loaded before
 	# rootfs is mounted.
-	use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	if ! use dist-kernel && use initramfs; then
+		dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
+	fi
 
 	keepdir /lib/firmware/intel-ucode
 	opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -194,7 +211,9 @@ pkg_preinst() {
 
 		# The earlyfw cpio needs to be in /boot because it must be loaded before
 		# rootfs is mounted.
-		use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
+		if ! use dist-kernel && use initramfs; then
+			opts+=( --write-earlyfw=${_initramfs_file} )
+		fi
 
 		if use split-ucode; then
 			opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
@@ -265,7 +284,12 @@ pkg_postrm() {
 
 pkg_postinst() {
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 
 	# We cannot give detailed information if user is affected or not:
 	# If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 5/7] sys-kernel/linux-firmware: add USE=dist-kernel
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
                   ` (2 preceding siblings ...)
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 4/7] sys-firmware/intel-microcode: add USE=dist-kernel Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs Andrew Ammerlaan
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 7/7] linux-mod-r1.eclass: do not reset kernel env vars " Andrew Ammerlaan
  5 siblings, 0 replies; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

The /boot/amd-ucode is useless when we use a dist-kernel since dracut is
responsible for generating the initramfs, and it (by default) includes the
microcode.

Instead add USE=dist-kernel and enable USE=initramfs by default. The
initramfs flag toggles the early_microcode setting of dracut, and if both flags
are enabled we trigger initramfs re-installation. This ensures that when we
update this package, we also get the latest microcode in our dist-kernel
initramfs or UKI.

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 .../linux-firmware-20240220-r2.ebuild         | 32 +++++++++++++++----
 .../linux-firmware-20240312.ebuild            | 32 +++++++++++++++----
 .../linux-firmware-20240410.ebuild            | 32 +++++++++++++++----
 .../linux-firmware-99999999.ebuild            | 32 +++++++++++++++----
 4 files changed, 100 insertions(+), 28 deletions(-)

diff --git a/sys-kernel/linux-firmware/linux-firmware-20240220-r2.ebuild b/sys-kernel/linux-firmware/linux-firmware-20240220-r2.ebuild
index 8ea7565f00ce..0ecca9dae446 100644
--- a/sys-kernel/linux-firmware/linux-firmware-20240220-r2.ebuild
+++ b/sys-kernel/linux-firmware/linux-firmware-20240220-r2.ebuild
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
-inherit linux-info mount-boot savedconfig multiprocessing
+inherit dist-kernel-utils linux-info mount-boot savedconfig multiprocessing
 
 # In case this is a real snapshot, fill in commit below.
 # For normal, tagged releases, leave blank
@@ -29,7 +29,7 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
 	redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
 	unknown-license? ( all-rights-reserved )"
 SLOT="0"
-IUSE="bindist compress-xz compress-zstd deduplicate initramfs +redistributable savedconfig unknown-license"
+IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable savedconfig unknown-license"
 REQUIRED_USE="initramfs? ( redistributable )
 	?? ( compress-xz compress-zstd )
 	savedconfig? ( !deduplicate )"
@@ -62,7 +62,14 @@ RDEPEND="!savedconfig? (
 			!sys-firmware/alsa-firmware[alsa_cards_sb16]
 			!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
 		)
-	)"
+	)
+	dist-kernel? ( virtual/dist-kernel )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 QA_PREBUILT="*"
 PATCHES=( "${FILESDIR}"/${PN}-copy-firmware-r4.patch )
@@ -84,8 +91,8 @@ pkg_setup() {
 				eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
 			fi
 		fi
-		linux-info_pkg_setup
 	fi
+	linux-info_pkg_setup
 }
 
 src_unpack() {
@@ -110,7 +117,7 @@ src_prepare() {
 
 	chmod +x copy-firmware.sh || die
 
-	if use initramfs; then
+	if use initramfs && ! use dist-kernel; then
 		if [[ -d "${S}/amd-ucode" ]]; then
 			local UCODETMP="${T}/ucode_tmp"
 			local UCODEDIR="${UCODETMP}/kernel/x86/microcode"
@@ -351,7 +358,13 @@ src_install() {
 
 	popd &>/dev/null || die
 
-	if use initramfs ; then
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 10-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
+	if use initramfs && ! use dist-kernel; then
 		insinto /boot
 		doins "${S}"/amd-uc.img
 	fi
@@ -391,7 +404,12 @@ pkg_postinst() {
 	done
 
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 }
 
 pkg_prerm() {
diff --git a/sys-kernel/linux-firmware/linux-firmware-20240312.ebuild b/sys-kernel/linux-firmware/linux-firmware-20240312.ebuild
index 8795fc72fda3..2481f3a517f0 100644
--- a/sys-kernel/linux-firmware/linux-firmware-20240312.ebuild
+++ b/sys-kernel/linux-firmware/linux-firmware-20240312.ebuild
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
-inherit linux-info mount-boot savedconfig multiprocessing
+inherit dist-kernel-utils linux-info mount-boot savedconfig multiprocessing
 
 # In case this is a real snapshot, fill in commit below.
 # For normal, tagged releases, leave blank
@@ -29,7 +29,7 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
 	redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
 	unknown-license? ( all-rights-reserved )"
 SLOT="0"
-IUSE="bindist compress-xz compress-zstd deduplicate initramfs +redistributable savedconfig unknown-license"
+IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable savedconfig unknown-license"
 REQUIRED_USE="initramfs? ( redistributable )
 	?? ( compress-xz compress-zstd )
 	savedconfig? ( !deduplicate )"
@@ -62,7 +62,14 @@ RDEPEND="!savedconfig? (
 			!sys-firmware/alsa-firmware[alsa_cards_sb16]
 			!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
 		)
-	)"
+	)
+	dist-kernel? ( virtual/dist-kernel )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 QA_PREBUILT="*"
 PATCHES=( "${FILESDIR}"/${PN}-copy-firmware-r4.patch )
@@ -84,8 +91,8 @@ pkg_setup() {
 				eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
 			fi
 		fi
-		linux-info_pkg_setup
 	fi
+	linux-info_pkg_setup
 }
 
 src_unpack() {
@@ -110,7 +117,7 @@ src_prepare() {
 
 	chmod +x copy-firmware.sh || die
 
-	if use initramfs; then
+	if use initramfs && ! use dist-kernel; then
 		if [[ -d "${S}/amd-ucode" ]]; then
 			local UCODETMP="${T}/ucode_tmp"
 			local UCODEDIR="${UCODETMP}/kernel/x86/microcode"
@@ -351,7 +358,13 @@ src_install() {
 
 	popd &>/dev/null || die
 
-	if use initramfs ; then
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 10-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
+	if use initramfs && ! use dist-kernel; then
 		insinto /boot
 		doins "${S}"/amd-uc.img
 	fi
@@ -391,7 +404,12 @@ pkg_postinst() {
 	done
 
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 }
 
 pkg_prerm() {
diff --git a/sys-kernel/linux-firmware/linux-firmware-20240410.ebuild b/sys-kernel/linux-firmware/linux-firmware-20240410.ebuild
index 8795fc72fda3..2481f3a517f0 100644
--- a/sys-kernel/linux-firmware/linux-firmware-20240410.ebuild
+++ b/sys-kernel/linux-firmware/linux-firmware-20240410.ebuild
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
-inherit linux-info mount-boot savedconfig multiprocessing
+inherit dist-kernel-utils linux-info mount-boot savedconfig multiprocessing
 
 # In case this is a real snapshot, fill in commit below.
 # For normal, tagged releases, leave blank
@@ -29,7 +29,7 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
 	redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
 	unknown-license? ( all-rights-reserved )"
 SLOT="0"
-IUSE="bindist compress-xz compress-zstd deduplicate initramfs +redistributable savedconfig unknown-license"
+IUSE="bindist compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable savedconfig unknown-license"
 REQUIRED_USE="initramfs? ( redistributable )
 	?? ( compress-xz compress-zstd )
 	savedconfig? ( !deduplicate )"
@@ -62,7 +62,14 @@ RDEPEND="!savedconfig? (
 			!sys-firmware/alsa-firmware[alsa_cards_sb16]
 			!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
 		)
-	)"
+	)
+	dist-kernel? ( virtual/dist-kernel )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 QA_PREBUILT="*"
 PATCHES=( "${FILESDIR}"/${PN}-copy-firmware-r4.patch )
@@ -84,8 +91,8 @@ pkg_setup() {
 				eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
 			fi
 		fi
-		linux-info_pkg_setup
 	fi
+	linux-info_pkg_setup
 }
 
 src_unpack() {
@@ -110,7 +117,7 @@ src_prepare() {
 
 	chmod +x copy-firmware.sh || die
 
-	if use initramfs; then
+	if use initramfs && ! use dist-kernel; then
 		if [[ -d "${S}/amd-ucode" ]]; then
 			local UCODETMP="${T}/ucode_tmp"
 			local UCODEDIR="${UCODETMP}/kernel/x86/microcode"
@@ -351,7 +358,13 @@ src_install() {
 
 	popd &>/dev/null || die
 
-	if use initramfs ; then
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 10-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
+	if use initramfs && ! use dist-kernel; then
 		insinto /boot
 		doins "${S}"/amd-uc.img
 	fi
@@ -391,7 +404,12 @@ pkg_postinst() {
 	done
 
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 }
 
 pkg_prerm() {
diff --git a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild
index e3f5246a89a3..01ae250624ed 100644
--- a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild
+++ b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
-inherit linux-info mount-boot savedconfig multiprocessing
+inherit dist-kernel-utils linux-info mount-boot savedconfig multiprocessing
 
 # In case this is a real snapshot, fill in commit below.
 # For normal, tagged releases, leave blank
@@ -29,7 +29,7 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
 	redistributable? ( linux-fw-redistributable BSD-2 BSD BSD-4 ISC MIT )
 	unknown-license? ( all-rights-reserved )"
 SLOT="0"
-IUSE="compress-xz compress-zstd deduplicate initramfs +redistributable savedconfig unknown-license"
+IUSE="compress-xz compress-zstd deduplicate dist-kernel +initramfs +redistributable savedconfig unknown-license"
 REQUIRED_USE="initramfs? ( redistributable )
 	?? ( compress-xz compress-zstd )
 	savedconfig? ( !deduplicate )"
@@ -61,7 +61,14 @@ RDEPEND="!savedconfig? (
 			!sys-firmware/alsa-firmware[alsa_cards_sb16]
 			!sys-firmware/alsa-firmware[alsa_cards_ymfpci]
 		)
-	)"
+	)
+	dist-kernel? ( virtual/dist-kernel )
+"
+IDEPEND="
+	dist-kernel? (
+		initramfs? ( sys-kernel/installkernel )
+	)
+"
 
 QA_PREBUILT="*"
 
@@ -78,8 +85,8 @@ pkg_setup() {
 				eerror "Kernels <5.19 do not support ZSTD-compressed firmware files"
 			fi
 		fi
-		linux-info_pkg_setup
 	fi
+	linux-info_pkg_setup
 }
 
 pkg_pretend() {
@@ -107,7 +114,7 @@ src_prepare() {
 
 	chmod +x copy-firmware.sh || die
 
-	if use initramfs; then
+	if use initramfs && ! use dist-kernel; then
 		if [[ -d "${S}/amd-ucode" ]]; then
 			local UCODETMP="${T}/ucode_tmp"
 			local UCODEDIR="${UCODETMP}/kernel/x86/microcode"
@@ -355,7 +362,13 @@ src_install() {
 
 	popd &>/dev/null || die
 
-	if use initramfs ; then
+	# Instruct Dracut on whether or not we want the microcode in initramfs
+	(
+		insinto /usr/lib/dracut/dracut.conf.d
+		newins - 10-${PN}.conf <<<"early_microcode=$(usex initramfs)"
+	)
+
+	if use initramfs && ! use dist-kernel; then
 		insinto /boot
 		doins "${S}"/amd-uc.img
 	fi
@@ -391,7 +404,12 @@ pkg_postinst() {
 	done
 
 	# Don't forget to umount /boot if it was previously mounted by us.
-	use initramfs && mount-boot_pkg_postinst
+	if use initramfs; then
+		if [[ -z ${ROOT} ]] && use dist-kernel; then
+			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		fi
+		mount-boot_pkg_postinst
+	fi
 }
 
 pkg_prerm() {
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
                   ` (3 preceding siblings ...)
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 5/7] sys-kernel/linux-firmware: " Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-15 16:02   ` Mike Gilbert
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 7/7] linux-mod-r1.eclass: do not reset kernel env vars " Andrew Ammerlaan
  5 siblings, 1 reply; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

Commit f51cd5b64c14ddfb83488a12d538c66a4a309376 resets kernel environment
variables when binpkgs are merged, this makes sense since we care about the
system that the binpkg will be installed on, not the system the binpkg was
built on. This introduced Bug 931213 as a side-effect, which will be fixed
in a separate commit to linux-mod-r1.eclass. In preparation of that, we document
and rename the LINUX_INFO_BINARY_RESET to SKIP_KERNEL_BINPKG_ENV_RESET.

However, commit f51cd5b64c14ddfb83488a12d538c66a4a309376 also makes binpkgs
always use the running kernel version. This behaviour is surprising and
confusing. In principle the 'eselect kernel' setting should still be respected
when binpkgs are used.

Bug: https://bugs.gentoo.org/926063
Bug: https://bugs.gentoo.org/931213
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/linux-info.eclass | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass
index 864594f607ca..9449a6359d2a 100644
--- a/eclass/linux-info.eclass
+++ b/eclass/linux-info.eclass
@@ -158,6 +158,14 @@ KERNEL_DIR="${KERNEL_DIR:-${ROOT%/}/usr/src/linux}"
 # This is a user flag and should under _no circumstances_ be set in the ebuild.
 : "${SKIP_KERNEL_CHECK:=""}"
 
+# @ECLASS_VARIABLE: SKIP_KERNEL_BINPKG_ENV_RESET
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set, do not reset the kernel environment variables when merging a package
+# as a binpkg.
+# Main use-case is for kernel modules, i.e. linux-mod-r1.eclass.
+# This should be set before running linux-info_pkg_setup
+
 # And to ensure all the weirdness with crosscompile
 inherit toolchain-funcs
 [[ ${EAPI} == 6 ]] && inherit eapi7-ver
@@ -696,12 +704,12 @@ linux-info_get_any_version() {
 		die "${FUNCNAME}() called on non-Linux system, please fix the ebuild"
 	fi
 
-	if [[ ${MERGE_TYPE} == binary && -z ${LINUX_INFO_BINARY_RESET} ]]; then
+	if [[ ${MERGE_TYPE} == binary && -z ${SKIP_KERNEL_BINPKG_ENV_RESET} ]]; then
 		unset KV_FULL _LINUX_CONFIG_EXISTS_DONE KV_OUT_DIR
-		LINUX_INFO_BINARY_RESET=1
+		SKIP_KERNEL_BINPKG_ENV_RESET=1
 	fi
 
-	if [[ ${MERGE_TYPE} != binary ]] && ! get_version; then
+	if ! get_version; then
 		ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
 	fi
 
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 7/7] linux-mod-r1.eclass: do not reset kernel env vars in binpkgs
  2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
                   ` (4 preceding siblings ...)
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs Andrew Ammerlaan
@ 2024-05-14 11:59 ` Andrew Ammerlaan
  2024-05-14 12:02   ` [gentoo-dev] [PATCH 0/7] Changes to dracut kernel module/microcode handling Andrew Nowa Ammerlaan
  5 siblings, 1 reply; 9+ messages in thread
From: Andrew Ammerlaan @ 2024-05-14 11:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

Closes: https://bugs.gentoo.org/931213
Bug: https://bugs.gentoo.org/926063
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/linux-mod-r1.eclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index d9651f962604..6060074d8734 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -661,6 +661,11 @@ _modules_check_migration() {
 # Handles linux-info bits to provide usable sources, KV_ variables,
 # and CONFIG_CHECK use.
 _modules_prepare_kernel() {
+	# The modules we build are specific to each kernel version, we don't
+	# want to reset the environment to use the user selected kernel version.
+	# Bug 931213, 926063
+	SKIP_KERNEL_BINPKG_ENV_RESET=1
+
 	get_version
 
 	# linux-info allows skipping checks if SKIP_KERNEL_CHECK is set and
-- 
2.45.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [gentoo-dev] [PATCH 0/7] Changes to dracut kernel module/microcode handling
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 7/7] linux-mod-r1.eclass: do not reset kernel env vars " Andrew Ammerlaan
@ 2024-05-14 12:02   ` Andrew Nowa Ammerlaan
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Nowa Ammerlaan @ 2024-05-14 12:02 UTC (permalink / raw)
  To: gentoo-dev, pr

Hi all,

This patch series essential moves the dist-kernel initramfs/UKI 
rebuilding out off zfs-kmod.ebuild and into linux-mod-r1.eclass.

In the process we fix several issues:
- zfs-kmod.ebuild binpkgs no longer rebuild currently running kernel, 
but uses instead the kernel version that matches the version the modules 
were built for (Bug 931213, commit 1,2,3,6,7).
- zfs.ebuild binpkgs no longer rebuild currently running kernel, but use 
the eselected kernel instead (commit 6,7). In most "normal" cases the 
eselected kernel version will match the kernel version zfs-kmod modules 
were built for due to the slot operator on the virtual/dist-kernel 
dependency in both ebuilds, and the automatic adjustments of the 
/usr/src/linux symlink when dist-kernels are used. (TODO: consider 
merging the zfs and zfs-kmod ebuilds to make this 100% robust).
- Which modules are and which ones are not included in the Dracut 
generated initramfs is now properly defined and won't change after 
random dist-kernel reinstallations (commit 1,2).
- As a result of the above, Dracut's "--reproducible" setting actually 
makes something that is reproducible (apart from package upgrades and 
configuration changes of course).
- It is now super easy for kernel module package maintainers to define 
that a module can be included in the initramfs, USE flags and 
(initramfs/UKI) rebuilds are taken care off by the eclass (commits 1,2)
- We mirror the changes to the kernel modules in the packages that 
install CPU microcode (linux-firmware and intel-microcode) by 
introducing the "dist-kernel" flag there which alters the behaviour of 
the "initramfs" flag to instead configure Dracut to include the 
microcode and then rebuild the Dracut initramfs/UKI. This ensures that 
microcode updates are always propagated into the initramfs. (commits 4,5)

Most users will not have to do anything, we are only setting defaults in 
/usr/lib/dracut/dracut.conf.d, the (existing) user configuration in 
/etc/dracut.conf.d takes precedence. Nonetheless, I wrote a news item to 
accompany these changes, users should ensure that they do not 
unintentionally overwrite USE=initramfs, and they may also want to get 
rid of custom configuration/workarounds they have set in /etc/dracut.conf.

Best regards,
Andrew


Title: Changes to dracut kernel module/microcode handling
Author: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Posted: 2024-05-10
Revision: 1
News-Item-Format: 2.0
Display-If-Installed: sys-kernel/dracut
Display-If-Installed: virtual/dist-kernel
Display-If-Installed: sys-kernel/linux-firmware
Display-If-Installed: sys-firmware/intel-microcode


Impact
====================

Several changes were made regarding out-of-tree kernel modules, CPU
microcode, and how these are handled in initial RAM file systems
(initramfs) generated by sys-kernel/dracut for distribution kernels.
Depending on the local Dracut and USE flag configuration, some
configuration adjustments may be required as a result of these changes.

Background (the problem)
====================

Previously Dracut implicitly included all out-of-tree kernel modules
it could find. This leads to several problems:
- It unnecessarily increases the size of the initramfs
- It creates a bit of a mess when using distribution kernels, consider
	the following:
		1) Distribution kernel is upgraded
		2) Initramfs for the new kernel is generated, it does not include
			any out-of-tree kernel modules.
		3) Portage triggers rebuild of the out-of-tree kernel modules
		4) If zfs is installed, its rebuild will trigger an initramfs
			re-installation. Otherwise no rebuild is triggered.
	Problem: What is and is not included in the initramfs is now
	ambiguous. It depends on the emerge order of the kernel modules
	when zfs is used. And will completely change if at some later stage
	regeneration of the initramfs is triggered manually via e.g.:
		emerge --config sys-kernel/gentoo-kernel
	As a result, Dracut's "--reproducible" setting is not working. And
	the functionality of the initramfs may change (seemingly) at random.

Background (the fix)
====================

Several things have been changed:
- Out-of-tree kernel modules installed by portage are explicitly omitted
	from the initramfs generated by Dracut by default.
- Packages that install a kernel module for which it might make sense to
	have it in the initramfs, have gained the "initramfs" USE flag. When
	this flag is enabled, Dracut is instructed to include the installed
	kernel modules. Packages for which it is essential that its kernel
	modules are included in the initramfs have this new flag enabled
	by default.
- When distribution kernels are used (USE=dist-kernel), and a module
	that should be in the initramfs is installed (USE=initramfs) the
	initramfs is always re-generated.
- The packages installing CPU microcode (sys-kernel/linux-firmware
	and sys-firmware/intel-microcode) have been adjusted to mirror the
	above changes for out-of-tree kernel modules. Both packages
	have gained the "dist-kernel" USE flag, and the "initramfs" flag is
	now enabled by default. When both flags are enabled, Dracut is
	configured to include the installed microcode in the initramfs, and
	then the initramfs is regenerated. When the "dist-kernel" flag is
	disabled, the "initramfs" flag behaves as it previously did.

User Action Required
====================

Users should double check two things:
1) Please ensure that you are *not* globally enabling or disabling
	the "initramfs" USE flag. Enabling it globally might result in an
	unnecessarily large initramfs. Disabling it globally might result
	in missing functionality in the initramfs. Which could lead to boot
	failure if, for example, the zfs module is missing while the root
	partition is a zfs.
2) Any add_drivers, or omit_drivers lines in /etc/dracut.conf or
	/etc/dracut.conf.d/* may override the Dracut configuration snippets
	installed by the kernel module packages in
	/usr/lib/dracut/dracut.conf.d.  Please review your Dracut
	configuration files to ensure that you are not unintentionally
	overriding the settings set by Portage.

Frequently Asked Questions
====================

A package installing a kernel module I would like in my initramfs has
not gained the "initramfs" USE flag. How do I proceed?

	Please report a new bug on bugs.gentoo.org, requesting that the
	package maintainer consider adding support to the package for
	including the modules in the initramfs. In the meantime you can
	locally override the configuration provided by the package (see
	below). Note though that when distribution kernels are used,
	regeneration of the initramfs must be triggered manually via e.g.:
		emerge --config sys-kernel/gentoo-kernel

How do I override the provided Dracut configuration snippets to
include/exclude a custom list of modules?

	To override the provided configuration snippet, create a new file
	/etc/dracut.conf.d/10-PACKAGENAME.conf, replacing PACKAGENAME with
	the name of the package providing the module. Add to this file:
		omit_drivers+=" my list of drivers to omit "
	and/or
		add_drivers+=" my list of drivers to include "


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs
  2024-05-14 11:59 ` [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs Andrew Ammerlaan
@ 2024-05-15 16:02   ` Mike Gilbert
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Gilbert @ 2024-05-15 16:02 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Andrew Ammerlaan

On Tue, May 14, 2024 at 7:59 AM Andrew Ammerlaan
<andrewammerlaan@gentoo.org> wrote:
> Commit f51cd5b64c14ddfb83488a12d538c66a4a309376 resets kernel environment
> variables when binpkgs are merged, this makes sense since we care about the
> system that the binpkg will be installed on, not the system the binpkg was
> built on. This introduced Bug 931213 as a side-effect, which will be fixed
> in a separate commit to linux-mod-r1.eclass. In preparation of that, we document
> and rename the LINUX_INFO_BINARY_RESET to SKIP_KERNEL_BINPKG_ENV_RESET.
>
> However, commit f51cd5b64c14ddfb83488a12d538c66a4a309376 also makes binpkgs
> always use the running kernel version. This behaviour is surprising and
> confusing. In principle the 'eselect kernel' setting should still be respected
> when binpkgs are used.

Seems reasonable to me as the author of
f51cd5b64c14ddfb83488a12d538c66a4a309376.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-05-15 16:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 11:59 [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Andrew Ammerlaan
2024-05-14 11:59 ` [gentoo-dev] [PATCH 2/7] profiles/use.desc: add new global flag "initramfs" Andrew Ammerlaan
2024-05-14 11:59 ` [gentoo-dev] [PATCH 3/7] sys-fs/zfs-kmod: add USE=initramfs, and enable by default Andrew Ammerlaan
2024-05-14 11:59 ` [gentoo-dev] [PATCH 4/7] sys-firmware/intel-microcode: add USE=dist-kernel Andrew Ammerlaan
2024-05-14 11:59 ` [gentoo-dev] [PATCH 5/7] sys-kernel/linux-firmware: " Andrew Ammerlaan
2024-05-14 11:59 ` [gentoo-dev] [PATCH 6/7] linux-info.eclass: respect eselect kernel setting in binpkgs Andrew Ammerlaan
2024-05-15 16:02   ` Mike Gilbert
2024-05-14 11:59 ` [gentoo-dev] [PATCH 7/7] linux-mod-r1.eclass: do not reset kernel env vars " Andrew Ammerlaan
2024-05-14 12:02   ` [gentoo-dev] [PATCH 0/7] Changes to dracut kernel module/microcode handling Andrew Nowa Ammerlaan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox