Subject: [bug#27695] [PATCH 1/2] bootloader: Add grub-hybrid-bootloader.

From: Danny Milosavljevic <[email-masked]>
Date: Thu, 20 Jul 2017 13:47:32 +0200

Hi Ludo,

On Thu, 20 Jul 2017 10:39:14 +0200
[email-masked] (Ludovic Courtès) wrote:

> Is it really all it takes to make a GRUB that can do both BIOS and UEFI?
> I wonder why GRUB upstream doesn’t do it by default.

I think they do, in a sense.  In many other distributions the directory is common - so if you install both grub-pc and grub-efi on your disk then grub will indeed use both (for grub-mkrescue).

>  Do you think we should discuss it with them?
> 
> If that works, we might just as well make it the new “grub” package and
> remove “grub-efi”.  Or is there any downside?

I only use this feature for grub-mkrescue right now.  I know that it is supported *there* in the sense that there's explicit "if" blocks checking for both platforms (by literals) in the same function, but not exclusively (i.e. "if (efi) A; if (non efi) B;" without "else").  See main() in util/grub-mkrescue.c in grub 2.02 (lines 667ff for EFI, lines 571ff for "PC"). The EFI stuff has "_EFI" in the preprocessor definitions, so search for that.

Note that main() supports a command line option for getting the source files for ONE SINGLE platform, but when you don't specify that option then it uses multiple platforms (the ones it can find).

For using multiple platforms as a regular bootloader I do NOT know whether that works or makes sense at all.  Maybe it does, I just didn't test it (and can't usefully).

That's why there's the alternative implementation that wouldn't add a Guix bootloader for it.

I hope someone else knows.  I don't have EFI hardware so I'm really the wrong person to find out that stuff.  Well I could try reading the documentation / asking and hoping that it's all correct, but ... you know... paper is patient :)

util/grub-install.c seems to use a case anaylsis with exclusive cases for finding out EFI or not *shrugs*.