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