Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
On Thu, 2021-01-14 at 10:22 +0100, Ulrich Mueller wrote: > > > > > > On Wed, 13 Jan 2021, Michał Górny wrote: > > > # loop for the purpose of allowing error handling via 'break' > > > Does that sound explanatory enough? > > "Not an actual loop but allows error handling with 'break'" Thanks. Updated. -- Best regards, Michał Górny
Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
> On Wed, 13 Jan 2021, Michał Górny wrote: > # loop for the purpose of allowing error handling via 'break' > Does that sound explanatory enough? "Not an actual loop but allows error handling with 'break'" signature.asc Description: PGP signature
Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
On Wed, 2021-01-13 at 21:53 +0100, Ulrich Mueller wrote: > > > > > > On Wed, 13 Jan 2021, Michał Górny wrote: > > > > Looks like this loop can run only once, so it is redundant? > > > It's the old C trick for convenient error handling. > > Newfangled contraptions. What's wrong with goto? :) > > > Do you have any other suggestion? I suppose we could use a nested > > function if you think that's nicer. > > No, it's fine. Maybe an explanatory comment would be helpful, because > I > think that code isn't obvious. . # loop for the purpose of allowing error handling via 'break' Does that sound explanatory enough? -- Best regards, Michał Górny
Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
> On Wed, 13 Jan 2021, Michał Górny wrote: >> Looks like this loop can run only once, so it is redundant? > It's the old C trick for convenient error handling. Newfangled contraptions. What's wrong with goto? :) > Do you have any other suggestion? I suppose we could use a nested > function if you think that's nicer. No, it's fine. Maybe an explanatory comment would be helpful, because I think that code isn't obvious. Ulrich signature.asc Description: PGP signature
Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
On Wed, 2021-01-13 at 15:49 +0100, Ulrich Mueller wrote: > > > > > > On Wed, 13 Jan 2021, Michał Górny wrote: > > + local success= > > + 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 > > Looks like this loop can run only once, so it is redundant? It's the old C trick for convenient error handling. Do you have any other suggestion? I suppose we could use a nested function if you think that's nicer. -- Best regards, Michał Górny
Re: [gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
> On Wed, 13 Jan 2021, Michał Górny wrote: > + local success= > + 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 Looks like this loop can run only once, so it is redundant? Ulrich signature.asc Description: PGP signature
[gentoo-dev] [PATCH 4/6] kernel-install.eclass: Improve failed install error messages
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 --- eclass/dist-kernel-utils.eclass | 4 ++-- eclass/kernel-install.eclass| 42 +++-- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index d92642a25a0a..d65dc0924b40 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -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 @@ -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 diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index cfd8ec0b7c58..f9b1834266dd 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -343,20 +343,36 @@ 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= + 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 -- 2.30.0