Skip to contentSkip to conversation

Odd problem with submenus

DISCUSSION John Haxby 2 participants 4 messages Jul 1, 2014 – Jul 3, 2014

lore
Share & tools
lore

John Haxby

author
#0 lore raw

Hello,

I have a warning generated by grub2-mkconfig that shows up on various systems that I'm not sure what to do about. Well, I know I can ignore it, but I'm not sure what do do about not getting the warning in the first place.

On this machine here, I have

menuentry 'Fedora, with Linux 3.14.9-200.fc20.x86_64' --class ...

and grub2-set-default 'Fedora, with ...' is OK, but then

and I also have GRUB_DISABLE_SUBMENU=true i /etc/default/grub, so

$ grub2-mkconfig -o /boot/grub2/grub.cfg
...
Warning: Please don't use old title `Fedora, with Linux
3.14.9-200.fc20.x86_64' for GRUB_DEFAULT, use `Advanced options for
Fedora>Fedora, with Linux 3.14.9-200.fc20.x86_64' (for versions before
2.00) or
`gnulinux-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb>gnulinux-3.14.9-200.fc20.x86_64-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb'
(for 2.00 or later)

Exhorting me to use a submenu default when there are no submenus is clearly wrong, so in /etc/grub.d/10_linux (and the other platform-specific files) there's:

Quoted 6 lines
      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi

It's easy enough to add a test for GRUB_DISABLE_SUBMENU here but I'm at a loss to know why this clause is needed at all. I know it means that if I have submenus enabled then I can just set the default to be the title of a submenu and not worry about the "Advanced options ..." bit, but it looks to me as though it was just a transition thing which is really no longer needed.

Is this really no longer needed or am I missing something? I'm happy to submit a patch either way.

jch

#1 lore raw

В Tue, 01 Jul 2014 17:59:35 +0100
John Haxby <[email protected]> пишет:

Quoted 35 lines

Hello,

I have a warning generated by grub2-mkconfig that shows up on various systems that I'm not sure what to do about. Well, I know I can ignore it, but I'm not sure what do do about not getting the warning in the first place.

On this machine here, I have

menuentry 'Fedora, with Linux 3.14.9-200.fc20.x86_64' --class ...

and grub2-set-default 'Fedora, with ...' is OK, but then

and I also have GRUB_DISABLE_SUBMENU=true i /etc/default/grub, so

$ grub2-mkconfig -o /boot/grub2/grub.cfg
...
Warning: Please don't use old title `Fedora, with Linux
3.14.9-200.fc20.x86_64' for GRUB_DEFAULT, use `Advanced options for
Fedora>Fedora, with Linux 3.14.9-200.fc20.x86_64' (for versions before
2.00) or
`gnulinux-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb>gnulinux-3.14.9-200.fc20.x86_64-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb'
(for 2.00 or later)

Exhorting me to use a submenu default when there are no submenus is clearly wrong, so in /etc/grub.d/10_linux (and the other platform-specific files) there's:

Quoted 6 lines
      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi
Quoted 7 lines

It's easy enough to add a test for GRUB_DISABLE_SUBMENU here but I'm at a loss to know why this clause is needed at all. I know it means that if I have submenus enabled then I can just set the default to be the title of a submenu and not worry about the "Advanced options ..." bit, but it looks to me as though it was just a transition thing which is really no longer needed.

You never know it; there is no reason to break working configuration.

Quoted 3 lines

Is this really no longer needed or am I missing something? I'm happy to submit a patch either way.

Yes, please, make it conditionally add submenu title to replacement_title based on GRUB_DISABLE_SUBMENU. Please also fix all scripts (the bug is not limited to linux).

author
#2 lore raw
Quoted 47 lines · Andrey Borzenkov

В Tue, 01 Jul 2014 17:59:35 +0100
John Haxby <[email protected]> пишет:

Quoted 35 lines
Quoted 35 lines

Hello,

I have a warning generated by grub2-mkconfig that shows up on various systems that I'm not sure what to do about. Well, I know I can ignore it, but I'm not sure what do do about not getting the warning in the first place.

On this machine here, I have

menuentry 'Fedora, with Linux 3.14.9-200.fc20.x86_64' --class ...

and grub2-set-default 'Fedora, with ...' is OK, but then

and I also have GRUB_DISABLE_SUBMENU=true i /etc/default/grub, so

$ grub2-mkconfig -o /boot/grub2/grub.cfg
...
Warning: Please don't use old title `Fedora, with Linux
3.14.9-200.fc20.x86_64' for GRUB_DEFAULT, use `Advanced options for
Fedora>Fedora, with Linux 3.14.9-200.fc20.x86_64' (for versions before
2.00) or
`gnulinux-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb>gnulinux-3.14.9-200.fc20.x86_64-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb'
(for 2.00 or later)

Exhorting me to use a submenu default when there are no submenus is clearly wrong, so in /etc/grub.d/10_linux (and the other platform-specific files) there's:

Quoted 6 lines
Quoted 6 lines
      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi
Quoted 7 lines
Quoted 7 lines

It's easy enough to add a test for GRUB_DISABLE_SUBMENU here but I'm at a loss to know why this clause is needed at all. I know it means that if I have submenus enabled then I can just set the default to be the title of a submenu and not worry about the "Advanced options ..." bit, but it looks to me as though it was just a transition thing which is really no longer needed.

You never know it; there is no reason to break working configuration.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Is this really no longer needed or am I missing something? I'm happy to submit a patch either way.

Yes, please, make it conditionally add submenu title to replacement_title based on GRUB_DISABLE_SUBMENU. Please also fix all scripts (the bug is not limited to linux).

Happy to oblige.

Actually, there are two problems. The various GRUB_DISABLE_* options all check for "true" with the exception of GRUB_DISABLE_SUBMENU which
checks for "y". This is likely to cause some confusion, not least
because Fedora and RHEL7 are both using "true". I'll work on two patches ...

My long-time preferred solution for things like this[1], though is to define functions like this:

    case x"$DISABLE_GRUB_SUBMENU" in
       xy*|xtrue|x1)  disable_grub_submenu () { return 0; } ;;
       *) disable_grub_submenu () { return 1; } ;;
    esac

And then I can do

if disable_grub_submenu; then ...

which I think is easier to read and gets all of the confusion about what constitutes truth into a single place.

jch

[1] since before bash, probably

#3 lore raw

В Thu, 03 Jul 2014 15:38:26 +0100
John Haxby <[email protected]> пишет:

Quoted 48 lines · Andrey Borzenkov
Quoted 47 lines

В Tue, 01 Jul 2014 17:59:35 +0100
John Haxby <[email protected]> пишет:

Quoted 35 lines
Quoted 35 lines

Hello,

I have a warning generated by grub2-mkconfig that shows up on various systems that I'm not sure what to do about. Well, I know I can ignore it, but I'm not sure what do do about not getting the warning in the first place.

On this machine here, I have

menuentry 'Fedora, with Linux 3.14.9-200.fc20.x86_64' --class ...

and grub2-set-default 'Fedora, with ...' is OK, but then

and I also have GRUB_DISABLE_SUBMENU=true i /etc/default/grub, so

$ grub2-mkconfig -o /boot/grub2/grub.cfg
...
Warning: Please don't use old title `Fedora, with Linux
3.14.9-200.fc20.x86_64' for GRUB_DEFAULT, use `Advanced options for
Fedora>Fedora, with Linux 3.14.9-200.fc20.x86_64' (for versions before
2.00) or
`gnulinux-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb>gnulinux-3.14.9-200.fc20.x86_64-advanced-d87b5f54-5bfb-45bd-b300-f4b1db6d5dfb'
(for 2.00 or later)

Exhorting me to use a submenu default when there are no submenus is clearly wrong, so in /etc/grub.d/10_linux (and the other platform-specific files) there's:

Quoted 6 lines
Quoted 6 lines
      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
          quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
          title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
          grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi
Quoted 7 lines
Quoted 7 lines

It's easy enough to add a test for GRUB_DISABLE_SUBMENU here but I'm at a loss to know why this clause is needed at all. I know it means that if I have submenus enabled then I can just set the default to be the title of a submenu and not worry about the "Advanced options ..." bit, but it looks to me as though it was just a transition thing which is really no longer needed.

You never know it; there is no reason to break working configuration.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Is this really no longer needed or am I missing something? I'm happy to submit a patch either way.

Yes, please, make it conditionally add submenu title to replacement_title based on GRUB_DISABLE_SUBMENU. Please also fix all scripts (the bug is not limited to linux).

Which is not enough, sorry. We of course should omit title correction in this case if default is already correct (without submenu). I.e. something like this

      if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" -a x"$GRUB_DISABLE_SUBMENU" != xy] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
          if [ x$GRUB_DISABLE_SUBMENU = xy ] ; then
            replacement_title=
          else
            replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>"
          fi
          replacement_title="$replacement_title""$(echo "$title" | sed 's,>,>>,g')"

Not sure if less convoluted condition is possible. Ideas are welcome :)

Quoted 5 lines

Happy to oblige.

Actually, there are two problems. The various GRUB_DISABLE_* options all check for "true" with the exception of GRUB_DISABLE_SUBMENU which checks for "y".

There is also GRUB_ENABLE_CRYPTODISK.

Quoted 4 lines

This is likely to cause some confusion, not least
because Fedora and RHEL7 are both using "true". I'll work on two patches ...

Well, let's keep them separate. First is clear bug fix, second is nice to have.

Quoted 12 lines

My long-time preferred solution for things like this[1], though is to define functions like this:

    case x"$DISABLE_GRUB_SUBMENU" in
       xy*|xtrue|x1)  disable_grub_submenu () { return 0; } ;;
       *) disable_grub_submenu () { return 1; } ;;
    esac

And then I can do

if disable_grub_submenu; then ...

But do not forget to fix also other places where GRUB_ENABLE_CRYPTODISK is used (grub-install).

Quoted 14 lines

which I think is easier to read and gets all of the confusion about what constitutes truth into a single place.

jch

[1] since before bash, probably

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel