diff options
| author | Janneke Nieuwenhuizen <janneke@gnu.org> | 2024-10-24 21:22:39 +0200 |
|---|---|---|
| committer | Jan (janneke) Nieuwenhuizen <janneke@gnu.org> | 2024-11-11 07:28:33 +0100 |
| commit | fdb23d9db8ca5431e280366c5c834e01eda62a5f (patch) | |
| tree | c4dec4c967c8ba47f957304ff35d68ee66d438b7 /gnu/bootloader | |
| parent | 046d6d9f8e5456d651cdc69b04dfae3af5230a98 (diff) | |
bootloader: grub: Remove hardcoded partition number for the Hurd.
This supports using another than the default DISK0 PART1 and using LABEL or
UUID as root file-system specifier. It still defaults to DISK0 PART1 if
the file-system cannot be found, i.e., lives only at the build side: A
virtual machine/childhurd build.
* gnu/build/file-systems.scm (%hurd-device-spec-regexp, %device-spec-regexp):
New variables.
(device-name->hurd-device-name, hurd-device-name->device-name,
device-spec->device, device-spec->device-name): Use them in new procedures.
* gnu/bootloader/grub.scm (make-grub-configuration): Use them to remove
hardcoded partition number (root-index 1).
Change-Id: I49fa93dacc09883dfb4d695402c5eac2e0e17286
Diffstat (limited to 'gnu/bootloader')
| -rw-r--r-- | gnu/bootloader/grub.scm | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 2723eda5f4d..ef516b1e13d 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> | 3 | ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com> |
| 4 | ;;; Copyright © 2017 Leo Famulari <leo@famulari.name> | 4 | ;;; Copyright © 2017 Leo Famulari <leo@famulari.name> |
| 5 | ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com> | 5 | ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com> |
| 6 | ;;; Copyright © 2019, 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org> | 6 | ;;; Copyright © 2019, 2020, 2023, 2024 Janneke Nieuwenhuizen <janneke@gnu.org> |
| 7 | ;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com> | 7 | ;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com> |
| 8 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> | 8 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
| 9 | ;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de> | 9 | ;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de> |
| @@ -34,6 +34,7 @@ | |||
| 34 | #:use-module (guix gexp) | 34 | #:use-module (guix gexp) |
| 35 | #:use-module (gnu artwork) | 35 | #:use-module (gnu artwork) |
| 36 | #:use-module (gnu bootloader) | 36 | #:use-module (gnu bootloader) |
| 37 | #:use-module (gnu build file-systems) | ||
| 37 | #:use-module (gnu system uuid) | 38 | #:use-module (gnu system uuid) |
| 38 | #:use-module (gnu system file-systems) | 39 | #:use-module (gnu system file-systems) |
| 39 | #:use-module (gnu system keyboard) | 40 | #:use-module (gnu system keyboard) |
| @@ -45,6 +46,7 @@ | |||
| 45 | #:use-module (ice-9 regex) | 46 | #:use-module (ice-9 regex) |
| 46 | #:use-module (srfi srfi-1) | 47 | #:use-module (srfi srfi-1) |
| 47 | #:use-module (srfi srfi-2) | 48 | #:use-module (srfi srfi-2) |
| 49 | #:use-module (srfi srfi-26) | ||
| 48 | #:export (grub-theme | 50 | #:export (grub-theme |
| 49 | grub-theme? | 51 | grub-theme? |
| 50 | grub-theme-image | 52 | grub-theme-image |
| @@ -355,6 +357,11 @@ code." | |||
| 355 | ((or #f (? string?)) | 357 | ((or #f (? string?)) |
| 356 | #~(format #f "search --file --set ~a" #$file))))) | 358 | #~(format #f "search --file --set ~a" #$file))))) |
| 357 | 359 | ||
| 360 | (define* (device->hurd-device-name device-spec #:key (disk "w")) | ||
| 361 | "Return DEVICE as a Hurd name spec: part:PART-NUMBER:device:DISKdDISK-INDEX." | ||
| 362 | (let ((device-name (canonicalize-device-spec device-spec))) | ||
| 363 | (device-name->hurd-device-name device-name #:disk disk))) | ||
| 364 | |||
| 358 | (define* (make-grub-configuration grub config entries | 365 | (define* (make-grub-configuration grub config entries |
| 359 | #:key | 366 | #:key |
| 360 | (locale #f) | 367 | (locale #f) |
| @@ -413,16 +420,16 @@ when booting a root file system on a Btrfs subvolume." | |||
| 413 | ;; IDE driver ("hdX") and those understood by rumpdisk ("wdX" | 420 | ;; IDE driver ("hdX") and those understood by rumpdisk ("wdX" |
| 414 | ;; in the "noide" case). | 421 | ;; in the "noide" case). |
| 415 | (disk (if (member "noide" arguments) "w" "h")) | 422 | (disk (if (member "noide" arguments) "w" "h")) |
| 416 | (modules (menu-entry-multiboot-modules entry)) | 423 | (device-spec (and=> device file-system-device->string)) |
| 417 | (root-index 1)) ; XXX EFI will need root-index 2 | 424 | (device-name (and=> device-spec device-spec->device-name)) |
| 425 | (modules (menu-entry-multiboot-modules entry))) | ||
| 418 | #~(format port " | 426 | #~(format port " |
| 419 | menuentry ~s { | 427 | menuentry ~s { |
| 420 | multiboot ~a root=part:~a:device:~ad0~a~a | 428 | multiboot ~a root=~a~a~a |
| 421 | }~%" | 429 | }~%" |
| 422 | #$label | 430 | #$label |
| 423 | #$kernel | 431 | #$kernel |
| 424 | #$root-index | 432 | #$(device-name->hurd-device-name device-name #:disk disk) |
| 425 | #$disk | ||
| 426 | (string-join (list #$@arguments) " " 'prefix) | 433 | (string-join (list #$@arguments) " " 'prefix) |
| 427 | (string-join (map string-join '#$modules) | 434 | (string-join (map string-join '#$modules) |
| 428 | "\n module " 'prefix)))) | 435 | "\n module " 'prefix)))) |
