Blame SOURCES/0162-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch

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