1 |
Support making mount-boot_check_status() nonfatal. This is useful |
2 |
to amend the error message with additional instructions. |
3 |
|
4 |
Signed-off-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
eclass/mount-boot.eclass | 14 +++++++++----- |
7 |
1 file changed, 9 insertions(+), 5 deletions(-) |
8 |
|
9 |
diff --git a/eclass/mount-boot.eclass b/eclass/mount-boot.eclass |
10 |
index 2874f9aae11b..8f59822db686 100644 |
11 |
--- a/eclass/mount-boot.eclass |
12 |
+++ b/eclass/mount-boot.eclass |
13 |
@@ -49,10 +49,11 @@ mount-boot_is_disabled() { |
14 |
# @INTERNAL |
15 |
# @DESCRIPTION: |
16 |
# Check if /boot is sane, i.e., mounted as read-write if on a separate |
17 |
-# partition. Die if conditions are not fulfilled. |
18 |
+# partition. Die if conditions are not fulfilled. If nonfatal is used, |
19 |
+# the function will return a non-zero status instead. |
20 |
mount-boot_check_status() { |
21 |
# Get out fast if possible. |
22 |
- mount-boot_is_disabled && return |
23 |
+ mount-boot_is_disabled && return 0 |
24 |
|
25 |
# note that /dev/BOOT is in the Gentoo default /etc/fstab file |
26 |
local fstabstate=$(awk '!/^[[:blank:]]*#|^\/dev\/BOOT/ && $2 == "/boot" \ |
27 |
@@ -60,7 +61,7 @@ mount-boot_check_status() { |
28 |
|
29 |
if [[ -z ${fstabstate} ]] ; then |
30 |
einfo "Assuming you do not have a separate /boot partition." |
31 |
- return |
32 |
+ return 0 |
33 |
fi |
34 |
|
35 |
local procstate=$(awk '$2 == "/boot" { split($4, a, ","); \ |
36 |
@@ -70,18 +71,21 @@ mount-boot_check_status() { |
37 |
if [[ -z ${procstate} ]] ; then |
38 |
eerror "Your boot partition is not mounted at /boot." |
39 |
eerror "Please mount it and retry." |
40 |
- die "/boot not mounted" |
41 |
+ die -n "/boot not mounted" |
42 |
+ return 1 |
43 |
fi |
44 |
|
45 |
if [[ ${procstate} == ro ]] ; then |
46 |
eerror "Your boot partition, detected as being mounted at /boot," \ |
47 |
"is read-only." |
48 |
eerror "Please remount it as read-write and retry." |
49 |
- die "/boot mounted read-only" |
50 |
+ die -n "/boot mounted read-only" |
51 |
+ return 2 |
52 |
fi |
53 |
|
54 |
einfo "Your boot partition was detected as being mounted at /boot." |
55 |
einfo "Files will be installed there for ${PN} to function correctly." |
56 |
+ return 0 |
57 |
} |
58 |
|
59 |
mount-boot_pkg_pretend() { |
60 |
-- |
61 |
2.30.0 |