Harald Hoyer fe68ba
From f8c24964cdde2b8c1569ab33225108573682d3b7 Mon Sep 17 00:00:00 2001
Harald Hoyer fe68ba
From: Javier Martinez Canillas <javierm@redhat.com>
Harald Hoyer fe68ba
Date: Fri, 9 Mar 2018 18:54:49 +0100
Harald Hoyer fe68ba
Subject: [PATCH] 51-dracut-rescue.install: fix initramfs not generated in
Harald Hoyer fe68ba
 /boot case
Harald Hoyer fe68ba
Harald Hoyer fe68ba
Commit 5e574046e76e ("5?-dracut*.install: Allow scripts to install
Harald Hoyer fe68ba
the initramfs in /boot dir") added support to generate initramfs
Harald Hoyer fe68ba
images in the /boot directory and copy the respective BLS files.
Harald Hoyer fe68ba
Harald Hoyer fe68ba
Unfortunately, it broke the rescue initramfs generation when it's
Harald Hoyer fe68ba
not installed on /boot due not checking for the correct condition.
Harald Hoyer fe68ba
Harald Hoyer fe68ba
It checks for the 0-rescue sub-dir to exist, but this is created so
Harald Hoyer fe68ba
instead if the parent sub-dir exists has to be checked. Also, check
Harald Hoyer fe68ba
if the destination directory is /boot or not, instead if it exists.
Harald Hoyer fe68ba
Harald Hoyer fe68ba
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Harald Hoyer fe68ba
---
Harald Hoyer fe68ba
 51-dracut-rescue.install | 4 ++--
Harald Hoyer fe68ba
 1 file changed, 2 insertions(+), 2 deletions(-)
Harald Hoyer fe68ba
Harald Hoyer fe68ba
diff --git a/51-dracut-rescue.install b/51-dracut-rescue.install
Harald Hoyer fe68ba
index 3f07a698..679e94b1 100755
Harald Hoyer fe68ba
--- a/51-dracut-rescue.install
Harald Hoyer fe68ba
+++ b/51-dracut-rescue.install
Harald Hoyer fe68ba
@@ -63,7 +63,7 @@ if ! [[ ${BOOT_OPTIONS[*]} ]]; then
Harald Hoyer fe68ba
     exit 1
Harald Hoyer fe68ba
 fi
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-if [[ -d "$BOOT_DIR_ABS" ]]; then
Harald Hoyer fe68ba
+if [[ -d "${BOOT_DIR_ABS%/*}" ]]; then
Harald Hoyer fe68ba
     BOOT_DIR="/${MACHINE_ID}/0-rescue"
Harald Hoyer fe68ba
     BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
Harald Hoyer fe68ba
     LOADER_ENTRY="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf"
Harald Hoyer fe68ba
@@ -106,7 +106,7 @@ case "$COMMAND" in
Harald Hoyer fe68ba
             ((ret+=$?))
Harald Hoyer fe68ba
         fi
Harald Hoyer fe68ba
 
Harald Hoyer fe68ba
-        if [[ -d "$BOOT_DIR" ]]; then
Harald Hoyer fe68ba
+        if [[ "${BOOT_DIR_ABS}" != "/boot" ]]; then
Harald Hoyer fe68ba
             {
Harald Hoyer fe68ba
                 echo "title      $PRETTY_NAME - Rescue Image"
Harald Hoyer fe68ba
                 echo "version    $KERNEL_VERSION"
Harald Hoyer fe68ba