grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] Fix bad test on GRUB_DISABLE_SUBMENU.


From: Javier Martinez Canillas
Subject: [PATCH v2] Fix bad test on GRUB_DISABLE_SUBMENU.
Date: Mon, 30 Sep 2019 17:00:16 +0200

From: Prarit Bhargava <address@hidden>

The GRUB_DISABLE_SUBMENU option is different than the others in the sense
that it has to be set to "y" instead of "true" to be enabled.

That causes a lot of confusion to users, some may wrongly set it to "true"
expecting that will work the same than with most options, and some may set
it to "yes" since for other options the value to set is a word and not a
single character.

This patch changes all the grub.d scripts using the GRUB_DISABLE_SUBMENU
option, so they check if it was set to "true" instead of "y", making it
consistent with all the other options.

But to keep backward compatibility for users that set the option to "y" in
/etc/default/grub file, keep testing for this value. And also do it for
"yes", since it is a common mistake made by users caused by this option
being inconsistent with the others.

Signed-off-by: Prarit Bhargava <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>


---

Changes since v1 (suggested by Daniel Kiper):

- Improve commit message to better explain why the change is needed.
- Fix not only 10_linux.in but all the grub.d scripts using this
  option.
- Add a comment explaining why the values 'y', 'yes' and true'
  are tested for this option.
- Fix the documentation so it mentions that the value to set is
  'true' instead of 'y'.

 docs/grub.texi              |  2 +-
 util/grub.d/10_hurd.in      | 10 +++++++++-
 util/grub.d/10_kfreebsd.in  | 10 +++++++++-
 util/grub.d/10_linux.in     | 10 +++++++++-
 util/grub.d/10_netbsd.in    | 10 +++++++++-
 util/grub.d/20_linux_xen.in | 10 +++++++++-
 util/grub.d/30_os-prober.in | 10 +++++++++-
 7 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index 2fe0e1b83bb..c25ab7a5fe7 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1504,7 +1504,7 @@ Normally, @command{grub-mkconfig} will generate top level 
menu entry for
 the kernel with highest version number and put all other found kernels
 or alternative menu entries for recovery mode in submenu. For entries returned
 by @command{os-prober} first entry will be put on top level and all others
-in submenu. If this option is set to @samp{y}, flat menu with all entries
+in submenu. If this option is set to @samp{true}, flat menu with all entries
 on top level will be generated instead. Changing this option will require
 changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} 
(@pxref{fallback})
 and @samp{default} (@pxref{default}) environment variables as well as saved
diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in
index 59a9a48a2f4..3663d360eb1 100644
--- a/util/grub.d/10_hurd.in
+++ b/util/grub.d/10_hurd.in
@@ -156,7 +156,15 @@ is_top_level=true
 while [ "x$kernels" != "x" ] ; do
   kernel=`version_find_latest $kernels`
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  # The GRUB_DISABLE_SUBMENU option used to be different than others since it 
was
+  # mentioned in the documentation that has to be set to 'y' instead of 'true' 
to
+  # enable it. This caused a lot of confusion to users that set the option to 
'y',
+  # 'yes' or 'true'. This was fixed but all of these values must be supported 
now.
+  if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = 
xy ]; then
+      GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; 
then
       hurd_entry "$kernel" simple
       submenu_indentation="$grub_tab"
     
diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in
index 9d8e8fd852c..199b20e1636 100644
--- a/util/grub.d/10_kfreebsd.in
+++ b/util/grub.d/10_kfreebsd.in
@@ -214,7 +214,15 @@ while [ "x$list" != "x" ] ; do
     module_dir_rel=$(make_system_path_relative_to_its_root $module_dir)
   fi
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  # The GRUB_DISABLE_SUBMENU option used to be different than others since it 
was
+  # mentioned in the documentation that has to be set to 'y' instead of 'true' 
to
+  # enable it. This caused a lot of confusion to users that set the option to 
'y',
+  # 'yes' or 'true'. This was fixed but all of these values must be supported 
now.
+  if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = 
xy ]; then
+      GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; 
then
       kfreebsd_entry "${OS}" "${version}" simple
       submenu_indentation="$grub_tab"
     
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 4532266be68..e8b01c0d0c7 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -261,7 +261,15 @@ while [ "x$list" != "x" ] ; do
     fi
   fi
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  # The GRUB_DISABLE_SUBMENU option used to be different than others since it 
was
+  # mentioned in the documentation that has to be set to 'y' instead of 'true' 
to
+  # enable it. This caused a lot of confusion to users that set the option to 
'y',
+  # 'yes' or 'true'. This was fixed but all of these values must be supported 
now.
+  if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = 
xy ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; 
then
     linux_entry "${OS}" "${version}" simple \
     "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
 
diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in
index 874f59969ed..dc0cd1b17ac 100644
--- a/util/grub.d/10_netbsd.in
+++ b/util/grub.d/10_netbsd.in
@@ -157,7 +157,15 @@ for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do
 
   gettext_printf "Found NetBSD kernel: %s\n" "$k" >&2
 
-  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
+  # The GRUB_DISABLE_SUBMENU option used to be different than others since it 
was
+  # mentioned in the documentation that has to be set to 'y' instead of 'true' 
to
+  # enable it. This caused a lot of confusion to users that set the option to 
'y',
+  # 'yes' or 'true'. This was fixed but all of these values must be supported 
now.
+  if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ "x${GRUB_DISABLE_SUBMENU}" = 
xy ]; then
+    GRUB_DISABLE_SUBMENU="true"
+  fi
+
+  if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; 
then
       netbsd_entry "knetbsd"   "$k" simple "${GRUB_CMDLINE_NETBSD_DEFAULT}"
     submenu_indentation="$grub_tab"
     
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 96179ea613c..391942a5922 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -288,7 +288,15 @@ while [ "x${xen_list}" != "x" ] ; do
            fi
        fi
 
-       if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy 
]; then
+       # The GRUB_DISABLE_SUBMENU option used to be different than others 
since it was
+       # mentioned in the documentation that has to be set to 'y' instead of 
'true' to
+       # enable it. This caused a lot of confusion to users that set the 
option to 'y',
+       # 'yes' or 'true'. This was fixed but all of these values must be 
supported now.
+       if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ 
"x${GRUB_DISABLE_SUBMENU}" = xy ]; then
+           GRUB_DISABLE_SUBMENU="true"
+       fi
+
+       if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != 
xtrue ]; then
            linux_entry "${OS}" "${version}" "${xen_version}" simple \
                "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" 
"${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
 
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 515a68c7aa0..cf42f55e8b4 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -234,7 +234,15 @@ EOF
          prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | 
grub_add_tab)"
        fi
 
-       if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy 
]; then
+       # The GRUB_DISABLE_SUBMENU option used to be different than others 
since it was
+       # mentioned in the documentation that has to be set to 'y' instead of 
'true' to
+       # enable it. This caused a lot of confusion to users that set the 
option to 'y',
+       # 'yes' or 'true'. This was fixed but all of these values must be 
supported now.
+       if [ "x${GRUB_DISABLE_SUBMENU}" = xyes ] || [ 
"x${GRUB_DISABLE_SUBMENU}" = xy ]; then
+           GRUB_DISABLE_SUBMENU="true"
+       fi
+
+       if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != 
xtrue ]; then
             cat << EOF
 menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class 
gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' 
{
 EOF
-- 
2.21.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]