bootloader: grub: Skip install-grub-efi when producing a disk image.

Fixes <http://issues.guix.gnu.org/44353>.

Every bootloader should try their best to install themselves using only the
MOUNT-POINT and otherwise do nothing.  This requirement comes from the
necessity to call INSTALL-GRUB when installing the (non-EFI) GRUB bootloader,
which needs to populate the root file system with extra modules that cannot be
fit in the core.img file, limited in size to 491520 bytes (by the i386-pc
format required for legacy BIOS compatibility).

As introducing bootloader knowledge at the level of the image code is
undesirable, every bootloader should be adapted to support this fall-back for
their installation procedure (TODO).

* gnu/bootloader/grub.scm (install-grub-efi)[efi-dir]: Skip when the EFI-DIR
argument is set to #f.
This commit is contained in:
Maxim Cournoyer 2020-11-11 14:48:54 -05:00
parent 1ec366cdfd
commit b0afa3c5f6
No known key found for this signature in database
GPG Key ID: 1260E46482E63562

@ -573,21 +573,24 @@ fi~%"))))
(define install-grub-efi (define install-grub-efi
#~(lambda (bootloader efi-dir mount-point) #~(lambda (bootloader efi-dir mount-point)
;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the ;; There is nothing useful to do when called in the context of a disk
;; system whose root is mounted at MOUNT-POINT. ;; image generation.
(let ((grub-install (string-append bootloader "/sbin/grub-install")) (when efi-dir
(install-dir (string-append mount-point "/boot")) ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
;; When installing Guix, it's common to mount EFI-DIR below ;; system whose root is mounted at MOUNT-POINT.
;; MOUNT-POINT rather than /boot/efi on the live image. (let ((grub-install (string-append bootloader "/sbin/grub-install"))
(target-esp (if (file-exists? (string-append mount-point efi-dir)) (install-dir (string-append mount-point "/boot"))
(string-append mount-point efi-dir) ;; When installing Guix, it's common to mount EFI-DIR below
efi-dir))) ;; MOUNT-POINT rather than /boot/efi on the live image.
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or (target-esp (if (file-exists? (string-append mount-point efi-dir))
;; root partition. (string-append mount-point efi-dir)
(setenv "GRUB_ENABLE_CRYPTODISK" "y") efi-dir)))
(invoke/quiet grub-install "--boot-directory" install-dir ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
"--bootloader-id=Guix" ;; root partition.
"--efi-directory" target-esp)))) (setenv "GRUB_ENABLE_CRYPTODISK" "y")
(invoke/quiet grub-install "--boot-directory" install-dir
"--bootloader-id=Guix"
"--efi-directory" target-esp)))))
(define (install-grub-efi-netboot subdir) (define (install-grub-efi-netboot subdir)
"Define a grub-efi-netboot bootloader installer for installation in SUBDIR, "Define a grub-efi-netboot bootloader installer for installation in SUBDIR,