Blame SOURCES/0144-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Javier Martinez Canillas <javierm@redhat.com>
8631a2
Date: Wed, 11 Apr 2018 11:49:24 +0200
8631a2
Subject: [PATCH] Make grub2-switch-to-blscfg to generate debug BLS when
8631a2
 MAKEDEBUG is set
8631a2
8631a2
If MAKEDEBUG=yes in /etc/sysconfig/kernel, then a debug menu entry should
8631a2
be created. So for BLS, a debug configuration file has to be created that
8631a2
contains additional debug kernel command line parameters.
8631a2
8631a2
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
8631a2
---
8631a2
 util/grub-switch-to-blscfg.in | 15 +++++++++++++++
8631a2
 1 file changed, 15 insertions(+)
8631a2
8631a2
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
b32e65
index eae3c379e..c59299ffa 100644
8631a2
--- a/util/grub-switch-to-blscfg.in
8631a2
+++ b/util/grub-switch-to-blscfg.in
8631a2
@@ -21,6 +21,7 @@
8631a2
 # Initialize some variables.
8631a2
 prefix=@prefix@
8631a2
 exec_prefix=@exec_prefix@
8631a2
+sbindir=@sbindir@
8631a2
 bindir=@bindir@
8631a2
 sysconfdir="@sysconfdir@"
8631a2
 PACKAGE_NAME=@PACKAGE_NAME@
8631a2
@@ -33,9 +34,12 @@ fi
8631a2
 
8631a2
 self=`basename $0`
8631a2
 
8631a2
+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
8631a2
 grub_editenv=${bindir}/@grub_editenv@
8631a2
 etcdefaultgrub=/etc/default/grub
8631a2
 
8631a2
+eval "$("${grub_get_kernel_settings}")" || true
8631a2
+
8631a2
 EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/')
8631a2
 if [ -d /sys/firmware/efi/efivars/ ]; then
8631a2
     startlink=/etc/grub2-efi.cfg
8631a2
@@ -226,6 +230,17 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
8631a2
             "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \
8631a2
             >"${bls_target}"
8631a2
     fi
8631a2
+
8631a2
+    if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
8631a2
+        arch="$(uname -m)"
8631a2
+        bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")"
8631a2
+        cp -aT  "${bls_target}" "${bls_debug}"
8631a2
+        title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')"
8631a2
+        blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")"
8631a2
+        sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}"
8631a2
+        sed -i -e "s/^id.*/${blsid}/" "${bls_debug}"
8631a2
+        sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}"
8631a2
+    fi
8631a2
 done
8631a2
 
8631a2
 GENERATE=0