From: Stefan <stefan-guix@vodafonemail.de>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 41066@debbugs.gnu.org, Mathieu Othacehe <othacehe@gnu.org>
Subject: [bug#41066] [PATCH] gnu: bootloader: Improve support for chain loading.
Date: Sun, 13 Dec 2020 20:28:57 +0100 [thread overview]
Message-ID: <101A8A97-C37B-46B4-84E2-DDE68D74B3F0@vodafonemail.de> (raw)
In-Reply-To: <9A42CB53-1D8B-406C-B046-46883BC9962F@vodafonemail.de>
* gnu/bootloader.scm (chain-efi-bootloader-installer): New function to call its
final-installer argument before copying files from the collection directory of a
bootloader profile to the bootloader target directory, preferring a target of
/mnt/boot/efi over /boot/efi, and only copying if source and destination
directories exist.
* (efi-bootloader-chain): Using (chain-efi-bootloader-installer) if the #:installer
argument is false.
The new chain-efi-bootloader-installer allows a customization of installers like
(install-grub-efi-netboot):
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
(list (file-append firmware "/boot/")
(file-append u-boot-my-scb "/libexec/u-boot.bin")
(plain-file "config.txt"
"kernel=u-boot.bin"))
grub-efi-netboot-bootloader
#:hooks my-special-bootloader-profile-manipulator
#:installer
(chain-efi-bootloader-installer (install-grub-efi-netboot "efi/boot")))
(target "/boot"))))
---
gnu/bootloader.scm | 54 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 11 deletions(-)
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 6d7352ddd2..ce62d315ef 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -70,6 +70,7 @@
%bootloaders
lookup-bootloader-by-name
+ chain-efi-bootloader-installer
efi-bootloader-chain))
^L
@@ -311,6 +312,38 @@ HOOKS lists additional hook functions to modify the profile."
(allow-collisions? #f)
(relative-symlinks? #f)))
+(define (chain-efi-bootloader-installer final-installer)
+ "Define a new bootloader installer gexp, which will invoke FINAL-INSTALLER
+before it will copy the content from a collection/ directory of its 'bootloader'
+argument into the directory of its 'target' argument.
+
+This order is by intention to allow overwriting bootloader files like
+device-trees with own files provided in that collection/ directory.
+
+The generated bootloader function will usually be used in this way:
+
+ (efi-bootloader-chain … #:installer (chain-efi-bootloader-installer …))"
+
+ #~(lambda (bootloader target mount-point)
+ (#$final-installer bootloader target mount-point)
+ (let* ((mount-point/target (string-append mount-point target))
+ ;; When installing Guix, it is common to mount TARGET below
+ ;; MOUNT-POINT rather than the root directory.
+ (bootloader-target (if (file-exists? mount-point/target)
+ mount-point/target
+ target))
+ (collection (string-append bootloader "/collection")))
+ (if (and (eq? (and=> (stat collection #f) stat:type)
+ 'directory)
+ (eq? (and=> (stat bootloader-target #f) stat:type)
+ 'directory))
+ ;; Now copy the content of the collection directory.
+ (copy-recursively collection bootloader-target
+ #:follow-symlinks? #t
+ #:log (%make-void-port "w"))
+ (error "expecting two directories for bootloader installation"
+ collection bootloader-target)))))
+
(define* (efi-bootloader-chain files
final-bootloader
#:key
@@ -330,10 +363,16 @@ of the directory itself will be symlinked into the collection/ directory.
The procedures in the HOOKS list can be used to further modify the bootloader
profile. It is possible to pass a single function instead of a list.
-If the INSTALLER argument is used, then this function will be called to install
-the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called."
+If the INSTALLER argument is used, then this procedure will be called to install
+the bootloader and handle the files inside the collection directory of the
+profile. Otherwise the generated procedure from
+
+ (chain-efi-bootloader-installer (bootloader-installer FINAL-BOOTLOADER))
+
+will be used to install the bootloader."
(let* ((final-installer (or installer
- (bootloader-installer final-bootloader)))
+ (chain-efi-bootloader-installer
+ (bootloader-installer final-bootloader))))
(profile (efi-bootloader-profile files
(bootloader-package final-bootloader)
(if (list? hooks)
@@ -342,11 +381,4 @@ the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called.
(bootloader
(inherit final-bootloader)
(package profile)
- (installer
- #~(lambda (bootloader target mount-point)
- (#$final-installer bootloader target mount-point)
- (copy-recursively
- (string-append bootloader "/collection")
- (string-append mount-point target)
- #:follow-symlinks? #t
- #:log (%make-void-port "w")))))))
+ (installer final-installer))))
--
2.29.2
next prev parent reply other threads:[~2020-12-13 19:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-03 23:34 [bug#41066] [PATCH] gnu: grub: Support for chain loading Stefan
2020-05-24 11:13 ` Danny Milosavljevic
2020-05-24 13:21 ` Stefan
2020-10-04 16:31 ` [bug#41066] [PATCH] gnu: bootloader: " Stefan
2020-10-10 9:31 ` Stefan
2020-10-18 11:20 ` Stefan
2020-10-18 11:21 ` Stefan
2020-10-22 17:46 ` Danny Milosavljevic
2020-10-23 12:48 ` Ludovic Courtès
2020-10-24 1:30 ` Danny Milosavljevic
2020-10-24 16:22 ` Ludovic Courtès
2020-10-25 0:33 ` Danny Milosavljevic
2020-10-25 16:58 ` Stefan
2020-10-25 16:59 ` Stefan
2020-11-02 15:42 ` Danny Milosavljevic
2020-11-02 16:21 ` Mathieu Othacehe
2020-11-03 9:07 ` Ludovic Courtès
2020-11-03 9:32 ` Mathieu Othacehe
2020-11-07 21:14 ` Stefan
2020-11-07 21:15 ` Stefan
2020-10-26 10:37 ` Ludovic Courtès
2020-11-16 9:33 ` bug#41066: " Danny Milosavljevic
2020-11-17 14:26 ` [bug#41066] " Stefan
2020-11-17 15:47 ` Danny Milosavljevic
2020-11-17 16:17 ` Danny Milosavljevic
2020-11-17 20:27 ` Stefan
2020-11-18 18:05 ` Danny Milosavljevic
2020-11-18 18:20 ` Stefan
2020-11-28 22:14 ` [bug#41066] [PATCH] gnu: bootloader: Improve support " Stefan
2020-12-12 17:14 ` Stefan
2020-12-13 14:42 ` Danny Milosavljevic
2020-12-13 17:24 ` Stefan
2020-12-13 19:28 ` Stefan [this message]
2020-12-28 19:02 ` Stefan
2021-03-27 16:48 ` bug#41066: " Stefan
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=101A8A97-C37B-46B4-84E2-DDE68D74B3F0@vodafonemail.de \
--to=stefan-guix@vodafonemail.de \
--cc=41066@debbugs.gnu.org \
--cc=dannym@scratchpost.org \
--cc=othacehe@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).