Skip to content

Commit

Permalink
kernel-install.eclass: Improve failed install error messages
Browse files Browse the repository at this point in the history
Support and use nonfatal to provide a detailed error message when kernel
postinst fails, in particular the correct 'emerge --config' command.

Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
mgorny committed Jan 16, 2021
1 parent 558822c commit 5a88589
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
4 changes: 2 additions & 2 deletions eclass/dist-kernel-utils.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dist-kernel_build_initramfs() {

ebegin "Building initramfs via dracut"
dracut --force "${output}" "${version}"
eend ${?} || die "Building initramfs failed"
eend ${?} || die -n "Building initramfs failed"
}

# @FUNCTION: dist-kernel_get_image_path
Expand Down Expand Up @@ -89,7 +89,7 @@ dist-kernel_install_kernel() {
# note: .config is taken relatively to System.map;
# initrd relatively to bzImage
installkernel "${version}" "${image}" "${map}"
eend ${?} || die "Installing the kernel failed"
eend ${?} || die -n "Installing the kernel failed"
}

# @FUNCTION: dist-kernel_reinstall_initramfs
Expand Down
43 changes: 30 additions & 13 deletions eclass/kernel-install.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -343,20 +343,37 @@ kernel-install_install_all() {
[[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments"
local ver=${1}

mount-boot_pkg_preinst

local image_path=$(dist-kernel_get_image_path)
if use initramfs; then
# putting it alongside kernel image as 'initrd' makes
# kernel-install happier
dist-kernel_build_initramfs \
"${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
"${ver}"
fi
local success=
# not an actual loop but allows error handling with 'break'
while :; do
mount-boot_pkg_preinst

local image_path=$(dist-kernel_get_image_path)
if use initramfs; then
# putting it alongside kernel image as 'initrd' makes
# kernel-install happier
nonfatal dist-kernel_build_initramfs \
"${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
"${ver}" || break
fi

dist-kernel_install_kernel "${ver}" \
"${EROOT}/usr/src/linux-${ver}/${image_path}" \
"${EROOT}/usr/src/linux-${ver}/System.map"
nonfatal dist-kernel_install_kernel "${ver}" \
"${EROOT}/usr/src/linux-${ver}/${image_path}" \
"${EROOT}/usr/src/linux-${ver}/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
}

# @FUNCTION: kernel-install_pkg_postinst
Expand Down

0 comments on commit 5a88589

Please sign in to comment.