From: Herman Rimm via Guix-patches via <guix-patches@gnu.org>
To: 74109@debbugs.gnu.org
Subject: [bug#74109] [PATCH] gnu: bootloader: grub: Add procedure to share EFI installer code.
Date: Wed, 30 Oct 2024 16:01:11 +0100 [thread overview]
Message-ID: <0d64318889bc98bd9b59d72676641a3914ffed3e.1730300346.git.herman@rimm.ee> (raw)
* gnu/bootloader/grub.scm (make-grub-efi-bootloader): Add procedure.
(install-grub-efi, install-grub-efi32): Remove variables.
(install-grub-efi-removable): Deprecate variable.
Change-Id: Ie10b506bb1088179d459ddafe3229fd730ac45aa
---
gnu/bootloader/grub.scm | 82 ++++++++++++++---------------------------
1 file changed, 27 insertions(+), 55 deletions(-)
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 2723eda5f4..4933bdcff0 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -28,6 +28,7 @@
(define-module (gnu bootloader grub)
#:use-module (guix build union)
+ #:use-module (guix deprecation)
#:use-module (guix records)
#:use-module (guix store)
#:use-module (guix utils)
@@ -54,6 +55,7 @@ (define-module (gnu bootloader grub)
grub-theme-gfxmode
install-grub-efi-removable
+ make-grub-efi-installer
make-grub-efi-netboot-installer
grub-bootloader
@@ -621,7 +623,16 @@ (define install-grub-disk-image
"-d" "."
image))))
-(define install-grub-efi
+(define* (make-grub-efi-installer #:key efi32? removable?)
+ "Return a G-expression of a procedure for installing GRUB on a UEFI
+system. If EFI32? is #t, then a 32-bit target will be used. If
+REMOVABLE? is #t, GRUB will be installed for Removable Media Boot."
+ (define extra-args
+ (list (and efi32?
+ #~(cond ((target-x86?) "--target=i386-efi")
+ ((target-arm?) "--target=arm-efi")))
+ ;; This does not update UEFI boot entries, like --no-nvram.
+ (and removable? "--removable")))
#~(lambda (bootloader efi-dir mount-point)
;; There is nothing useful to do when called in the context of a disk
;; image generation.
@@ -638,57 +649,10 @@ (define install-grub-efi
;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
;; root partition.
(setenv "GRUB_ENABLE_CRYPTODISK" "y")
- (invoke/quiet grub-install "--boot-directory" install-dir
- "--bootloader-id=Guix"
- "--efi-directory" target-esp)))))
-
-(define install-grub-efi-removable
- #~(lambda (bootloader efi-dir mount-point)
- ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point
- ;; NOTE: efi-dir comes from target list of booloader configuration
- ;; There is nothing useful to do when called in the context of a disk
- ;; image generation.
- (when efi-dir
- ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
- ;; system whose root is mounted at MOUNT-POINT.
- (let ((grub-install (string-append bootloader "/sbin/grub-install"))
- (install-dir (string-append mount-point "/boot"))
- ;; When installing Guix, it's common to mount EFI-DIR below
- ;; MOUNT-POINT rather than /boot/efi on the live image.
- (target-esp (if (file-exists? (string-append mount-point efi-dir))
- (string-append mount-point efi-dir)
- efi-dir)))
- ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
- ;; root partition.
- (setenv "GRUB_ENABLE_CRYPTODISK" "y")
- (invoke/quiet grub-install "--boot-directory" install-dir
- "--removable"
- ;; "--no-nvram"
- "--bootloader-id=Guix"
- "--efi-directory" target-esp)))))
-
-(define install-grub-efi32
- #~(lambda (bootloader efi-dir mount-point)
- ;; There is nothing useful to do when called in the context of a disk
- ;; image generation.
- (when efi-dir
- ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
- ;; system whose root is mounted at MOUNT-POINT.
- (let ((grub-install (string-append bootloader "/sbin/grub-install"))
- (install-dir (string-append mount-point "/boot"))
- ;; When installing Guix, it's common to mount EFI-DIR below
- ;; MOUNT-POINT rather than /boot/efi on the live image.
- (target-esp (if (file-exists? (string-append mount-point efi-dir))
- (string-append mount-point efi-dir)
- efi-dir)))
- ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
- ;; root partition.
- (setenv "GRUB_ENABLE_CRYPTODISK" "y")
- (invoke/quiet grub-install "--boot-directory" install-dir
- "--bootloader-id=Guix"
- (cond ((target-x86?) "--target=i386-efi")
- ((target-arm?) "--target=arm-efi"))
- "--efi-directory" target-esp)))))
+ (invoke/quiet grub-install "--bootloader-id=Guix"
+ "--boot-directory" install-dir
+ "--efi-directory" target-esp
+ #$@(filter identity extra-args))))))
(define* (make-grub-efi-netboot-installer grub-efi grub-cfg subdir)
"Make a bootloader-installer for a grub-efi-netboot bootloader, which expects
@@ -849,7 +813,7 @@ (define grub-efi-bootloader
(bootloader
(name 'grub-efi)
(package grub-efi)
- (installer install-grub-efi)
+ (installer (make-grub-efi-installer))
(disk-image-installer #f)
(configuration-file grub-cfg)
(configuration-file-generator grub-configuration-file)))
@@ -858,12 +822,12 @@ (define grub-efi-removable-bootloader
(bootloader
(inherit grub-efi-bootloader)
(name 'grub-efi-removable-bootloader)
- (installer install-grub-efi-removable)))
+ (installer (make-grub-efi-installer #:removable? #t))))
(define grub-efi32-bootloader
(bootloader
(inherit grub-efi-bootloader)
- (installer install-grub-efi32)
+ (installer (make-grub-efi-installer #:efi32? #t))
(name 'grub-efi32)
(package grub-efi32)))
@@ -909,4 +873,12 @@ (define-syntax grub-configuration
(bootloader grub-bootloader)
fields ...))))
+\f
+;;;
+;;; Deprecated bootloader and installer variables.
+;;;
+
+(define-deprecated/alias install-grub-efi-removable
+ (make-grub-efi-installer #:removable? #t))
+
;;; grub.scm ends here
base-commit: d6f775c30c6f47e174f6110d1089edc6315600e4
--
2.45.2
next reply other threads:[~2024-10-30 15:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 15:01 Herman Rimm via Guix-patches via [this message]
2024-10-31 21:15 ` [bug#74109] [PATCH v2 0/2] Reduce duplicate bootloader installer code Herman Rimm via Guix-patches via
2024-10-31 21:15 ` [bug#74109] [PATCH v2 1/2] gnu: bootloader: grub: Add procedure to share EFI " Herman Rimm via Guix-patches via
2024-10-31 21:15 ` [bug#74109] [PATCH v2 2/2] gnu: bootloader: u-boot: Add procedure to share " Herman Rimm via Guix-patches via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d64318889bc98bd9b59d72676641a3914ffed3e.1730300346.git.herman@rimm.ee \
--to=guix-patches@gnu.org \
--cc=74109@debbugs.gnu.org \
--cc=herman@rimm.ee \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.