diff options
| author | Nowa Ammerlaan <nowa@gentoo.org> | 2024-12-29 21:46:40 +0100 |
|---|---|---|
| committer | Michał Górny <mgorny@gentoo.org> | 2025-01-02 18:08:30 +0100 |
| commit | 9af7e9d11ede9c823e2904a9cf387d5e1286a4d0 (patch) | |
| tree | ba55eef6b9769e5e873a941e7feb7fe484701547 | |
| parent | a9b25945f57ea44213913ed4796582435d011b1a (diff) | |
| download | gentoo-9af7e9d11ede9c823e2904a9cf387d5e1286a4d0.tar.gz gentoo-9af7e9d11ede9c823e2904a9cf387d5e1286a4d0.tar.bz2 gentoo-9af7e9d11ede9c823e2904a9cf387d5e1286a4d0.zip | |
dist-kernel-utils.eclass: implement basic support for install with ROOT
Before this change the kernel installation is silently skipped in all cases.
Using sys-kernel/installkernel to generate an initramfs/uki will indeed be
a huge mess so when an initramfs is requested we now print a helpful error
message. If we do not want an initramfs, or the initramfs/uki was generated
with portage using USE=generic-uki then we can safely try to install the kernel.
Installkernel-50 is capable of dealing with this situation in most cases, but it
will print a bunch of warnings since plugins are skipped. Bootloader
configuration, for example, cannot be updated in this case.
For kernel modules we can also safely make this change, all modules that can be
in the initramfs have the initramfs flag and if it is enabled then we will also
hit this error message.
End result of this change is more verbosity when kernel installation is skipped
and basic support for installing the kernel with --root set for simple
configurations (no initramfs or generic-uki with compat layout or uki layout).
Signed-off-by: Nowa Ammerlaan <nowa@gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/38842
Signed-off-by: Michał Górny <mgorny@gentoo.org>
| -rw-r--r-- | eclass/dist-kernel-utils.eclass | 25 | ||||
| -rw-r--r-- | eclass/kernel-install.eclass | 8 | ||||
| -rw-r--r-- | eclass/linux-mod-r1.eclass | 4 |
3 files changed, 27 insertions, 10 deletions
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 210c586c8c29..3d7315e9e94e 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -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 diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index 5b4f3b096c41..6ca39e551110 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -716,9 +716,7 @@ kernel-install_pkg_postinst() { dist-kernel_compressed_module_cleanup \ "${EROOT}/lib/modules/${KV_FULL}" - if [[ -z ${ROOT} ]]; then - kernel-install_install_all "${KV_FULL}" - fi + kernel-install_install_all "${KV_FULL}" if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && use generic-uki; then ewarn "The prebuilt initramfs and unified kernel image are highly experimental!" @@ -740,7 +738,7 @@ kernel-install_pkg_postinst() { kernel-install_pkg_postrm() { debug-print-function ${FUNCNAME} "$@" - if [[ -z ${ROOT} && ! ${KERNEL_IUSE_GENERIC_UKI} ]]; then + if [[ ! ${KERNEL_IUSE_GENERIC_UKI} ]]; then local kernel_dir=${EROOT}/usr/src/linux-${KV_FULL} local image_path=$(dist-kernel_get_image_path) ebegin "Removing initramfs" @@ -754,8 +752,6 @@ kernel-install_pkg_postrm() { # @DESCRIPTION: # Rebuild the initramfs and reinstall the kernel. kernel-install_pkg_config() { - [[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently" - if [[ -z ${KV_FULL} ]]; then KV_FULL=${PV}${KV_LOCALVERSION} fi diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass index 4e5b17548b04..f6a5d4f187d8 100644 --- a/eclass/linux-mod-r1.eclass +++ b/eclass/linux-mod-r1.eclass @@ -1,4 +1,4 @@ -# Copyright 2023-2024 Gentoo Authors +# Copyright 2023-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: linux-mod-r1.eclass @@ -508,7 +508,7 @@ linux-mod-r1_pkg_postinst() { dist-kernel_compressed_module_cleanup "${EROOT}/lib/modules/${KV_FULL}" _modules_update_depmod - if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] && + if [[ ${MODULES_INITRAMFS_IUSE} ]] && use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+} then dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" |
