public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 0/3] mount-boot/kernel-install: better (re)mount /boot error messages
@ 2021-01-12 12:59 Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 1/3] mount-boot.eclass: Remove support for EAPI 4 and 5 Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-12 12:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Hi,

Here's a trivial-ish patchset that adds 'nonfatal' support to
mount-boot.eclass and then uses it in kernel-install.eclass to issue
better error messages.

This is primarily because dist-kernels install to /boot in postinst
only.  If /boot is not mounted properly at postinst time, it is possible
to reissue it using 'emerge --config' without having to rebuild
the whole kernel.



Michał Górny (3):
  mount-boot.eclass: Remove support for EAPI 4 and 5
  mount-boot.eclass: Support nonfatal
  kernel-install.eclass: Add instructions for non-mounted /boot

 eclass/kernel-install.eclass | 12 ++++++++++--
 eclass/mount-boot.eclass     | 17 +++++++++++------
 2 files changed, 21 insertions(+), 8 deletions(-)

-- 
2.30.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 1/3] mount-boot.eclass: Remove support for EAPI 4 and 5
  2021-01-12 12:59 [gentoo-dev] [PATCH 0/3] mount-boot/kernel-install: better (re)mount /boot error messages Michał Górny
@ 2021-01-12 12:59 ` Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 2/3] mount-boot.eclass: Support nonfatal Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 3/3] kernel-install.eclass: Add instructions for non-mounted /boot Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-12 12:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

The eclass is no longer used by any EAPI 4 or 5 ebuilds in ::gentoo.
This removes the need for EAPI-conditional nonfatal support.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/mount-boot.eclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass
index 00b367793252..2874f9aae11b 100644
--- a/eclass/mount-boot.eclass
+++ b/eclass/mount-boot.eclass
@@ -5,6 +5,7 @@
 # @MAINTAINER:
 # base-system@gentoo.org
 # @BLURB: functions for packages that install files into /boot
+# @SUPPORTED_EAPIS: 6 7
 # @DESCRIPTION:
 # This eclass is really only useful for bootloaders.
 #
@@ -13,7 +14,7 @@
 # error if it can't.  It does nothing if /boot isn't a separate partition.
 
 case ${EAPI:-0} in
-	4|5|6|7) ;;
+	6|7) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/3] mount-boot.eclass: Support nonfatal
  2021-01-12 12:59 [gentoo-dev] [PATCH 0/3] mount-boot/kernel-install: better (re)mount /boot error messages Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 1/3] mount-boot.eclass: Remove support for EAPI 4 and 5 Michał Górny
@ 2021-01-12 12:59 ` Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 3/3] kernel-install.eclass: Add instructions for non-mounted /boot Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-12 12:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Support making mount-boot_check_status() nonfatal.  This is useful
to amend the error message with additional instructions.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/mount-boot.eclass | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass
index 2874f9aae11b..8f59822db686 100644
--- a/eclass/mount-boot.eclass
+++ b/eclass/mount-boot.eclass
@@ -49,10 +49,11 @@ mount-boot_is_disabled() {
 # @INTERNAL
 # @DESCRIPTION:
 # Check if /boot is sane, i.e., mounted as read-write if on a separate
-# partition.  Die if conditions are not fulfilled.
+# partition.  Die if conditions are not fulfilled.  If nonfatal is used,
+# the function will return a non-zero status instead.
 mount-boot_check_status() {
 	# Get out fast if possible.
-	mount-boot_is_disabled && return
+	mount-boot_is_disabled && return 0
 
 	# note that /dev/BOOT is in the Gentoo default /etc/fstab file
 	local fstabstate=$(awk '!/^[[:blank:]]*#|^\/dev\/BOOT/ && $2 == "/boot" \
@@ -60,7 +61,7 @@ mount-boot_check_status() {
 
 	if [[ -z ${fstabstate} ]] ; then
 		einfo "Assuming you do not have a separate /boot partition."
-		return
+		return 0
 	fi
 
 	local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \
@@ -70,18 +71,21 @@ mount-boot_check_status() {
 	if [[ -z ${procstate} ]] ; then
 		eerror "Your boot partition is not mounted at /boot."
 		eerror "Please mount it and retry."
-		die "/boot not mounted"
+		die -n "/boot not mounted"
+		return 1
 	fi
 
 	if [[ ${procstate} == ro ]] ; then
 		eerror "Your boot partition, detected as being mounted at /boot," \
 			"is read-only."
 		eerror "Please remount it as read-write and retry."
-		die "/boot mounted read-only"
+		die -n "/boot mounted read-only"
+		return 2
 	fi
 
 	einfo "Your boot partition was detected as being mounted at /boot."
 	einfo "Files will be installed there for ${PN} to function correctly."
+	return 0
 }
 
 mount-boot_pkg_pretend() {
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 3/3] kernel-install.eclass: Add instructions for non-mounted /boot
  2021-01-12 12:59 [gentoo-dev] [PATCH 0/3] mount-boot/kernel-install: better (re)mount /boot error messages Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 1/3] mount-boot.eclass: Remove support for EAPI 4 and 5 Michał Górny
  2021-01-12 12:59 ` [gentoo-dev] [PATCH 2/3] mount-boot.eclass: Support nonfatal Michał Górny
@ 2021-01-12 12:59 ` Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-12 12:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Use the newly-introduced mount-boot.eclass nonfatal support to amend
the error message with the instruction to run 'emerge --config' rather
than rebuild the whole kernel.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/kernel-install.eclass | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index e826626e13f2..bcbb0f1c8574 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -403,7 +403,15 @@ kernel-install_pkg_postinst() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	if [[ -z ${ROOT} ]]; then
-		mount-boot_pkg_preinst
+		if ! nonfatal mount-boot_check_status; then
+			eerror
+			eerror "The kernel files were copied to disk successfully but the kernel"
+			eerror "was not deployed.  Once you resolve the problems, please run"
+			eerror "the equivalent of the following command to install it:"
+			eerror
+			eerror "    emerge --config ${CATEGORY}/${PN}"
+			die "Kernel install failed, please mount /boot and run emerge --config ${CATEGORY}/${PN}"
+		fi
 
 		local ver="${PV}${KV_LOCALVERSION}"
 		local image_path=$(kernel-install_get_image_path)
@@ -455,7 +463,7 @@ kernel-install_pkg_postrm() {
 kernel-install_pkg_config() {
 	[[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
 
-	mount-boot_pkg_preinst
+	mount-boot_check_status
 
 	local ver="${PV}${KV_LOCALVERSION}"
 	local image_path=$(kernel-install_get_image_path)
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-12 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12 12:59 [gentoo-dev] [PATCH 0/3] mount-boot/kernel-install: better (re)mount /boot error messages Michał Górny
2021-01-12 12:59 ` [gentoo-dev] [PATCH 1/3] mount-boot.eclass: Remove support for EAPI 4 and 5 Michał Górny
2021-01-12 12:59 ` [gentoo-dev] [PATCH 2/3] mount-boot.eclass: Support nonfatal Michał Górny
2021-01-12 12:59 ` [gentoo-dev] [PATCH 3/3] kernel-install.eclass: Add instructions for non-mounted /boot Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox