Blob Blame History Raw
From 08d16ac5e3849e2c0b73aa57adc745dbc3a73aad Mon Sep 17 00:00:00 2001
From: Prarit Bhargava <prarit@redhat.com>
Date: Thu, 7 Feb 2013 11:53:41 -0500
Subject: [PATCH 459/482] add GRUB_DISABLE_SUBMENU option

This patch adds the ability to disable the grub2 submenus from
/etc/default/grub

To disable the submenus

echo 'GRUB_DISABLE_SUBMENU="true"' >> /etc/default/grub
---
 util/grub-mkconfig.in   |  3 ++-
 util/grub.d/10_linux.in | 24 ++++++++++++++----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 8decc1d..ea42cab 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -215,7 +215,8 @@ export GRUB_DEFAULT \
   GRUB_INIT_TUNE \
   GRUB_SAVEDEFAULT \
   GRUB_ENABLE_CRYPTODISK \
-  GRUB_BADRAM
+  GRUB_BADRAM \
+  GRUB_DISABLE_SUBMENU
 
 if test "x${grub_cfg}" != "x"; then
   rm -f "${grub_cfg}.new"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 4807d84..d7ea670 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -240,17 +240,19 @@ while [ "x$list" != "x" ] ; do
     linux_root_device_thisversion=${GRUB_DEVICE}
   fi
 
-  if [ "x$is_first_entry" = xtrue ]; then
-    linux_entry "${OS}" "${version}" simple \
-    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+  if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
+    if [ "x$is_first_entry" = xtrue ]; then
+      linux_entry "${OS}" "${version}" simple \
+      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
 
-    submenu_indentation="$grub_tab"
+      submenu_indentation="$grub_tab"
     
-    if [ -z "$boot_device_id" ]; then
-	boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
+      if [ -z "$boot_device_id" ]; then
+	  boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
+      fi
+      # TRANSLATORS: %s is replaced with an OS name
+      echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
     fi
-    # TRANSLATORS: %s is replaced with an OS name
-    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
   fi
 
   linux_entry "${OS}" "${version}" advanced \
@@ -266,8 +268,10 @@ done
 
 # If at least one kernel was found, then we need to
 # add a closing '}' for the submenu command.
-if [ x"$is_first_entry" != xtrue ]; then
-  echo '}'
+if [ "x${GRUB_DISABLE_SUBMENU}" = x ]; then
+  if [ x"$is_first_entry" != xtrue ]; then
+    echo '}'
+  fi
 fi
 
 echo "$title_correction_code"
-- 
1.8.2.1