diff options
| author | Stefan <stefan-guix@vodafonemail.de> | 2022-11-30 19:59:09 -0500 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-12-01 14:31:28 -0500 |
| commit | a9acbf919a7668e26863d2d26d48c5fd41b57fcd (patch) | |
| tree | e29c25d793f35b03a711ed865d20eecb55033034 /gnu/bootloader.scm | |
| parent | 1a63aea94340f6a24ac09e1c348401e9dfd05395 (diff) | |
gnu: bootloader: Rework chaining, add grub-efi-netboot-removable-bootloader.
This rework allows to use an (efi-bootloader-chain) like this, which is able
to boot over network or local storage, depending on whether the bootloader
target has support for symbolic links:
(operating-system
(bootloader
(bootloader-configuration
(bootloader
(efi-bootloader-chain
grub-efi-netboot-removable-bootloader
#:packages (list my-firmware-package
my-u-boot-package)
#:files (list (plain-file "config.txt"
"kernel=u-boot.bin"))
#:hooks my-special-bootloader-profile-manipulator))
(targets '("/booti/efi"))
…))
…)
* doc/guix.texi (Bootloader Configuration): Describe the new
‘grub-efi-netboot-removable-bootloader’. Mention the file names used and that
the UEFI Boot Manager is not modified. Advise to disable write-access over
TFTP.
* gnu/bootloader.scm (efi-bootloader-profile): Allow a list of packages and
collect everything directly in the profile, avoiding a separate collection
directory. Renamed the profile from "bootloader-profile" to
"efi-bootloader-profile".
[bootloader-collection]: Rename to...
[efi-bootloader-profile-hook]: ... this and remove unused modules. Do not
create the now extraneous collection directory.
(efi-bootloader-chain): Add PACKAGES and DISK-IMAGE-INSTALLER arguments.
Remove handling of the collection directory, now only calling the given
installer procedure.
* gnu/bootloader/grub.scm (make-grub-efi-netboot-installer): New helper.
(make-grub-configuration): New helper based on (grub-configuration-file). Add
a GRUB argument, fix indentation, remove previous code retrieving GRUB from
CONFIG.
(grub-configuration-file): Make use of make-grub-configuration.
(grub-efi-configuration-file): New procedure.
(grub-cfg): New variable to replace "/boot/grub/grub.cfg".
(install-grub-efi-netboot): Remove, splitting logic to...
(make-grub-efi-netboot-installer): ... this new helper procedure, as well as
to make-grub-efi-netboot, added below.
(grub-bootloader): Adjust to use the GRUB-CFG.
(grub-efi-bootloader): Likewise. Removed inheritance and declare all fields
explicitly.
(make-grub-efi-netboot-bootloader): New procedure.
(grub-efi-netboot-bootloader): Use it.
(grub-efi-netboot-removable-bootloader): New variable.
* gnu/packages/bootloaders.scm (make-grub-efi-netboot): New procedure.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu/bootloader.scm')
| -rw-r--r-- | gnu/bootloader.scm | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index da65b9d5d5d..2c36d8c6cf7 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm | |||
| @@ -322,26 +322,22 @@ instead~%"))) | |||
| 322 | (force %bootloaders)) | 322 | (force %bootloaders)) |
| 323 | (leave (G_ "~a: no such bootloader~%") name))) | 323 | (leave (G_ "~a: no such bootloader~%") name))) |
| 324 | 324 | ||
| 325 | (define (efi-bootloader-profile files bootloader-package hooks) | 325 | (define (efi-bootloader-profile packages files hooks) |
| 326 | "Creates a profile with BOOTLOADER-PACKAGE and a directory collection/ with | 326 | "Creates a profile from the lists of PACKAGES and FILES from the store. |
| 327 | links to additional FILES from the store. This collection is meant to be used | 327 | This profile is meant to be used by the bootloader-installer. |
| 328 | by the bootloader installer. | ||
| 329 | 328 | ||
| 330 | FILES is a list of file or directory names from the store, which will be | 329 | FILES is a list of file or directory names from the store, which will be |
| 331 | symlinked into the collection/ directory. If a directory name ends with '/', | 330 | symlinked into the profile. If a directory name ends with '/', then the |
| 332 | then the directory content instead of the directory itself will be symlinked | 331 | directory content instead of the directory itself will be symlinked into the |
| 333 | into the collection/ directory. | 332 | profile. |
| 334 | 333 | ||
| 335 | FILES may contain file like objects produced by functions like plain-file, | 334 | FILES may contain file like objects produced by procedures like plain-file, |
| 336 | local-file, etc., or package contents produced with file-append. | 335 | local-file, etc., or package contents produced with file-append. |
| 337 | 336 | ||
| 338 | HOOKS lists additional hook functions to modify the profile." | 337 | HOOKS lists additional hook functions to modify the profile." |
| 339 | (define (bootloader-collection manifest) | 338 | (define (efi-bootloader-profile-hook manifest) |
| 340 | (define build | 339 | (define build |
| 341 | (with-imported-modules '((guix build utils) | 340 | (with-imported-modules '((guix build utils)) |
| 342 | (ice-9 ftw) | ||
| 343 | (srfi srfi-1) | ||
| 344 | (srfi srfi-26)) | ||
| 345 | #~(begin | 341 | #~(begin |
| 346 | (use-modules ((guix build utils) | 342 | (use-modules ((guix build utils) |
| 347 | #:select (mkdir-p strip-store-file-name)) | 343 | #:select (mkdir-p strip-store-file-name)) |
| @@ -365,8 +361,7 @@ HOOKS lists additional hook functions to modify the profile." | |||
| 365 | (define (name-is-store-entry? name) | 361 | (define (name-is-store-entry? name) |
| 366 | "Return #t if NAME is a direct store entry and nothing inside." | 362 | "Return #t if NAME is a direct store entry and nothing inside." |
| 367 | (not (string-index (strip-store-file-name name) #\/))) | 363 | (not (string-index (strip-store-file-name name) #\/))) |
| 368 | (let* ((collection (string-append #$output "/collection")) | 364 | (let* ((files '#$files) |
| 369 | (files '#$files) | ||
| 370 | (directories (filter name-ends-with-/? files)) | 365 | (directories (filter name-ends-with-/? files)) |
| 371 | (names-from-directories | 366 | (names-from-directories |
| 372 | (append-map (lambda (directory) | 367 | (append-map (lambda (directory) |
| @@ -374,11 +369,11 @@ HOOKS lists additional hook functions to modify the profile." | |||
| 374 | directories)) | 369 | directories)) |
| 375 | (names (append names-from-directories | 370 | (names (append names-from-directories |
| 376 | (remove name-ends-with-/? files)))) | 371 | (remove name-ends-with-/? files)))) |
| 377 | (mkdir-p collection) | 372 | (mkdir-p #$output) |
| 378 | (if (every file-exists? names) | 373 | (if (every file-exists? names) |
| 379 | (begin | 374 | (begin |
| 380 | (for-each (lambda (name) | 375 | (for-each (lambda (name) |
| 381 | (symlink-to name collection | 376 | (symlink-to name #$output |
| 382 | (if (name-is-store-entry? name) | 377 | (if (name-is-store-entry? name) |
| 383 | strip-store-file-name | 378 | strip-store-file-name |
| 384 | basename))) | 379 | basename))) |
| @@ -386,57 +381,63 @@ HOOKS lists additional hook functions to modify the profile." | |||
| 386 | #t) | 381 | #t) |
| 387 | #f))))) | 382 | #f))))) |
| 388 | 383 | ||
| 389 | (gexp->derivation "bootloader-collection" | 384 | (gexp->derivation "efi-bootloader-profile" |
| 390 | build | 385 | build |
| 391 | #:local-build? #t | 386 | #:local-build? #t |
| 392 | #:substitutable? #f | 387 | #:substitutable? #f |
| 393 | #:properties | 388 | #:properties |
| 394 | `((type . profile-hook) | 389 | `((type . profile-hook) |
| 395 | (hook . bootloader-collection)))) | 390 | (hook . efi-bootloader-profile-hook)))) |
| 396 | 391 | ||
| 397 | (profile (content (packages->manifest (list bootloader-package))) | 392 | (profile (content (packages->manifest packages)) |
| 398 | (name "bootloader-profile") | 393 | (name "efi-bootloader-profile") |
| 399 | (hooks (append (list bootloader-collection) hooks)) | 394 | (hooks (cons efi-bootloader-profile-hook hooks)) |
| 400 | (locales? #f) | 395 | (locales? #f) |
| 401 | (allow-collisions? #f) | 396 | (allow-collisions? #f) |
| 402 | (relative-symlinks? #f))) | 397 | (relative-symlinks? #f))) |
| 403 | 398 | ||
| 404 | (define* (efi-bootloader-chain files | 399 | (define* (efi-bootloader-chain final-bootloader |
| 405 | final-bootloader | ||
| 406 | #:key | 400 | #:key |
| 401 | (packages '()) | ||
| 402 | (files '()) | ||
| 407 | (hooks '()) | 403 | (hooks '()) |
| 408 | installer) | 404 | installer |
| 409 | "Define a bootloader chain with FINAL-BOOTLOADER as the final bootloader and | 405 | disk-image-installer) |
| 410 | certain directories and files from the store given in the list of FILES. | 406 | "Define a chain of bootloaders with the FINAL-BOOTLOADER, optional PACKAGES, |
| 407 | and optional directories and files from the store given in the list of FILES. | ||
| 411 | 408 | ||
| 412 | FILES may contain file like objects produced by functions like plain-file, | 409 | The package of the FINAL-BOOTLOADER and all PACKAGES and FILES will be placed |
| 413 | local-file, etc., or package contents produced with file-append. They will be | 410 | in an efi-bootloader-profile, which will be passed to the INSTALLER. |
| 414 | collected inside a directory collection/ inside a generated bootloader profile, | 411 | |
| 415 | which will be passed to the INSTALLER. | 412 | FILES may contain file-like objects produced by procedures like plain-file, |
| 413 | local-file, etc., or package contents produced with file-append. | ||
| 416 | 414 | ||
| 417 | If a directory name in FILES ends with '/', then the directory content instead | 415 | If a directory name in FILES ends with '/', then the directory content instead |
| 418 | of the directory itself will be symlinked into the collection/ directory. | 416 | of the directory itself will be symlinked into the efi-bootloader-profile. |
| 419 | 417 | ||
| 420 | The procedures in the HOOKS list can be used to further modify the bootloader | 418 | The procedures in the HOOKS list can be used to further modify the bootloader |
| 421 | profile. It is possible to pass a single function instead of a list. | 419 | profile. It is possible to pass a single function instead of a list. |
| 422 | 420 | ||
| 423 | If the INSTALLER argument is used, then this function will be called to install | 421 | If the INSTALLER argument is used, then this gexp procedure will be called to |
| 424 | the bootloader. Otherwise the installer of the FINAL-BOOTLOADER will be called." | 422 | install the efi-bootloader-profile. Otherwise the installer of the |
| 425 | (let* ((final-installer (or installer | 423 | FINAL-BOOTLOADER will be called. |
| 426 | (bootloader-installer final-bootloader))) | 424 | |
| 427 | (profile (efi-bootloader-profile files | 425 | If the DISK-IMAGE-INSTALLER is used, then this gexp procedure will be called |
| 428 | (bootloader-package final-bootloader) | 426 | to install the efi-bootloader-profile into a disk image. Otherwise the |
| 429 | (if (list? hooks) | 427 | disk-image-installer of the FINAL-BOOTLOADER will be called." |
| 430 | hooks | 428 | (bootloader |
| 431 | (list hooks))))) | 429 | (inherit final-bootloader) |
| 432 | (bootloader | 430 | (name "efi-bootloader-chain") |
| 433 | (inherit final-bootloader) | 431 | (package |
| 434 | (package profile) | 432 | (efi-bootloader-profile (cons (bootloader-package final-bootloader) |
| 435 | (installer | 433 | packages) |
| 436 | #~(lambda (bootloader target mount-point) | 434 | files |
| 437 | (#$final-installer bootloader target mount-point) | 435 | (if (list? hooks) |
| 438 | (copy-recursively | 436 | hooks |
| 439 | (string-append bootloader "/collection") | 437 | (list hooks)))) |
| 440 | (string-append mount-point target) | 438 | (installer |
| 441 | #:follow-symlinks? #t | 439 | (or installer |
| 442 | #:log (%make-void-port "w"))))))) | 440 | (bootloader-installer final-bootloader))) |
| 441 | (disk-image-installer | ||
| 442 | (or disk-image-installer | ||
| 443 | (bootloader-disk-image-installer final-bootloader))))) | ||
