From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CB81F15802E for ; Thu, 27 Jun 2024 14:27:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D94B7E2AF9; Thu, 27 Jun 2024 14:26:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 80525E2AF6 for ; Thu, 27 Jun 2024 14:26:58 +0000 (UTC) Message-ID: Date: Thu, 27 Jun 2024 16:26:54 +0200 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [gentoo-dev] [PATCH 2/5 v2] kernel-install.eclass: move mount-boot check to, dist-kernel-utils.eclass To: Ulrich Mueller Cc: gentoo-dev@lists.gentoo.org References: <38ed17cb-950a-4abd-b904-537388dbe612@gentoo.org> <476674df-a57c-4c4d-ad1e-487211a4daf0@gentoo.org> Content-Language: en-US, nl-NL From: Andrew Nowa Ammerlaan Autocrypt: addr=andrewammerlaan@gentoo.org; keydata= xsBNBF3n3cUBCAC6uoDZ0XzaO29l8AzUblXQ5rxZI7nbGEnfFqjEQCK3oEXxsDa9Ez1myx3M ir53Vyx64Iz1Bq/TOS/PttgguPpiLggCpTTD2vavp5SwFmg272+P8bUJVJF2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17Wa6+WXC+80/iLxxolMqM4KfuIR5OizbqK 2CRAJY7la7TSv1lTD1cAEQEAAcLAfAQYAQgAJgIbDBYhBAb/U0G9gF2wvH0HpqGfY2zU7bzR BQJlNiHABQkJL3d7AAoJEKGfY2zU7bzRjDwH/1fp/87km2YYVgrfP1aWLjAA/TwcEVycRJQQ S9Q6xuzgD5AYhjzBSONoN46cwf+gla6xndY0lCawsZN7whtJ/DhqSZEfL0HgHkJ6T8FCXexf n1s6XmIAxqIrMmfsuOkAPLJIHzAAGzQX8DXcRSj1cIDUpa1Uy7ncVvI4EzJBRtJVJXIbl+53 NGauXU8ZuprPYkMSPuW3eHATFc0F5DhmlFUXh+HYYK+2QTO73TENMhngkrYcw63je5bRp/+f 72XFKlf1gXHK1ivg8nYueyUfrxZTBGKagusOiQeOao2I1uYcHoFhPYJrQWePMyZiYyB6PR0K DR4B/Ulo3v0eBXaaYzo= Organization: Gentoo Linux In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Archives-Salt: 6cd20561-61f5-4442-8399-7fa51179dd53 X-Archives-Hash: 0dacd57c1a9ba1a4b6bd2da8f75f6744 On 27/06/2024 06:07, Ulrich Mueller wrote: > IMHO "while true" would be better readable. Adjusted, here's v2: From 422fcc5fb53c3f2adf25256fb7d18a65e4036496 Mon Sep 17 00:00:00 2001 From: Andrew Ammerlaan Date: Tue, 25 Jun 2024 16:12:39 +0200 Subject: [PATCH] kernel-install.eclass: move mount-boot check to dist-kernel-utils.eclass ebuilds and eclasses using dist-kernel_reinstall_initramfs should also have the check for mounted /boot and ESP. We can do this safely via mount-boot-utils.eclass which does not export any phases. Signed-off-by: Andrew Ammerlaan --- eclass/dist-kernel-utils.eclass | 39 ++++++++++++++++++++++++----- eclass/kernel-install.eclass | 44 +++++++-------------------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 13137f8c863c8..4bc3fab44aae9 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -26,7 +26,7 @@ case ${EAPI} in *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -inherit toolchain-funcs +inherit mount-boot-utils toolchain-funcs # @FUNCTION: dist-kernel_get_image_path # @DESCRIPTION: @@ -79,11 +79,38 @@ dist-kernel_install_kernel() { local image=${2} local map=${3} - ebegin "Installing the kernel via installkernel" - # note: .config is taken relatively to System.map; - # initrd relatively to bzImage - ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" - eend ${?} || die -n "Installing the kernel failed" + local success= + # not an actual loop but allows error handling with 'break' + while true; do + nonfatal mount-boot_check_status || break + + ebegin "Installing the kernel via installkernel" + # note: .config is taken relatively to System.map; + # initrd relatively to bzImage + ARCH=$(tc-arch-kernel) installkernel "${version}" "${image}" "${map}" || break + eend ${?} || die -n "Installing the kernel failed" + + success=1 + break + done + + if [[ ! ${success} ]]; then + # Fallback string, if the identifier file is not found + local kernel=":" + # Try to read dist-kernel identifier to more accurately instruct users + local k_id_file=${image%$(dist-kernel_get_image_path)}/dist-kernel + if [[ -f ${k_id_file} ]]; then + kernel=\'\=$(<${k_id_file})\' + fi + + eerror + eerror "The kernel was not deployed successfully. Inspect the failure" + eerror "in the logs above and once you resolve the problems please" + eerror "run the equivalent of the following command to try again:" + eerror + eerror " emerge --config ${kernel}" + die "Kernel install failed, please fix the problems and run emerge --config" + fi } # @FUNCTION: dist-kernel_reinstall_initramfs diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass index f512d815fe098..77570a905ce11 100644 --- a/eclass/kernel-install.eclass +++ b/eclass/kernel-install.eclass @@ -17,9 +17,7 @@ # /usr/src/linux-${PV} containing the kernel image in its standard # location and System.map. # -# The eclass exports src_test, pkg_postinst and pkg_postrm. -# Additionally, the inherited mount-boot eclass exports pkg_pretend. -# It also stubs out pkg_preinst and pkg_prerm defined by mount-boot. +# The eclass exports src_test, pkg_preinst, pkg_postinst and pkg_postrm. # @ECLASS_VARIABLE: KERNEL_IUSE_GENERIC_UKI # @PRE_INHERIT @@ -50,7 +48,7 @@ case ${EAPI} in *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -inherit dist-kernel-utils mount-boot multiprocessing toolchain-funcs +inherit dist-kernel-utils mount-boot-utils multiprocessing toolchain-funcs SLOT="${PV}" IUSE="+initramfs test" @@ -526,6 +524,10 @@ kernel-install_test() { kernel-install_pkg_pretend() { debug-print-function ${FUNCNAME} "${@}" + # Check, but don't die because we can fix the problem and then + # emerge --config ... to re-run installation. + nonfatal mount-boot_check_status + if ! has_version -d sys-kernel/linux-firmware; then ewarn "sys-kernel/linux-firmware not found installed on your system." ewarn "This package provides various firmware files that may be needed" @@ -665,27 +667,8 @@ kernel-install_install_all() { fi fi - local success= - # not an actual loop but allows error handling with 'break' - while :; do - nonfatal mount-boot_check_status || break - - nonfatal dist-kernel_install_kernel "${module_ver}" \ - "${kernel_dir}/${image_path}" "${kernel_dir}/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 + dist-kernel_install_kernel "${module_ver}" "${kernel_dir}/${image_path}" \ + "${kernel_dir}/System.map" } # @FUNCTION: kernel-install_pkg_postinst @@ -718,15 +701,6 @@ kernel-install_pkg_postinst() { fi } -# @FUNCTION: kernel-install_pkg_prerm -# @DESCRIPTION: -# Stub out mount-boot.eclass. -kernel-install_pkg_prerm() { - debug-print-function ${FUNCNAME} "${@}" - - # (no-op) -} - # @FUNCTION: kernel-install_pkg_postrm # @DESCRIPTION: # Clean up the generated initramfs from the removed kernel directory. @@ -774,5 +748,5 @@ kernel-install_compress_modules() { fi -EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_prerm pkg_postrm +EXPORT_FUNCTIONS src_test pkg_preinst pkg_postinst pkg_postrm EXPORT_FUNCTIONS pkg_config pkg_pretend