From: Andrew Ammerlaan Date: Sat, 17 Jun 2023 06:18:55 +0000 (+0200) Subject: fix(install.d): respect more kernel-install env variables X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fdracut.git;a=commitdiff_plain;h=a037634ad71711d29828214830ebdade0c449dbc fix(install.d): respect more kernel-install env variables - If kernel-install has defined a staging area for us (KERNEL_INSTALL_STAGING_AREA) install generated initrd/uki.efi there. The actual install is then handled by 90-loaderentry.install or 90-uki-copy-install. - Also skip regeneration if an uki.efi already exists. - Pass --kernel-image to dracut, this is required to generate an uki (uefi=yes) - Add --no-uefi argument to dracut rescue image generation, this ensures that it at least installs correctly. TODO: Rework 51-dracut-rescue.install to also work with uki's. This fixes installing a kernel with uefi=yes in dracut config and layout=uki in kernel/install.conf. Signed-off-by: Andrew Ammerlaan --- diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install index a81c41c95..eae308497 100755 --- a/install.d/50-dracut.install +++ b/install.d/50-dracut.install @@ -11,23 +11,40 @@ if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then exit 0 fi -if [[ -d "$BOOT_DIR_ABS" ]]; then - INITRD="initrd" +# Mismatching the install layout and the --uefi/--no-uefi opts just creates a mess. +if [[ "$KERNEL_INSTALL_LAYOUT" == "uki" && -n "$KERNEL_INSTALL_STAGING_AREA" ]]; then + BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA" + IMAGE="uki.efi" + UEFI_OPTS="--uefi" +elif [[ "$KERNEL_INSTALL_LAYOUT" == "bls" && -n "$KERNEL_INSTALL_STAGING_AREA" ]]; then + BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA" + IMAGE="initrd" + UEFI_OPTS="--no-uefi" else - BOOT_DIR_ABS="/boot" - INITRD="initramfs-${KERNEL_VERSION}.img" + # No layout information, use users --uefi/--no-uefi preference + UEFI_OPTS="" + if [[ -d "$BOOT_DIR_ABS" ]]; then + IMAGE="initrd" + else + BOOT_DIR_ABS="/boot" + IMAGE="initramfs-${KERNEL_VERSION}.img" + fi fi ret=0 case "$COMMAND" in add) - INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd - if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then - # we found an initrd at the same place as the kernel + if [[ "$IMAGE" == "uki.efi" ]]; then + IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/uki.efi + else + IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd + fi + if [[ -f ${IMAGE_PREGENERATED} ]]; then + # we found an initrd or uki.efi at the same place as the kernel # use this and don't generate a new one - cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$INITRD" \ - && chown root:root "$BOOT_DIR_ABS/$INITRD" \ - && chmod 0600 "$BOOT_DIR_ABS/$INITRD" \ + cp --reflink=auto "$IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$IMAGE" \ + && chown root:root "$BOOT_DIR_ABS/$IMAGE" \ + && chmod 0600 "$BOOT_DIR_ABS/$IMAGE" \ && exit 0 fi @@ -58,12 +75,14 @@ case "$COMMAND" in dracut -f \ ${noimageifnotneeded:+--noimageifnotneeded} \ $([[ "$KERNEL_INSTALL_VERBOSE" == 1 ]] && echo --verbose) \ - "$BOOT_DIR_ABS/$INITRD" \ + $([[ -n "$KERNEL_IMAGE" ]] && echo --kernel-image "${KERNEL_IMAGE}") \ + "$UEFI_OPTS" \ + "$BOOT_DIR_ABS/$IMAGE" \ "$KERNEL_VERSION" ret=$? ;; remove) - rm -f -- "$BOOT_DIR_ABS/$INITRD" + rm -f -- "$BOOT_DIR_ABS/$IMAGE" ret=$? ;; esac diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install index 8bf9a6d95..562ffcbd7 100755 --- a/install.d/51-dracut-rescue.install +++ b/install.d/51-dracut-rescue.install @@ -96,7 +96,9 @@ case "$COMMAND" in fi if [[ ! -f "$BOOT_DIR_ABS/$INITRD" ]]; then - dracut -f --no-hostonly -a "rescue" "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION" + dracut -f --no-hostonly --no-uefi \ + $([[ -n "$KERNEL_IMAGE" ]] && echo --kernel-image "${KERNEL_IMAGE}") \ + -a "rescue" "$BOOT_DIR_ABS/$INITRD" "$KERNEL_VERSION" ((ret+=$?)) fi