efi: Don't display a uefi-firmware entry if it's not supported

Add a new --is-supported option to commands/efi/efifwsetup and
conditionalize display on it.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Robbie Harwood authored and Daniel Kiper committed 2022-08-20 01:26:06 +02:00
1 parent 1e79bbfbda
commit 26031d3b10
2 files changed
+5 -1

No files matched your search

+3
View File
@@ -40,6 +40,9 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
grub_size_t oi_size; grub_size_t oi_size;
static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID; static grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
if (argc >= 1 && grub_strcmp(args[0], "--is-supported") == 0)
return !efifwsetup_is_supported ();
if (!efifwsetup_is_supported ()) if (!efifwsetup_is_supported ())
return grub_error (GRUB_ERR_INVALID_COMMAND, return grub_error (GRUB_ERR_INVALID_COMMAND,
N_("reboot to firmware setup is not supported by the current firmware")); N_("reboot to firmware setup is not supported by the current firmware"));
+2 -1
View File
@@ -31,7 +31,8 @@ LABEL="UEFI Firmware Settings"
gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2
cat << EOF cat << EOF
if [ "\$grub_platform" = "efi" ]; then fwsetup --is-supported
if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then
menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' {
fwsetup fwsetup
} }