summaryrefslogtreecommitdiff
path: root/gnu/build
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
parent242fad357e969da3b1f80b7e4360b54d99ee03f3 (diff)
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')
-rw-r--r--gnu/build/bootloader.scm37
-rw-r--r--gnu/build/image.scm14
2 files changed, 38 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)))
+
diff --git a/gnu/build/image.scm b/gnu/build/image.scm
index ddfd34c111..321be8e4b1 100644
--- a/gnu/build/image.scm
+++ b/gnu/build/image.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2022 Pavel Shlyak <p.shlyak@pantherx.org>
+;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -27,6 +28,7 @@
#:use-module (guix build syscalls)
#:use-module (guix build utils)
#:use-module (guix store database)
+ #:use-module (guix utils)
#:use-module (gnu build bootloader)
#:use-module (gnu build install)
#:use-module (gnu build linux-boot)
@@ -41,6 +43,7 @@
convert-disk-image
genimage
initialize-efi-partition
+ initialize-efi32-partition
initialize-root-partition
make-iso9660-image))
@@ -169,6 +172,17 @@ produced by #:references-graphs. Pass WAL-MODE? to call-with-database."
"Install in ROOT directory, an EFI loader using GRUB-EFI."
(install-efi-loader grub-efi root))
+(define* (initialize-efi32-partition root
+ #:key
+ grub-efi32
+ #:allow-other-keys)
+ "Install in ROOT directory, an EFI 32bit loader using GRUB-EFI32."
+ (install-efi-loader grub-efi32 root
+ #:targets (cond ((target-x86?)
+ '("i386-efi" . "BOOTIA32.EFI"))
+ ((target-arm?)
+ '("arm-efi" . "BOOTARM.EFI")))))
+
(define* (initialize-root-partition root
#:key
bootcfg