15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Javier Martinez Canillas <javierm@redhat.com>
15a2072
Date: Mon, 9 Jul 2018 12:19:03 +0200
15a2072
Subject: [PATCH] Fix grub-switch-to-blscfg boot prefix handling
15a2072
15a2072
Commit b3ac18e3265f ("grub-switch-to-blscfg.in: Better boot prefix checking")
15a2072
simplified the boot prefix checking, but unfortunately introduced a couple of
15a2072
regressions on the script. Fix them.
15a2072
15a2072
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
15a2072
---
15a2072
 util/grub-switch-to-blscfg.in | 12 +++++++-----
15a2072
 1 file changed, 7 insertions(+), 5 deletions(-)
15a2072
15a2072
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
15a2072
index 2f37a1f740b..40612e00686 100644
15a2072
--- a/util/grub-switch-to-blscfg.in
15a2072
+++ b/util/grub-switch-to-blscfg.in
15a2072
@@ -220,7 +220,8 @@ EOF
15a2072
 
15a2072
 for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
     bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
15a2072
-    linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')"
15a2072
+    linux="/vmlinuz-${kernelver}"
15a2072
+    linux_path="/boot${linux}"
15a2072
     kernel_dir="/lib/modules/${kernelver}"
15a2072
 
15a2072
     if [ ! -d "${kernel_dir}" ] ; then
15a2072
@@ -230,8 +231,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
         continue
15a2072
     fi
15a2072
 
15a2072
-    linux_relpath="$("${grub_mkrelpath}" "${linux}")"
15a2072
-    bootprefix="${linux%%"${linux_relpath}"}"
15a2072
+    linux_relpath="$("${grub_mkrelpath}" "${linux_path}")"
15a2072
+    bootprefix="${linux_relpath%%"${linux}"}"
15a2072
 
15a2072
     if [ -f "${kernel_dir}/bls.conf" ] ; then
15a2072
         cp -af "${kernel_dir}/bls.conf" "${bls_target}"
15a2072
@@ -243,7 +244,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
     fi
15a2072
 
15a2072
     if [ -n "${bootprefix}" ]; then
15a2072
-        sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}"
15a2072
+        sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}"
15a2072
+        sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}"
15a2072
     fi
15a2072
 
15a2072
     if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
15a2072
@@ -258,7 +260,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
15a2072
     fi
15a2072
 done
15a2072
 
15a2072
-if [ -n "${bootprefix}" -a -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
15a2072
+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
15a2072
     mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
15a2072
 fi
15a2072