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