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

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