commit:     24aae6dd6e42c19b4e7415b9477621a357648219
Author:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 06:34:46 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 06:34:46 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=24aae6dd

sys-firmware/intel-microcode: avoid mount-boot if ROOT is set

and:
- rdep on iucode_tool for .install hook
- USE=hostonly: iucode_tool is executed in pkg_preinst and should therefore be
an idep instead of a rdep (not that it really makes a functional difference
since it is bdep anyway)
- rework REQUIRED_USE: the *.install hooks require the split-ucode to be
present. Since with USE=dist-kernel, USE=initramfs does not install intel-uc.img
(instead it is delegared to installkernel via the *.install hooks)  we need
always split-ucode with dist-kernel.
- *.install: exit gracefully if no ucode installed

this mirrors recent changes in sys-kernel/linux-firmware

Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../files/35-intel-microcode-systemd.install       | 23 +++++++++++++---------
 .../files/35-intel-microcode.install               | 10 +++++++---
 ...> intel-microcode-20240531_p20240526-r2.ebuild} | 22 ++++++++++++++-------
 3 files changed, 36 insertions(+), 19 deletions(-)

diff --git 
a/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install 
b/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
index 7ad7b8c49e83..58593a675b37 100644
--- a/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
+++ b/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
@@ -35,13 +35,18 @@ opts=(
        --no-downgrade
 )
 
-if [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]]; then
-       echo "Generating Intel CPU Microcode early initramfs image..."
-       opts+=(
-               --list-all
-               --list
-       )
+if [[ -d /lib/firmware/intel-ucode ]]; then
+       if [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]]; then
+               echo "Generating Intel CPU Microcode early initramfs image..."
+               opts+=(
+                       --list-all
+                       --list
+               )
+       fi
+
+       iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
+               { echo "iucode_tool failed" && exit 1; }
+else
+       [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo \
+               "No Intel CPU Microcode installed, nothing to do here."
 fi
-
-iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
-       { echo "iucode_tool failed" && exit 1; }

diff --git a/sys-firmware/intel-microcode/files/35-intel-microcode.install 
b/sys-firmware/intel-microcode/files/35-intel-microcode.install
index d4e9ef19d56b..513b3a84d08e 100644
--- a/sys-firmware/intel-microcode/files/35-intel-microcode.install
+++ b/sys-firmware/intel-microcode/files/35-intel-microcode.install
@@ -41,9 +41,13 @@ main() {
                --list
        )
 
-       einfo "Generating Intel CPU Microcode early initramfs image..."
-       iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
-               die "iucode_tool failed"
+       if [[ -d /lib/firmware/intel-ucode ]]; then
+               einfo "Generating Intel CPU Microcode early initramfs image..."
+               iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
+                       die "iucode_tool failed"
+       else
+               einfo "No Intel CPU Microcode installed, nothing to do here."
+       fi
 }
 
 main

diff --git 
a/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild 
b/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
similarity index 97%
rename from 
sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild
rename to 
sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
index 55f66f30803d..947e22ff9bc2 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
@@ -45,16 +45,24 @@ LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* ~amd64 ~x86"
 IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
-REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
+REQUIRED_USE="
+       || ( initramfs split-ucode )
+       dist-kernel? ( split-ucode )
+"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
 RDEPEND="
-       dist-kernel? ( virtual/dist-kernel )
-       hostonly? ( sys-apps/iucode_tool )
+       dist-kernel? (
+               virtual/dist-kernel
+               initramfs? (
+                       sys-apps/iucode_tool
+               )
+       )
 "
 IDEPEND="
+       hostonly? ( sys-apps/iucode_tool )
        dist-kernel? (
                initramfs? ( sys-kernel/installkernel )
        )
@@ -84,10 +92,10 @@ MICROCODE_SIGNATURES_DEFAULT=""
 
 pkg_pretend() {
        if use initramfs; then
-               if [[ -z ${ROOT} ]] && use dist-kernel; then
+               if use dist-kernel; then
                        # Check, but don't die because we can fix the problem 
and then
                        # emerge --config ... to re-run installation.
-                       nonfatal mount-boot_check_status
+                       [[ -z ${ROOT} ]] && nonfatal mount-boot_check_status
                else
                        mount-boot_pkg_pretend
                fi
@@ -302,8 +310,8 @@ pkg_postrm() {
 
 pkg_postinst() {
        if use initramfs; then
-               if [[ -z ${ROOT} ]] && use dist-kernel; then
-                       dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+               if use dist-kernel; then
+                       [[ -z ${ROOT} ]] && dist-kernel_reinstall_initramfs 
"${KV_DIR}" "${KV_FULL}"
                else
                        # Don't forget to umount /boot if it was previously 
mounted by us.
                        mount-boot_pkg_postinst

Reply via email to