From 2c37b290f58cfe01239d6441aba2d92c03478ff7 Mon Sep 17 00:00:00 2001 From: Matteo Croce Date: Fri, 19 Jul 2024 23:23:57 +0200 Subject: [PATCH] support kernels without initrd If the installed kernel has no initrd support, skip the image creation. --- install.d/50-dracut.install | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install index 441414ac32..b265212ae6 100755 --- a/install.d/50-dracut.install +++ b/install.d/50-dracut.install @@ -5,6 +5,14 @@ KERNEL_VERSION="$2" BOOT_DIR_ABS="$3" KERNEL_IMAGE="$4" +CONFIG_PATHS=( + "/lib/modules/${KERNEL_VERSION}/config" + "/lib/modules/${KERNEL_VERSION}/build/.config" + "/lib/modules/${KERNEL_VERSION}/source/.config" + "/usr/src/linux-${KERNEL_VERSION}/.config" + "$BOOT_DIR_ABS/config-${KERNEL_VERSION}" +) + # If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory. # So, let's skip to create initrd. if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then @@ -53,6 +61,12 @@ ret=0 case "$COMMAND" in add) + for CONFIG in "${CONFIG_PATHS[@]}"; do + # This kernel doesn't support initramfs, so don't generate one + if [[ -f $CONFIG ]] && ! grep -qx CONFIG_BLK_DEV_INITRD=y "$CONFIG"; then + exit 0 + fi + done if [[ $IMAGE == "uki.efi" ]]; then IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/uki.efi else