eclass/dist-kernel-utils: Sync with Gentoo

It's from Gentoo commit 9af7e9d11ede9c823e2904a9cf387d5e1286a4d0.
This commit is contained in:
Flatcar Buildbot 2025-01-13 07:07:19 +00:00 committed by Krzesimir Nowak
parent d16d997f43
commit feb865283a

View File

@ -1,4 +1,4 @@
# Copyright 2020-2024 Gentoo Authors
# Copyright 2020-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: dist-kernel-utils.eclass
@ -82,12 +82,33 @@ dist-kernel_install_kernel() {
local success=
# not an actual loop but allows error handling with 'break'
while true; do
if [[ -n ${ROOT} ]] && in_iuse initramfs && use initramfs; then
if ! in_iuse generic-uki || ! use generic-uki; then
eerror
eerror "ROOT is set, and (re-)generation of an initramfs is requested"
eerror "via the USE=initramfs flag. However, this is currently not"
eerror "supported via the sys-kernel/installkernel mechanism."
eerror
if in_iuse generic-uki && ! use generic-uki; then
eerror "Generation and installation of a generic initramfs and/or"
eerror "Unified Kernel Image is possible via portage by enabling the"
eerror "USE=generic-uki flag. Please enable the generic-uki flag, or"
eerror "chroot into: ROOT=${ROOT}"
else
eerror "Please chroot into: ROOT=${ROOT}"
fi
break
fi
fi
nonfatal mount-boot_check_status || break
mkdir -p "${EROOT}/boot" || break
ebegin "Installing the kernel via installkernel"
# note: .config is taken relatively to System.map;
# initrd relatively to bzImage
ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" || break
ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" \
"${EROOT}/boot" || break
eend ${?} || die -n "Installing the kernel failed"
success=1
@ -175,7 +196,8 @@ dist-kernel_get_module_suffix() {
echo .ko
elif [[ ! -r ${config} ]]; then
die "Cannot find kernel config ${config}"
elif grep -q "CONFIG_MODULE_COMPRESS_NONE=y" "${config}"; then
elif grep -q "CONFIG_MODULE_COMPRESS_NONE=y" "${config}" ||
grep -q "# CONFIG_MODULE_COMPRESS is not set" "${config}"; then
echo .ko
elif grep -q "CONFIG_MODULE_COMPRESS_GZIP=y" "${config}"; then
echo .ko.gz