From: Andrew Nowa Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] [PATCH 2/5] kernel-install.eclass: move mount-boot check to, dist-kernel-utils.eclass
Date: Wed, 26 Jun 2024 22:07:27 +0200 [thread overview]
Message-ID: <d27e11c9-8212-48bc-9581-9d537705095b@gentoo.org> (raw)
In-Reply-To: <476674df-a57c-4c4d-ad1e-487211a4daf0@gentoo.org>
From c4c5ef732670f8b23f20b1215af49cdceacd28a3 Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Date: Tue, 25 Jun 2024 16:12:39 +0200
Subject: [PATCH] kernel-install.eclass: move mount-boot check to
dist-kernel-utils.eclass
ebuilds and eclasses using dist-kernel_reinstall_initramfs should also
have the check for mounted /boot and ESP. We can do this safely via
mount-boot-utils.eclass which does not export any phases.
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
eclass/dist-kernel-utils.eclass | 41 +++++++++++++++++++++++++++-----
eclass/kernel-install.eclass | 42 +++++++--------------------------
2 files changed, 43 insertions(+), 40 deletions(-)
diff --git a/eclass/dist-kernel-utils.eclass
b/eclass/dist-kernel-utils.eclass
index 13137f8c863c8..b357cfe6d228c 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -26,7 +26,7 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-inherit toolchain-funcs
+inherit mount-boot-utils toolchain-funcs
# @FUNCTION: dist-kernel_get_image_path
# @DESCRIPTION:
@@ -79,11 +79,40 @@ dist-kernel_install_kernel() {
local image=${2}
local map=${3}
- 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}"
- eend ${?} || die -n "Installing the kernel failed"
+ local success=
+ # not an actual loop but allows error handling with 'break'
+ while :; do
+ nonfatal mount-boot_check_status || 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
+ eend ${?} || die -n "Installing the kernel failed"
+
+ success=1
+ break
+ done
+
+ if [[ ! ${success} ]]; then
+ # Try to read dist-kernel identifier to more accurately instruct users
+ local kernel
+ local k_id_file=${image%$(dist-kernel_get_image_path)}/dist-kernel
+ if [[ -f ${k_id_file} ]]; then
+ kernel=\'\=$(<${k_id_file})\'
+ else
+ # Fallback string if identifier is not found
+ kernel="<name of your kernel pakcage>:<kernel version>"
+ fi
+
+ eerror
+ eerror "The kernel was not deployed successfully. Inspect the failure"
+ eerror "in the logs above and once you resolve the problems please"
+ eerror "run the equivalent of the following command to try again:"
+ eerror
+ eerror " emerge --config ${kernel}"
+ die "Kernel install failed, please fix the problems and run emerge
--config"
+ fi
}
# @FUNCTION: dist-kernel_reinstall_initramfs
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index f512d815fe098..a572597bc6fa3 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -18,8 +18,6 @@
# location and System.map.
#
# The eclass exports src_test, pkg_postinst and pkg_postrm.
-# Additionally, the inherited mount-boot eclass exports pkg_pretend.
-# It also stubs out pkg_preinst and pkg_prerm defined by mount-boot.
# @ECLASS_VARIABLE: KERNEL_IUSE_GENERIC_UKI
# @PRE_INHERIT
@@ -50,7 +48,7 @@ case ${EAPI} in
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-inherit dist-kernel-utils mount-boot multiprocessing toolchain-funcs
+inherit dist-kernel-utils mount-boot-utils multiprocessing toolchain-funcs
SLOT="${PV}"
IUSE="+initramfs test"
@@ -526,6 +524,10 @@ kernel-install_test() {
kernel-install_pkg_pretend() {
debug-print-function ${FUNCNAME} "${@}"
+ # Check, but don't die because we can fix the problem and then
+ # emerge --config ... to re-run installation.
+ nonfatal mount-boot_check_status
+
if ! has_version -d sys-kernel/linux-firmware; then
ewarn "sys-kernel/linux-firmware not found installed on your system."
ewarn "This package provides various firmware files that may be needed"
@@ -665,27 +667,8 @@ kernel-install_install_all() {
fi
fi
- local success=
- # not an actual loop but allows error handling with 'break'
- while :; do
- nonfatal mount-boot_check_status || break
-
- nonfatal dist-kernel_install_kernel "${module_ver}" \
- "${kernel_dir}/${image_path}" "${kernel_dir}/System.map" || break
-
- success=1
- break
- done
-
- if [[ ! ${success} ]]; then
- eerror
- eerror "The kernel files were copied to disk successfully but the kernel"
- eerror "was not deployed successfully. Once you resolve the problems,"
- eerror "please run the equivalent of the following command to try again:"
- eerror
- eerror " emerge --config ${CATEGORY}/${PN}:${SLOT}"
- die "Kernel install failed, please fix the problems and run emerge
--config ${CATEGORY}/${PN}:${SLOT}"
- fi
+ dist-kernel_install_kernel "${module_ver}" "${kernel_dir}/${image_path}" \
+ "${kernel_dir}/System.map"
}
# @FUNCTION: kernel-install_pkg_postinst
@@ -718,15 +701,6 @@ kernel-install_pkg_postinst() {
fi
}
-# @FUNCTION: kernel-install_pkg_prerm
-# @DESCRIPTION:
-# Stub out mount-boot.eclass.
-kernel-install_pkg_prerm() {
- debug-print-function ${FUNCNAME} "${@}"
-
- # (no-op)
-}
-
# @FUNCTION: kernel-install_pkg_postrm
# @DESCRIPTION:
# Clean up the generated initramfs from the removed kernel directory.
@@ -774,5 +748,5 @@ kernel-install_compress_modules() {
fi
-EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_prerm pkg_postrm
+EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_postrm
EXPORT_FUNCTIONS pkg_config pkg_pretend
next prev parent reply other threads:[~2024-06-26 20:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 19:09 [gentoo-dev] [PATCH] kernel-build.eclass: identify dist-kernels, and warn users Andrew Nowa Ammerlaan
2024-06-26 20:06 ` [gentoo-dev] [PATCH 0/5] mount-boot.eclass: revises /boot checking for dist-kernels, add checks for ESP Andrew Nowa Ammerlaan
2024-06-26 20:06 ` [gentoo-dev] [PATCH 1/5] mount-boot.eclass: check for ESP as well as /boot, split, eclass Andrew Nowa Ammerlaan
2024-06-26 20:07 ` Andrew Nowa Ammerlaan [this message]
2024-06-26 20:08 ` [gentoo-dev] [PATCH 3/5] linux-mod-r1.eclass: check /boot if we are re-installing, dist-kernel Andrew Nowa Ammerlaan
2024-06-26 20:08 ` [gentoo-dev] [PATCH 4/5] sys-kernel/linux-firmware: complain less when /boot is not, mounted Andrew Nowa Ammerlaan
2024-06-26 20:09 ` [gentoo-dev] [PATCH 5/5] sys-firmware/intel-microcode: " Andrew Nowa Ammerlaan
2024-06-27 4:07 ` [gentoo-dev] [PATCH 2/5] kernel-install.eclass: move mount-boot check to, dist-kernel-utils.eclass Ulrich Mueller
2024-06-27 14:26 ` [gentoo-dev] [PATCH 2/5 v2] " Andrew Nowa Ammerlaan
2024-06-27 4:00 ` [gentoo-dev] [PATCH 1/5] mount-boot.eclass: check for ESP as well as /boot, split, eclass Ulrich Mueller
2024-06-27 14:24 ` [gentoo-dev] [PATCH 1/5 v2] " Andrew Nowa Ammerlaan
2024-06-28 6:33 ` Ulrich Mueller
2024-06-28 9:18 ` [gentoo-dev] [PATCH 1/5 v3] " Andrew Nowa Ammerlaan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d27e11c9-8212-48bc-9581-9d537705095b@gentoo.org \
--to=andrewammerlaan@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox