mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-01 11:18:09 -07:00
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@gentoo.org>
54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright 2024 Gentoo Authors
|
|
# This script is installed by sys-firmware/intel-microcode, it is executed by
|
|
# the traditional installkernel, NOT by systemd's kernel-install. I.e. this
|
|
# plugin is run when the systemd USE flag is disabled or
|
|
# SYSTEMD_KERNEL_INSTALL=0 is set in the environment.
|
|
|
|
# familiar helpers, we intentionally don't use Gentoo functions.sh
|
|
die() {
|
|
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
|
|
exit 1
|
|
}
|
|
|
|
einfo() {
|
|
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}" >&2
|
|
}
|
|
|
|
main() {
|
|
# re-define for subst to work
|
|
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
|
|
|
|
if [[ ${INSTALLKERNEL_INITRD_GENERATOR} == dracut ]]; then
|
|
# Dracut bundles microcode in its initramfs images
|
|
echo "initrd_generator=${INSTALLKERNEL_INITRD_GENERATOR} bundles CPU microcode, nothing to do here."
|
|
exit 0
|
|
fi
|
|
|
|
# do nothing if somehow iucode_tool is not installed
|
|
[[ -x $(command -v iucode_tool) ]] || die "iucode_tool command not available"
|
|
|
|
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
|
|
|
|
local opts=(
|
|
--write-earlyfw="/boot/intel-uc.img"
|
|
--overwrite
|
|
--strict-checks
|
|
--no-ignore-broken
|
|
--no-downgrade
|
|
--list-all
|
|
--list
|
|
)
|
|
|
|
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
|