|
|
43355b |
From 6fa596ca039300e5f4bb3cca14768976efe95eac Mon Sep 17 00:00:00 2001
|
|
|
43355b |
From: Pavel Valena <pvalena@redhat.com>
|
|
|
43355b |
Date: Wed, 12 Jun 2024 06:30:42 +0200
|
|
|
43355b |
Subject: [PATCH 3/6] revert: "fix(install.d): correctly install pre-genned
|
|
|
43355b |
image and die if no args"
|
|
|
43355b |
|
|
|
43355b |
revert: "fix(install.d): simplify and use what kernel-install gives us"
|
|
|
43355b |
|
|
|
43355b |
This reverts commits:
|
|
|
43355b |
d40155385d060f8d8608fa8a4931e2e42ddc3a8f
|
|
|
43355b |
8388ad149c698c951089606352fdb0cdcaaf40c9
|
|
|
43355b |
|
|
|
43355b |
https://github.com/dracut-ng/dracut-ng/issues/334
|
|
|
43355b |
|
|
|
43355b |
This is temporary, until the `20-grub.install` will be able to handle initrd
|
|
|
43355b |
from kernel staging area.
|
|
|
43355b |
---
|
|
|
43355b |
install.d/50-dracut.install | 152 ++++++++++++++++++-----------
|
|
|
43355b |
install.d/51-dracut-rescue.install | 22 +----
|
|
|
43355b |
2 files changed, 97 insertions(+), 77 deletions(-)
|
|
|
43355b |
|
|
|
43355b |
diff --git a/install.d/50-dracut.install b/install.d/50-dracut.install
|
|
|
43355b |
index 14f87721..441414ac 100755
|
|
|
43355b |
--- a/install.d/50-dracut.install
|
|
|
43355b |
+++ b/install.d/50-dracut.install
|
|
|
43355b |
@@ -1,13 +1,13 @@
|
|
|
43355b |
#!/bin/bash
|
|
|
43355b |
|
|
|
43355b |
-COMMAND="${1:?}"
|
|
|
43355b |
-KERNEL_VERSION="${2:?}"
|
|
|
43355b |
-#shellcheck disable=SC2034
|
|
|
43355b |
+COMMAND="$1"
|
|
|
43355b |
+KERNEL_VERSION="$2"
|
|
|
43355b |
BOOT_DIR_ABS="$3"
|
|
|
43355b |
KERNEL_IMAGE="$4"
|
|
|
43355b |
|
|
|
43355b |
-# If the initrd was provided on the kernel command line, we shouldn't generate our own.
|
|
|
43355b |
-if [[ "$COMMAND" != "add" || "$#" -gt 4 ]]; then
|
|
|
43355b |
+# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory.
|
|
|
43355b |
+# So, let's skip to create initrd.
|
|
|
43355b |
+if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
|
|
|
43355b |
exit 0
|
|
|
43355b |
fi
|
|
|
43355b |
|
|
|
43355b |
@@ -16,64 +16,102 @@ if [[ "$KERNEL_INSTALL_IMAGE_TYPE" = "uki" ]]; then
|
|
|
43355b |
exit 0
|
|
|
43355b |
fi
|
|
|
43355b |
|
|
|
43355b |
-if [[ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" = "dracut" ]]; then
|
|
|
43355b |
- # We are the initrd generator
|
|
|
43355b |
- IMAGE="initrd"
|
|
|
43355b |
- UEFI_OPTS="--no-uefi"
|
|
|
43355b |
+# Mismatching the install layout and the --uefi/--no-uefi opts just creates a mess.
|
|
|
43355b |
+if [[ $KERNEL_INSTALL_LAYOUT == "uki" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then
|
|
|
43355b |
+ BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA"
|
|
|
43355b |
+ if [[ -z $KERNEL_INSTALL_UKI_GENERATOR || $KERNEL_INSTALL_UKI_GENERATOR == "dracut" ]]; then
|
|
|
43355b |
+ # No uki generator preference set or we have been chosen
|
|
|
43355b |
+ IMAGE="uki.efi"
|
|
|
43355b |
+ UEFI_OPTS="--uefi"
|
|
|
43355b |
+ elif [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then
|
|
|
43355b |
+ # We aren't the uki generator, but we have been requested to make the initrd
|
|
|
43355b |
+ IMAGE="initrd"
|
|
|
43355b |
+ UEFI_OPTS="--no-uefi"
|
|
|
43355b |
+ else
|
|
|
43355b |
+ exit 0
|
|
|
43355b |
+ fi
|
|
|
43355b |
+elif [[ $KERNEL_INSTALL_LAYOUT == "bls" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then
|
|
|
43355b |
+ BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA"
|
|
|
43355b |
+ if [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then
|
|
|
43355b |
+ IMAGE="initrd"
|
|
|
43355b |
+ UEFI_OPTS="--no-uefi"
|
|
|
43355b |
+ else
|
|
|
43355b |
+ exit 0
|
|
|
43355b |
+ fi
|
|
|
43355b |
else
|
|
|
43355b |
- exit 0
|
|
|
43355b |
+ # No layout information, use users --uefi/--no-uefi preference
|
|
|
43355b |
+ UEFI_OPTS=""
|
|
|
43355b |
+ if [[ -d $BOOT_DIR_ABS ]]; then
|
|
|
43355b |
+ IMAGE="initrd"
|
|
|
43355b |
+ else
|
|
|
43355b |
+ BOOT_DIR_ABS="/boot"
|
|
|
43355b |
+ IMAGE="initramfs-${KERNEL_VERSION}.img"
|
|
|
43355b |
+ fi
|
|
|
43355b |
fi
|
|
|
43355b |
|
|
|
43355b |
-if [[ "$KERNEL_INSTALL_UKI_GENERATOR" = "dracut" ]]; then
|
|
|
43355b |
- # We are chosen to generate the UKI as well as initrd
|
|
|
43355b |
- IMAGE="uki.efi"
|
|
|
43355b |
- UEFI_OPTS="--uefi"
|
|
|
43355b |
-fi
|
|
|
43355b |
+ret=0
|
|
|
43355b |
|
|
|
43355b |
-if [[ -f ${KERNEL_IMAGE%/*}/$IMAGE ]]; then
|
|
|
43355b |
- # we found an initrd or uki.efi at the same place as the kernel
|
|
|
43355b |
- # use this and don't generate a new one
|
|
|
43355b |
- [[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo \
|
|
|
43355b |
- "There is an $IMAGE image at the same place as the kernel, skipping generating a new one"
|
|
|
43355b |
- cp --reflink=auto "${KERNEL_IMAGE%/*}/$IMAGE" "$KERNEL_INSTALL_STAGING_AREA/$IMAGE" \
|
|
|
43355b |
- && chown root:root "$KERNEL_INSTALL_STAGING_AREA/$IMAGE" \
|
|
|
43355b |
- && chmod 0600 "$KERNEL_INSTALL_STAGING_AREA/$IMAGE" \
|
|
|
43355b |
- && exit 0
|
|
|
43355b |
-fi
|
|
|
43355b |
+case "$COMMAND" in
|
|
|
43355b |
+ add)
|
|
|
43355b |
+ if [[ $IMAGE == "uki.efi" ]]; then
|
|
|
43355b |
+ IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/uki.efi
|
|
|
43355b |
+ else
|
|
|
43355b |
+ IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd
|
|
|
43355b |
+ fi
|
|
|
43355b |
+ if [[ -f ${IMAGE_PREGENERATED} ]]; then
|
|
|
43355b |
+ # we found an initrd or uki.efi at the same place as the kernel
|
|
|
43355b |
+ # use this and don't generate a new one
|
|
|
43355b |
+ [[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo \
|
|
|
43355b |
+ "There is an ${IMAGE} image at the same place as the kernel, skipping generating a new one"
|
|
|
43355b |
+ cp --reflink=auto "$IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$IMAGE" \
|
|
|
43355b |
+ && chown root:root "$BOOT_DIR_ABS/$IMAGE" \
|
|
|
43355b |
+ && chmod 0600 "$BOOT_DIR_ABS/$IMAGE" \
|
|
|
43355b |
+ && exit 0
|
|
|
43355b |
+ fi
|
|
|
43355b |
|
|
|
43355b |
-if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then
|
|
|
43355b |
- if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then
|
|
|
43355b |
- read -r -d '' -a BOOT_OPTIONS < "$KERNEL_INSTALL_CONF_ROOT/cmdline"
|
|
|
43355b |
- fi
|
|
|
43355b |
-elif [[ -f /etc/kernel/cmdline ]]; then
|
|
|
43355b |
- read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
|
|
|
43355b |
-elif [[ -f /usr/lib/kernel/cmdline ]]; then
|
|
|
43355b |
- read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
|
|
|
43355b |
-else
|
|
|
43355b |
- declare -a BOOT_OPTIONS
|
|
|
43355b |
+ if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then
|
|
|
43355b |
+ if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then
|
|
|
43355b |
+ read -r -d '' -a BOOT_OPTIONS < "$KERNEL_INSTALL_CONF_ROOT/cmdline"
|
|
|
43355b |
+ fi
|
|
|
43355b |
+ elif [[ -f /etc/kernel/cmdline ]]; then
|
|
|
43355b |
+ read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
|
|
|
43355b |
+ elif [[ -f /usr/lib/kernel/cmdline ]]; then
|
|
|
43355b |
+ read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
|
|
|
43355b |
+ else
|
|
|
43355b |
+ declare -a BOOT_OPTIONS
|
|
|
43355b |
|
|
|
43355b |
- read -r -d '' -a line < /proc/cmdline
|
|
|
43355b |
- for i in "${line[@]}"; do
|
|
|
43355b |
- [[ ${i#initrd=*} != "$i" ]] && continue
|
|
|
43355b |
- BOOT_OPTIONS+=("$i")
|
|
|
43355b |
- done
|
|
|
43355b |
-fi
|
|
|
43355b |
+ read -r -d '' -a line < /proc/cmdline
|
|
|
43355b |
+ for i in "${line[@]}"; do
|
|
|
43355b |
+ [[ ${i#initrd=*} != "$i" ]] && continue
|
|
|
43355b |
+ BOOT_OPTIONS+=("$i")
|
|
|
43355b |
+ done
|
|
|
43355b |
+ fi
|
|
|
43355b |
|
|
|
43355b |
-unset noimageifnotneeded
|
|
|
43355b |
+ unset noimageifnotneeded
|
|
|
43355b |
|
|
|
43355b |
-for ((i = 0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
|
|
|
43355b |
- # shellcheck disable=SC1001
|
|
|
43355b |
- if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
|
|
|
43355b |
- noimageifnotneeded="yes"
|
|
|
43355b |
- break
|
|
|
43355b |
- fi
|
|
|
43355b |
-done
|
|
|
43355b |
+ for ((i = 0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
|
|
|
43355b |
+ # shellcheck disable=SC1001
|
|
|
43355b |
+ if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
|
|
|
43355b |
+ noimageifnotneeded="yes"
|
|
|
43355b |
+ break
|
|
|
43355b |
+ fi
|
|
|
43355b |
+ done
|
|
|
43355b |
+
|
|
|
43355b |
+ # shellcheck disable=SC2046
|
|
|
43355b |
+ dracut -f \
|
|
|
43355b |
+ ${noimageifnotneeded:+--noimageifnotneeded} \
|
|
|
43355b |
+ $([[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo --verbose) \
|
|
|
43355b |
+ $([[ -n $KERNEL_IMAGE ]] && echo --kernel-image "$KERNEL_IMAGE") \
|
|
|
43355b |
+ "$UEFI_OPTS" \
|
|
|
43355b |
+ --kver "$KERNEL_VERSION" \
|
|
|
43355b |
+ "$BOOT_DIR_ABS/$IMAGE"
|
|
|
43355b |
+ ret=$?
|
|
|
43355b |
+ ;;
|
|
|
43355b |
+
|
|
|
43355b |
+ remove)
|
|
|
43355b |
+ rm -f -- "$BOOT_DIR_ABS/$IMAGE"
|
|
|
43355b |
+ ret=$?
|
|
|
43355b |
+ ;;
|
|
|
43355b |
+esac
|
|
|
43355b |
|
|
|
43355b |
-# shellcheck disable=SC2046
|
|
|
43355b |
-dracut -f \
|
|
|
43355b |
- ${noimageifnotneeded:+--noimageifnotneeded} \
|
|
|
43355b |
- $([[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo --verbose) \
|
|
|
43355b |
- $([[ -n $KERNEL_IMAGE ]] && echo --kernel-image "$KERNEL_IMAGE") \
|
|
|
43355b |
- "$UEFI_OPTS" \
|
|
|
43355b |
- --kver "$KERNEL_VERSION" \
|
|
|
43355b |
- "$KERNEL_INSTALL_STAGING_AREA/$IMAGE" || exit 1
|
|
|
43355b |
+exit $ret
|
|
|
43355b |
diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install
|
|
|
43355b |
index 25f75557..aa0ccdc5 100755
|
|
|
43355b |
--- a/install.d/51-dracut-rescue.install
|
|
|
43355b |
+++ b/install.d/51-dracut-rescue.install
|
|
|
43355b |
@@ -2,29 +2,11 @@
|
|
|
43355b |
|
|
|
43355b |
export LANG=C
|
|
|
43355b |
|
|
|
43355b |
-COMMAND="${1:?}"
|
|
|
43355b |
-KERNEL_VERSION="${2:?}"
|
|
|
43355b |
+COMMAND="$1"
|
|
|
43355b |
+KERNEL_VERSION="$2"
|
|
|
43355b |
BOOT_DIR_ABS="${3%/*}/0-rescue"
|
|
|
43355b |
KERNEL_IMAGE="$4"
|
|
|
43355b |
|
|
|
43355b |
-# If the initrd was provided on the kernel command line, we shouldn't generate our own.
|
|
|
43355b |
-if [[ "$COMMAND" = "add" && "$#" -gt 4 ]]; then
|
|
|
43355b |
- exit 0
|
|
|
43355b |
-fi
|
|
|
43355b |
-
|
|
|
43355b |
-# Do not attempt to create initramfs if the supplied image is already a UKI
|
|
|
43355b |
-if [[ "$KERNEL_INSTALL_IMAGE_TYPE" = "uki" ]]; then
|
|
|
43355b |
- exit 0
|
|
|
43355b |
-fi
|
|
|
43355b |
-
|
|
|
43355b |
-if [[ "$KERNEL_INSTALL_UKI_GENERATOR" = "dracut" ]]; then
|
|
|
43355b |
- # Rescue images currently not compatible with UKIs
|
|
|
43355b |
- exit 0
|
|
|
43355b |
-elif [[ "${KERNEL_INSTALL_INITRD_GENERATOR:-dracut}" != "dracut" ]]; then
|
|
|
43355b |
- # We are not the initrd generator
|
|
|
43355b |
- exit 0
|
|
|
43355b |
-fi
|
|
|
43355b |
-
|
|
|
43355b |
dropindirs_sort() {
|
|
|
43355b |
suffix=$1
|
|
|
43355b |
shift
|
|
|
43355b |
--
|
|
|
43355b |
2.42.0
|
|
|
43355b |
|