summary refs log tree commit diff
path: root/gnu/build/bootloader.scm
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-06-17 23:18:35 -0600
committerMathieu Othacehe <othacehe@gnu.org>2022-06-24 10:21:06 +0200
commit62c86c8391ceb8953ca972498fd75ea9298b85ff (patch)
treef4ddcdf3749219c0fd36b92d0c2ba52b73566a07 /gnu/build/bootloader.scm
parent242fad357e969da3b1f80b7e4360b54d99ee03f3 (diff)
downloadguix-62c86c8391ceb8953ca972498fd75ea9298b85ff.tar.gz
image: Add support for 32bit UEFI.
* gnu/bootloader/grub.scm (grub-efi32-bootloader): New variable.
(install-grub-efi32): New variable.
* gnu/build/bootloader.scm (install-efi): Add a 'targets' keyword
argument.
(install-efi-loader): Likewise.
* gnu/build/image.scm (initialize-efi32-partition): New procedure.
* gnu/packages/bootloaders.scm (grub-efi32): New variable.
* gnu/system/image.scm (esp32-partition): New variable
(efi32-disk-image): New variable.
(efi32-raw-image-type): New variable.
(system-disk-image)[partition-image]: Set '#:grub-efi32' when
calling the partition initializer.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/build/bootloader.scm')
-rw-r--r--gnu/build/bootloader.scm37
1 files changed, 24 insertions, 13 deletions
diff --git a/gnu/build/bootloader.scm b/gnu/build/bootloader.scm
index 9a89fe55cb..af6063a884 100644
--- a/gnu/build/bootloader.scm
+++ b/gnu/build/bootloader.scm
@@ -1,6 +1,8 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+;;; Copyright © 2022 Timothy Sample <samplet@ngyro.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -54,8 +56,12 @@
 ;;; EFI bootloader.
 ;;;
 
-(define (install-efi grub grub-config esp)
-  "Write a self-contained GRUB EFI loader to the mounted ESP using GRUB-CONFIG."
+(define* (install-efi grub grub-config esp #:key targets)
+  "Write a self-contained GRUB EFI loader to the mounted ESP using
+GRUB-CONFIG.
+
+If TARGETS is set, use its car as the GRUB image format and its cdr as
+the output filename.  Otherwise, use defaults for the host platform."
   (let* ((system %host-type)
          ;; Hard code the output location to a well-known path recognized by
          ;; compliant firmware. See "3.5.1.1 Removable Media Boot Behaviour":
@@ -63,14 +69,15 @@
          (grub-mkstandalone (string-append grub "/bin/grub-mkstandalone"))
          (efi-directory (string-append esp "/EFI/BOOT"))
          ;; Map grub target names to boot file names.
-         (efi-targets (cond ((string-prefix? "x86_64" system)
-                             '("x86_64-efi" . "BOOTX64.EFI"))
-                            ((string-prefix? "i686" system)
-                             '("i386-efi" . "BOOTIA32.EFI"))
-                            ((string-prefix? "armhf" system)
-                             '("arm-efi" . "BOOTARM.EFI"))
-                            ((string-prefix? "aarch64" system)
-                             '("arm64-efi" . "BOOTAA64.EFI")))))
+         (efi-targets (or targets
+                          (cond ((string-prefix? "x86_64" system)
+                                 '("x86_64-efi" . "BOOTX64.EFI"))
+                                ((string-prefix? "i686" system)
+                                 '("i386-efi" . "BOOTIA32.EFI"))
+                                ((string-prefix? "armhf" system)
+                                 '("arm-efi" . "BOOTARM.EFI"))
+                                ((string-prefix? "aarch64" system)
+                                 '("arm64-efi" . "BOOTAA64.EFI"))))))
     ;; grub-mkstandalone requires a TMPDIR to prepare the firmware image.
     (setenv "TMPDIR" esp)
 
@@ -81,9 +88,12 @@
             ;; Graft the configuration file onto the image.
             (string-append "boot/grub/grub.cfg=" grub-config))))
 
-(define (install-efi-loader grub-efi esp)
+(define* (install-efi-loader grub-efi esp #:key targets)
   "Install in ESP directory the given GRUB-EFI bootloader.  Configure it to
-load the Grub bootloader located in the 'Guix_image' root partition."
+load the Grub bootloader located in the 'Guix_image' root partition.
+
+If TARGETS is set, use its car as the GRUB image format and its cdr as
+the output filename.  Otherwise, use defaults for the host platform."
   (let ((grub-config "grub.cfg"))
     (call-with-output-file grub-config
       (lambda (port)
@@ -97,5 +107,6 @@ load the Grub bootloader located in the 'Guix_image' root partition."
                insmod part_gpt~@
                search --set=root --label Guix_image~@
                configfile /boot/grub/grub.cfg~%")))
-    (install-efi grub-efi grub-config esp)
+    (install-efi grub-efi grub-config esp #:targets targets)
     (delete-file grub-config)))
+