dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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