Skip to content

Commit

Permalink
fix(install.d): respect more kernel-install env variables
Browse files Browse the repository at this point in the history
- 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 <andrewammerlaan@gentoo.org>
  • Loading branch information
AndrewAmmerlaan authored and aafeijoo-suse committed Jun 26, 2023
1 parent 09d3ec1 commit a037634
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
43 changes: 31 additions & 12 deletions install.d/50-dracut.install
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion install.d/51-dracut-rescue.install
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a037634

Please sign in to comment.