summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-01-12 13:28:50 +0100
committerMichał Górny <mgorny@gentoo.org>2021-01-16 10:53:00 +0100
commit375261ca73010b5c3d094f1c7d44baacd9edd9ae (patch)
tree92869b31eaf0eedbaaa5998b84a393a41583c827 /eclass
parentmount-boot.eclass: Remove support for EAPI 4 and 5 (diff)
downloadgentoo-375261ca73010b5c3d094f1c7d44baacd9edd9ae.tar.gz
gentoo-375261ca73010b5c3d094f1c7d44baacd9edd9ae.tar.bz2
gentoo-375261ca73010b5c3d094f1c7d44baacd9edd9ae.zip
mount-boot.eclass: Support nonfatal
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>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/mount-boot.eclass14
1 files 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() {