Make grub-install check for errors from efibootmgr

Code is currently ignoring errors from efibootmgr, giving users
clearly bogus output like:

        Setting up grub-efi-amd64 (2.02~beta3-4) ...
        Installing for x86_64-efi platform.
        Could not delete variable: No space left on device
        Could not prepare Boot variable: No space left on device
        Installation finished. No error reported.

and then potentially unbootable systems. If efibootmgr fails, grub-install
should know that and report it!

We've been using similar patch in Debian now for some time, with no ill effects.

Signed-off-by: Steve McIntyre <93sam@debian.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Steve McIntyre 2018-01-31 21:49:36 +00:00 committed by Vincent Batts
parent 984c022638
commit 0b6bd057c0
3 changed files with 29 additions and 15 deletions

View file

@ -1848,9 +1848,13 @@ main (int argc, char *argv[])
if (!removable && update_nvram)
{
/* Try to make this image bootable using the EFI Boot Manager, if available. */
grub_install_register_efi (efidir_grub_dev,
"\\System\\Library\\CoreServices",
efi_distributor);
int ret;
ret = grub_install_register_efi (efidir_grub_dev,
"\\System\\Library\\CoreServices",
efi_distributor);
if (ret)
grub_util_error (_("efibootmgr failed to register the boot entry: %s"),
strerror (ret));
}
grub_device_close (ins_dev);
@ -1871,6 +1875,7 @@ main (int argc, char *argv[])
{
char * efifile_path;
char * part;
int ret;
/* Try to make this image bootable using the EFI Boot Manager, if available. */
if (!efi_distributor || efi_distributor[0] == '\0')
@ -1887,8 +1892,11 @@ main (int argc, char *argv[])
efidir_grub_dev->disk->name,
(part ? ",": ""), (part ? : ""));
grub_free (part);
grub_install_register_efi (efidir_grub_dev,
efifile_path, efi_distributor);
ret = grub_install_register_efi (efidir_grub_dev,
efifile_path, efi_distributor);
if (ret)
grub_util_error (_("efibootmgr failed to register the boot entry: %s"),
strerror (ret));
}
break;