1 From 81e46875469ae8b2a803e6457784801a0a7a7963 Mon Sep 17 00:00:00 2001
2 From: Prarit Bhargava <prarit@redhat.com>
3 Date: Thu, 7 Feb 2013 11:53:41 -0500
4 Subject: [PATCH] add GRUB_DISABLE_SUBMENU option
6 This patch adds the ability to disable the grub2 submenus from
9 To disable the submenus
11 echo 'GRUB_DISABLE_SUBMENU="true"' >> /etc/default/grub
15 util/grub-mkconfig.in | 3 ++-
16 util/grub.d/10_linux.in | 24 ++++++++++++++----------
17 2 files changed, 16 insertions(+), 11 deletions(-)
19 diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
20 index 516be86..354eb43 100644
21 --- a/util/grub-mkconfig.in
22 +++ b/util/grub-mkconfig.in
23 @@ -216,7 +216,8 @@ export GRUB_DEFAULT \
26 GRUB_ENABLE_CRYPTODISK \
29 + GRUB_DISABLE_SUBMENU
31 if test "x${grub_cfg}" != "x"; then
32 rm -f "${grub_cfg}.new"
33 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
34 index e2b8ab3..9427a39 100644
35 --- a/util/grub.d/10_linux.in
36 +++ b/util/grub.d/10_linux.in
37 @@ -240,17 +240,19 @@ while [ "x$list" != "x" ] ; do
38 linux_root_device_thisversion=${GRUB_DEVICE}
41 - if [ "x$is_first_entry" = xtrue ]; then
42 - linux_entry "${OS}" "${version}" simple \
43 - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
44 + if [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
45 + if [ "x$is_first_entry" = xtrue ]; then
46 + linux_entry "${OS}" "${version}" simple \
47 + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
49 - submenu_indentation="\t"
50 + submenu_indentation="\t"
52 - if [ -z "$boot_device_id" ]; then
53 - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
54 + if [ -z "$boot_device_id" ]; then
55 + boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
57 + # TRANSLATORS: %s is replaced with an OS name
58 + echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
60 - # TRANSLATORS: %s is replaced with an OS name
61 - echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
64 linux_entry "${OS}" "${version}" advanced \
65 @@ -266,8 +268,10 @@ done
67 # If at least one kernel was found, then we need to
68 # add a closing '}' for the submenu command.
69 -if [ x"$is_first_entry" != xtrue ]; then
71 +if [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
72 + if [ x"$is_first_entry" != xtrue ]; then
77 echo "$title_correction_code"
78 --- grub-2.00/util/grub.d/20_linux_xen.in~ 2013-04-15 00:03:09.162253769 +0200
79 +++ grub-2.00/util/grub.d/20_linux_xen.in 2013-04-15 00:18:49.254774567 +0200
81 linux_root_device_thisversion=${GRUB_DEVICE}
84 - if [ "x$is_first_entry" = xtrue ]; then
85 + if [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
86 + if [ "x$is_first_entry" = xtrue ]; then
87 linux_entry "${OS}" "${version}" "${xen_version}" simple \
88 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
92 # TRANSLATORS: %s is replaced with an OS name
93 echo "submenu '$(gettext_printf "Advanced options for %s (with Xen hypervisor)" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
94 - echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
95 + echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
97 + is_first_entry=false
99 - is_first_entry=false
101 linux_entry "${OS}" "${version}" "${xen_version}" advanced \
102 "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
105 list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
107 - if [ x"$is_first_entry" != xtrue ]; then
108 + if [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
109 + if [ x"$is_first_entry" != xtrue ]; then
113 xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`