grub-devel
[Top][All Lists]
Advanced

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

[PATCH] util/grub.d/30_os-prober.in: Conditionally show or hide chain an


From: Pascal Hambourg
Subject: [PATCH] util/grub.d/30_os-prober.in: Conditionally show or hide chain and efi menu entries
Date: Sat, 6 Jan 2024 16:36:11 +0100
User-agent: Mozilla Thunderbird

On systems which support both BIOS/legacy and EFI boot, it makes no
sense to show menu entries for EFI bootloaders when booted in
BIOS/legacy mode and show menu entries for BIOS/legacy boot loaders
when booted in EFI mode.

Show 'chain' menu entries only if not booted in EFI mode.
Show 'efi' menu entries only if booted in EFI mode.

This will allow os-prober to report both EFI and BIOS legacy boot
loaders regardless of the current boot mode on systems which support
both EFI and BIOS/legacy boot.

Note:
I did not change indentation to keep the patch minimal.

Signed-off-by: Pascal Hambourg <pascal@plouf.fr.eu.org>
---
 util/grub.d/30_os-prober.in | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 8e5cbb50e..a16f7549b 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -155,6 +155,7 @@ for OS in ${OSPROBED} ; do

          onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
       cat << EOF
+if [ "\$grub_platform" != "efi" ]; then
 menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os 
\$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
 EOF
       save_default_entry | grub_add_tab
@@ -179,6 +180,7 @@ EOF
       cat <<EOF
        chainloader +1
 }
+fi
 EOF
     ;;
     efi)
@@ -187,6 +189,7 @@ EOF
        DEVICE=${DEVICE%@*}
        onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
       cat << EOF
+if [ "\$grub_platform" = "efi" ]; then
 menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os 
\$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
 EOF
       save_default_entry | sed -e "s/^/\t/"
@@ -195,6 +198,7 @@ EOF
       cat <<EOF
        chainloader ${EFIPATH}
 }
+fi
 EOF
     ;;
     linux)
--
2.30.2



reply via email to

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