efi: add feature_efifwsetup_check
PATCH 1/1 efi: add feature_efifwsetup_check
In commit 26031d3b1 (efi: Don't display a uefi-firmware entry if it's not supported, 2022-08-18) an unconditional call to fwsetup --is-supported was added which causes the system to reboot if grub-install hasn't been run because fwsetup doesn't have the new option.
This is a huge regression.
To make sure fwsetup --is-supported works we add a new feature that only newer GRUB installations have: feature_efifwsetup_check.
If the feature is available the current behavior is maintained (fwsetup --is-supported) but if it's not available the behavior before 26031d3b1 is maintained (unconditionally show the menu entry on EFI platforms).
Also do this only on the EFI platform as Dimitri John Ledkov suggested.
--- grub-core/normal/main.c | 2 +- util/grub.d/30_uefi-firmware.in | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-)
grub-core/normal/main.c +1 -1
@@ -506,7 +506,7 @@ static const char *features[] = {"feature_chainloader_bpb" ,"feature_ntldr" ,"feature_platform_search_hint" ,"feature_default_font_path" ,"feature_all_video_module" ,"feature_menuentry_id" ,"feature_menuentry_options" ,"feature_200_final" , -"feature_nativedisk_cmd" ,"feature_timeout_style" +"feature_nativedisk_cmd" ,"feature_timeout_style" ,"feature_efifwsetup_check" };GRUB_MOD_INIT (normal)
util/grub.d/30_uefi-firmware.in +11 -5
@@ -31,10 +31,16 @@ LABEL="UEFI Firmware Settings" gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 cat << EOF -fwsetup --is-supported -if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then - menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { - fwsetup - } +if [ "\$grub_platform" = "efi" ]; then + if [ "\$feature_efifwsetup_check" = "y" ] ; then + fwsetup --is-supported + else + true + fi + if [ "\$?" = 0 ]; then + menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { + fwsetup + } + fi fi EOF
Signature · 1 line
2.37.3
Quoted 67 lines · Felipe Contreras
In commit
26031d3b1(efi: Don't display a uefi-firmware entry if it's not supported, 2022-08-18) an unconditional call tofwsetup --is-supportedwas added which causes the system to reboot ifgrub-installhasn't been run becausefwsetupdoesn't have the new option.This is a huge regression.
To make sure
fwsetup --is-supportedworks we add a new feature that only newer GRUB installations have:feature_efifwsetup_check.If the feature is available the current behavior is maintained (
fwsetup --is-supported) but if it's not available the behavior before26031d3b1is maintained (unconditionally show the menu entry on EFI platforms).Also do this only on the EFI platform as Dimitri John Ledkov suggested.
Cc Javier Martinez Canillas <[email protected]>Cc Robbie Harwood <[email protected]>Cc Dimitri John Ledkov <[email protected]>Signed-off-by Felipe Contreras <[email protected]>--- grub-core/normal/main.c | 2 +- util/grub.d/30_uefi-firmware.in | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-)grub-core/normal/main.c +1
-1@@ -506,7 +506,7 @@ static const char *features[] = {"feature_chainloader_bpb" ,"feature_ntldr" ,"feature_platform_search_hint" ,"feature_default_font_path" ,"feature_all_video_module" ,"feature_menuentry_id" ,"feature_menuentry_options" ,"feature_200_final" , -"feature_nativedisk_cmd" ,"feature_timeout_style" +"feature_nativedisk_cmd" ,"feature_timeout_style" ,"feature_efifwsetup_check" };GRUB_MOD_INIT (normal)util/grub.d/30_uefi-firmware.in +11
-5@@ -31,10 +31,16 @@ LABEL="UEFI Firmware Settings" gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 cat << EOF -fwsetup --is-supported -if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then - menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { - fwsetup - } +if [ "\$grub_platform" = "efi" ]; then + if [ "\$feature_efifwsetup_check" = "y" ] ; then + fwsetup --is-supported + else + true + fi + if [ "\$?" = 0 ]; then + menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { + fwsetup + } + fi fi EOFSignature · 1 line
2.37.3
Thanks for your interest, but I prefer Javier's proposed approach.
Be well,
--Robbie
Quoted 64 lines · Robbie Harwood
Quoted 61 lines · Felipe Contreras
In commit
26031d3b1(efi: Don't display a uefi-firmware entry if it's not supported, 2022-08-18) an unconditional call tofwsetup --is-supportedwas added which causes the system to reboot ifgrub-installhasn't been run becausefwsetupdoesn't have the new option.This is a huge regression.
To make sure
fwsetup --is-supportedworks we add a new feature that only newer GRUB installations have:feature_efifwsetup_check.If the feature is available the current behavior is maintained (
fwsetup --is-supported) but if it's not available the behavior before26031d3b1is maintained (unconditionally show the menu entry on EFI platforms).Also do this only on the EFI platform as Dimitri John Ledkov suggested.
Cc Javier Martinez Canillas <[email protected]>Cc Robbie Harwood <[email protected]>Cc Dimitri John Ledkov <[email protected]>Signed-off-by Felipe Contreras <[email protected]>--- grub-core/normal/main.c | 2 +- util/grub.d/30_uefi-firmware.in | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-)grub-core/normal/main.c +1
-1@@ -506,7 +506,7 @@ static const char *features[] = {"feature_chainloader_bpb" ,"feature_ntldr" ,"feature_platform_search_hint" ,"feature_default_font_path" ,"feature_all_video_module" ,"feature_menuentry_id" ,"feature_menuentry_options" ,"feature_200_final" , -"feature_nativedisk_cmd" ,"feature_timeout_style" +"feature_nativedisk_cmd" ,"feature_timeout_style" ,"feature_efifwsetup_check" };GRUB_MOD_INIT (normal)util/grub.d/30_uefi-firmware.in +9
-5@@ -31,10 +31,16 @@ LABEL="UEFI Firmware Settings" gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 cat << EOF -fwsetup --is-supported -if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then - menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { - fwsetup - } +if [ "\$grub_platform" = "efi" ]; then + if [ "\$feature_efifwsetup_check" = "y" ] ; then + fwsetup --is-supported + else + true + fi + if [ "\$?" = 0 ]; then + menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { + fwsetup
Quoted 8 lines
Quoted 6 lines
util/grub.d/30_uefi-firmware.in +2
-1+ } + fi fi EOF --2.37.3
Thanks for your interest, but I prefer Javier's proposed approach.
Just to be clear: Javier's patch will *always* show a menu entry for UEFI firmware UI, even if the machine doesn't support it, so the user will click the entry, and an error will appear.
And also will make it so nothing uses fwsetup --is-supported. Should the option be removed then?
Signature · 1 line
Felipe Contreras