summaryrefslogtreecommitdiff
path: root/gnu/bootloader.scm
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2022-08-21 10:41:15 +0200
committerMarius Bakke <marius@gnu.org>2022-08-28 23:37:28 +0200
commit0811d2cb8dff5de9f535e14726c9874ec2f4a96c (patch)
treee0cf417522262a2b213b76d8a7f20f1e476b9c5f /gnu/bootloader.scm
parentb9322d78194fe76ef1586e5dc6fc30d0707d7310 (diff)
bootloader: Convert device in menu-entry to proper sexp.
Previously, menu-entry->sexp didn't try to convert `device` to a proper sexp, which was inserted directly into the boot parameters G-exp, leading to a G-exp input error. Now convert both uuid and file-system-label possibilities to sexps, and add parsing code to sexp->menu-entry. This fixes #57307. * gnu/bootloader.scm (menu-entry->sexp, sexp->menu-entry): Take non-string devices into account. Signed-off-by: Marius Bakke <marius@gnu.org>
Diffstat (limited to 'gnu/bootloader.scm')
-rw-r--r--gnu/bootloader.scm25
1 files changed, 21 insertions, 4 deletions
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 70e18361790..2eec48693c3 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -4,6 +4,7 @@
4;;; Copyright © 2017 Leo Famulari <leo@famulari.name> 4;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
5;;; Copyright © 2019, 2021 Ludovic Courtès <ludo@gnu.org> 5;;; Copyright © 2019, 2021 Ludovic Courtès <ludo@gnu.org>
6;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 6;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
7;;; 8;;;
8;;; This file is part of GNU Guix. 9;;; This file is part of GNU Guix.
9;;; 10;;;
@@ -21,6 +22,8 @@
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. 22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 23
23(define-module (gnu bootloader) 24(define-module (gnu bootloader)
25 #:use-module (gnu system file-systems)
26 #:use-module (gnu system uuid)
24 #:use-module (guix discovery) 27 #:use-module (guix discovery)
25 #:use-module (guix gexp) 28 #:use-module (guix gexp)
26 #:use-module (guix profiles) 29 #:use-module (guix profiles)
@@ -104,12 +107,19 @@
104 107
105(define (menu-entry->sexp entry) 108(define (menu-entry->sexp entry)
106 "Return ENTRY serialized as an sexp." 109 "Return ENTRY serialized as an sexp."
110 (define (device->sexp device)
111 (match device
112 ((? uuid? uuid)
113 `(uuid ,(uuid-type uuid) ,(uuid->string uuid)))
114 ((? file-system-label? label)
115 `(label ,(file-system-label->string label)))
116 (_ device)))
107 (match entry 117 (match entry
108 (($ <menu-entry> label device mount-point linux linux-arguments initrd #f 118 (($ <menu-entry> label device mount-point linux linux-arguments initrd #f
109 ()) 119 ())
110 `(menu-entry (version 0) 120 `(menu-entry (version 0)
111 (label ,label) 121 (label ,label)
112 (device ,device) 122 (device ,(device->sexp device))
113 (device-mount-point ,mount-point) 123 (device-mount-point ,mount-point)
114 (linux ,linux) 124 (linux ,linux)
115 (linux-arguments ,linux-arguments) 125 (linux-arguments ,linux-arguments)
@@ -118,7 +128,7 @@
118 multiboot-kernel multiboot-arguments multiboot-modules) 128 multiboot-kernel multiboot-arguments multiboot-modules)
119 `(menu-entry (version 0) 129 `(menu-entry (version 0)
120 (label ,label) 130 (label ,label)
121 (device ,device) 131 (device ,(device->sexp device))
122 (device-mount-point ,mount-point) 132 (device-mount-point ,mount-point)
123 (multiboot-kernel ,multiboot-kernel) 133 (multiboot-kernel ,multiboot-kernel)
124 (multiboot-arguments ,multiboot-arguments) 134 (multiboot-arguments ,multiboot-arguments)
@@ -127,6 +137,13 @@
127(define (sexp->menu-entry sexp) 137(define (sexp->menu-entry sexp)
128 "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry> 138 "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
129record." 139record."
140 (define (sexp->device device-sexp)
141 (match device-sexp
142 (('uuid type uuid-string)
143 (uuid uuid-string type))
144 (('label label)
145 (file-system-label label))
146 (_ device-sexp)))
130 (match sexp 147 (match sexp
131 (('menu-entry ('version 0) 148 (('menu-entry ('version 0)
132 ('label label) ('device device) 149 ('label label) ('device device)
@@ -135,7 +152,7 @@ record."
135 ('initrd initrd) _ ...) 152 ('initrd initrd) _ ...)
136 (menu-entry 153 (menu-entry
137 (label label) 154 (label label)
138 (device device) 155 (device (sexp->device device))
139 (device-mount-point mount-point) 156 (device-mount-point mount-point)
140 (linux linux) 157 (linux linux)
141 (linux-arguments linux-arguments) 158 (linux-arguments linux-arguments)
@@ -148,7 +165,7 @@ record."
148 ('multiboot-modules multiboot-modules) _ ...) 165 ('multiboot-modules multiboot-modules) _ ...)
149 (menu-entry 166 (menu-entry
150 (label label) 167 (label label)
151 (device device) 168 (device (sexp->device device))
152 (device-mount-point mount-point) 169 (device-mount-point mount-point)
153 (multiboot-kernel multiboot-kernel) 170 (multiboot-kernel multiboot-kernel)
154 (multiboot-arguments multiboot-arguments) 171 (multiboot-arguments multiboot-arguments)