From bb7b3f56b8d85bb1c96d9d0b85a10769fb497005 Mon Sep 17 00:00:00 2001 From: Nowa Ammerlaan Date: Sat, 1 Mar 2025 13:09:25 +0100 Subject: [PATCH] dist-kernel-utils.eclass: pass on extra args to installkernel v56 Installkernel v56 has gained the capability of parsing optional arguments. Adjust the helper functions here so ebuilds can pass on these extra arguments directly to installkernel. Signed-off-by: Nowa Ammerlaan --- eclass/dist-kernel-utils.eclass | 72 +++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 3d7315e9e94ec..49977c18795a0 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -66,18 +66,37 @@ dist-kernel_get_image_path() { } # @FUNCTION: dist-kernel_install_kernel -# @USAGE: +# @USAGE: [] [] [] [] [...] # @DESCRIPTION: -# Install kernel using installkernel tool. specifies -# the kernel version, full path to the image, -# full path to System.map. +# Install kernel using installkernel. Takes the following arguments: +# +# -- the target kernel version (default: ${KV_FULL}) +# +# -- the full path to the kernel image (default: the image +# as reported by dist-kernel_get_image_path() in the ${KV_DIR}) +# +# -- the full path to the System.map +# (default: ${KV_DIR}/System.map}) +# +# -- the target directory to install to (default: ${EROOT}/boot) +# +# -- extra optional arguments for installkernel +# see man kernel-install and man installkernel. Requires at +# least version 56 of sys-kernel/installkernel. dist-kernel_install_kernel() { debug-print-function ${FUNCNAME} "$@" - [[ ${#} -eq 3 ]] || die "${FUNCNAME}: invalid arguments" - local version=${1} - local image=${2} - local map=${3} + local version=${1:-${KV_FULL}} + local image=${2:-${KV_DIR}/$(dist-kernel_get_image_path)} + local map=${3:-${KV_DIR}/System.map} + local dir=${4:-${EROOT}/boot} + + local installkernel_args=( + "${version}" "${image}" "${map}" "${dir}" + ) + if has_version ">=sys-kernel/installkernel-56"; then + installkernel_args+=( "${@:5}" --verbose ) + fi local success= # not an actual loop but allows error handling with 'break' @@ -107,8 +126,7 @@ dist-kernel_install_kernel() { 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}" \ - "${EROOT}/boot" || break + ARCH=$(tc-arch-kernel) installkernel "${installkernel_args[@]}" || break eend ${?} || die -n "Installing the kernel failed" success=1 @@ -129,39 +147,49 @@ dist-kernel_install_kernel() { 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}" + if has --all "${installkernel_args[@]}"; then + eerror " installkernel ${installkernel_args[*]}" + else + eerror " emerge --config ${kernel}" + fi die "Kernel install failed, please fix the problems and run emerge --config" fi } # @FUNCTION: dist-kernel_reinstall_initramfs -# @USAGE: +# @USAGE: [] [] [...] # @DESCRIPTION: # Rebuild and install initramfs for the specified dist-kernel. -# is the kernel source directory (${KV_DIR} from linux-info), -# while is the full kernel version (${KV_FULL}). -# The function will determine whether is actually -# a dist-kernel, and whether initramfs was used. +# Takes the following arguments: +# +# -- the full path to the target kernel (default: ${KV_DIR}) +# +# -- the target kernel version (default: ${KV_FULL}) +# +# -- extra optional arguments for installkernel +# see man kernel-install and man installkernel. Requires at +# least version 56 of sys-kernel/installkernel. # # This function is to be used in pkg_postinst() of ebuilds installing -# kernel modules that are included in the initramfs. +# kernel modules that are included in the initramfs. In order to +# reinstall *all* distribution kernels currently installed on the +# system add the --all argument (requires installkernel-56 or newer). dist-kernel_reinstall_initramfs() { debug-print-function ${FUNCNAME} "$@" - [[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments" - local kernel_dir=${1} - local ver=${2} + local kernel_dir=${1:-${KV_DIR}} + local ver=${2:-${KV_FULL}} local image_path=${kernel_dir}/$(dist-kernel_get_image_path) if [[ ! -f ${image_path} ]]; then eerror "Kernel install missing, image not found:" eerror " ${image_path}" - eerror "Initramfs will not be updated. Please reinstall your kernel." + eerror "Initramfs will not be updated. Please reinstall kernel ${ver}." return fi dist-kernel_install_kernel "${ver}" "${image_path}" \ - "${kernel_dir}/System.map" + "${kernel_dir}/System.map" "${EROOT}/boot" "${@:3}" } # @FUNCTION: dist-kernel_PV_to_KV