1 |
Support and use nonfatal to provide a detailed error message when kernel |
2 |
postinst fails, in particular the correct 'emerge --config' command. |
3 |
|
4 |
Signed-off-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
eclass/dist-kernel-utils.eclass | 4 ++-- |
7 |
eclass/kernel-install.eclass | 42 +++++++++++++++++++++++---------- |
8 |
2 files changed, 31 insertions(+), 15 deletions(-) |
9 |
|
10 |
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass |
11 |
index d92642a25a0a..d65dc0924b40 100644 |
12 |
--- a/eclass/dist-kernel-utils.eclass |
13 |
+++ b/eclass/dist-kernel-utils.eclass |
14 |
@@ -43,7 +43,7 @@ dist-kernel_build_initramfs() { |
15 |
|
16 |
ebegin "Building initramfs via dracut" |
17 |
dracut --force "${output}" "${version}" |
18 |
- eend ${?} || die "Building initramfs failed" |
19 |
+ eend ${?} || die -n "Building initramfs failed" |
20 |
} |
21 |
|
22 |
# @FUNCTION: dist-kernel_get_image_path |
23 |
@@ -89,7 +89,7 @@ dist-kernel_install_kernel() { |
24 |
# note: .config is taken relatively to System.map; |
25 |
# initrd relatively to bzImage |
26 |
installkernel "${version}" "${image}" "${map}" |
27 |
- eend ${?} || die "Installing the kernel failed" |
28 |
+ eend ${?} || die -n "Installing the kernel failed" |
29 |
} |
30 |
|
31 |
# @FUNCTION: dist-kernel_reinstall_initramfs |
32 |
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass |
33 |
index cfd8ec0b7c58..f9b1834266dd 100644 |
34 |
--- a/eclass/kernel-install.eclass |
35 |
+++ b/eclass/kernel-install.eclass |
36 |
@@ -343,20 +343,36 @@ kernel-install_install_all() { |
37 |
[[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" |
38 |
local ver=${1} |
39 |
|
40 |
- mount-boot_pkg_preinst |
41 |
- |
42 |
- local image_path=$(dist-kernel_get_image_path) |
43 |
- if use initramfs; then |
44 |
- # putting it alongside kernel image as 'initrd' makes |
45 |
- # kernel-install happier |
46 |
- dist-kernel_build_initramfs \ |
47 |
- "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \ |
48 |
- "${ver}" |
49 |
- fi |
50 |
+ local success= |
51 |
+ while :; do |
52 |
+ mount-boot_pkg_preinst |
53 |
+ |
54 |
+ local image_path=$(dist-kernel_get_image_path) |
55 |
+ if use initramfs; then |
56 |
+ # putting it alongside kernel image as 'initrd' makes |
57 |
+ # kernel-install happier |
58 |
+ nonfatal dist-kernel_build_initramfs \ |
59 |
+ "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \ |
60 |
+ "${ver}" || break |
61 |
+ fi |
62 |
|
63 |
- dist-kernel_install_kernel "${ver}" \ |
64 |
- "${EROOT}/usr/src/linux-${ver}/${image_path}" \ |
65 |
- "${EROOT}/usr/src/linux-${ver}/System.map" |
66 |
+ nonfatal dist-kernel_install_kernel "${ver}" \ |
67 |
+ "${EROOT}/usr/src/linux-${ver}/${image_path}" \ |
68 |
+ "${EROOT}/usr/src/linux-${ver}/System.map" || break |
69 |
+ |
70 |
+ success=1 |
71 |
+ break |
72 |
+ done |
73 |
+ |
74 |
+ if [[ ! ${success} ]]; then |
75 |
+ eerror |
76 |
+ eerror "The kernel files were copied to disk successfully but the kernel" |
77 |
+ eerror "was not deployed successfully. Once you resolve the problems," |
78 |
+ eerror "please run the equivalent of the following command to try again:" |
79 |
+ eerror |
80 |
+ eerror " emerge --config ${CATEGORY}/${PN}:${SLOT}" |
81 |
+ die "Kernel install failed, please fix the problems and run emerge --config ${CATEGORY}/${PN}:${SLOT}" |
82 |
+ fi |
83 |
} |
84 |
|
85 |
# @FUNCTION: kernel-install_pkg_postinst |
86 |
-- |
87 |
2.30.0 |