From e07352f756ba883f238810ccd40b2961333a9344 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9rgio=20M=2E=20Basto?= <sergio@serjux.com>
Date: Sat, 31 Dec 2022 19:47:34 +0000
Subject: [PATCH] (#1768132) if new Fedora Release regenerate rescue entry
---
install.d/51-dracut-rescue.install | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/install.d/51-dracut-rescue.install b/install.d/51-dracut-rescue.install
index 8bf9a6d9..afd3c4ee 100755
--- a/install.d/51-dracut-rescue.install
+++ b/install.d/51-dracut-rescue.install
@@ -75,6 +75,19 @@ ret=0
case "$COMMAND" in
add)
+ if [[ -e "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" ]]; then
+ FILE_ENTRY="${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf"
+ else
+ FILE_ENTRY="${KERNEL_IMAGE%/*}/bls.conf"
+ fi
+ check=$(/usr/bin/cmp --silent <(sed "s/${KERNEL_VERSION}/0-rescue-${MACHINE_ID}/" $FILE_ENTRY) $LOADER_ENTRY ; echo $?)
+ if [[ $check -ne 0 ]] then
+ # LOADER_ENTRY is different from this release
+ # we need delete initrd and img to generate them again
+ [[ -f "$BOOT_DIR_ABS/$INITRD" ]] && rm "$BOOT_DIR_ABS/$INITRD"
+ [[ -f "$BOOT_DIR_ABS/$KERNEL" ]] && rm "$BOOT_DIR_ABS/$KERNEL"
+ fi
+
[[ -f "$LOADER_ENTRY" ]] && [[ -f "$BOOT_DIR_ABS/$KERNEL" ]] \
&& [[ -f "$BOOT_DIR_ABS/$INITRD" ]] && exit 0
@@ -110,11 +123,7 @@ case "$COMMAND" in
echo "initrd $BOOT_DIR/initrd"
} > "$LOADER_ENTRY"
else
- if [[ -e "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" ]]; then
- cp -aT "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" "$LOADER_ENTRY"
- else
- cp -aT "${KERNEL_IMAGE%/*}/bls.conf" "$LOADER_ENTRY"
- fi
+ cp -aT "$FILE_ENTRY" "$LOADER_ENTRY"
sed -i "s/${KERNEL_VERSION}/0-rescue-${MACHINE_ID}/" "$LOADER_ENTRY"
fi
--
2.38.1