nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0159-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Peter Jones <pjones@redhat.com>
8631a2
Date: Fri, 22 Jun 2018 14:04:28 -0400
8631a2
Subject: [PATCH] grub-switch-to-blscfg.in: Better boot prefix checking
8631a2
8631a2
Signed-off-by: Peter Jones <pjones@redhat.com>
8631a2
---
8631a2
 util/grub-switch-to-blscfg.in | 36 +++++++++++++++++-------------------
8631a2
 1 file changed, 17 insertions(+), 19 deletions(-)
8631a2
8631a2
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
09e3cc
index dac41e738..884cf45b1 100644
8631a2
--- a/util/grub-switch-to-blscfg.in
8631a2
+++ b/util/grub-switch-to-blscfg.in
8631a2
@@ -219,30 +219,31 @@ EOF
8631a2
 }
8631a2
 
8631a2
 for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
8631a2
-    if [ ! -d "/lib/modules/${kernelver}" ] ; then
8631a2
-        continue
8631a2
-    fi
8631a2
-    if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then
8631a2
-        continue
8631a2
-    fi
8631a2
     bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
8631a2
+    linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')"
8631a2
     kernel_dir="/lib/modules/${kernelver}"
8631a2
-    if [ -f "${kernel_dir}/bls.conf" ]; then
8631a2
+
8631a2
+    if [ ! -d "${kernel_dir}" ] ; then
8631a2
+        continue
8631a2
+    fi
8631a2
+    if [ ! -f "${linux_path}" ]; then
8631a2
+        continue
8631a2
+    fi
8631a2
+
8631a2
+    linux_relpath="$("${grub_mkrelpath}" "${linux}")"
8631a2
+    bootprefix="${linux%%"${linux_relpath}"}"
8631a2
+
8631a2
+    if [ -f "${kernel_dir}/bls.conf" ] ; then
8631a2
         cp -af "${kernel_dir}/bls.conf" "${bls_target}"
8631a2
     else
8631a2
         mkbls "${kernelver}" \
8631a2
             "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
8631a2
+            "${bootprefix}" \
8631a2
             >"${bls_target}"
8631a2
     fi
8631a2
 
8631a2
-    linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]*,,')"
8631a2
-    initrd="$(grep '^initrd[ \t]' "${bls_target}" | sed -e 's,^initrd[ \t]*,,')"
8631a2
-    linux_relpath="$("${grub_mkrelpath}" /boot/$linux)"
8631a2
-    initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)"
8631a2
-
8631a2
-    if [ $linux != $linux_relpath ] ; then
8631a2
-        sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}"
8631a2
-        sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}"
8631a2
+    if [ -n "${bootprefix}" ]; then
8631a2
+        sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}"
8631a2
     fi
8631a2
 
8631a2
     if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
8631a2
@@ -257,10 +258,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
8631a2
     fi
8631a2
 done
8631a2
 
8631a2
-if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
8631a2
-    if [ $linux != $linux_relpath ]; then
8631a2
-        bootprefix="$(dirname ${linux_relpath})"
8631a2
-    fi
8631a2
+if [ -n "${bootprefix}" -a -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