mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
system: Add a version field to the <boot-parameters> record.
This version field exposes the (already present) version information of a boot parameters file. * gnu/system.scm (%boot-parameters-version): New variable. (<boot-parameters>)[version]: New field. (read-boot-parameters): Use it. (operating-system-boot-parameters-file): Likewise. * tests/boot-parameters.scm (test-read-boot-parameters): Use %boot-parameters-version as the default version value in the template.
This commit is contained in:
parent
a53ea46bfc
commit
4a3b8f4d59
2 changed files with 18 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
||||||
;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
|
;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
|
||||||
;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
|
;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
|
||||||
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
|
;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
|
||||||
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
;;; Copyright © 2020, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <jannek@gnu.org>
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <jannek@gnu.org>
|
||||||
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
|
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
|
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
|
||||||
|
@ -161,6 +161,8 @@ (define-module (gnu system)
|
||||||
boot-parameters-kernel-arguments
|
boot-parameters-kernel-arguments
|
||||||
boot-parameters-initrd
|
boot-parameters-initrd
|
||||||
boot-parameters-multiboot-modules
|
boot-parameters-multiboot-modules
|
||||||
|
boot-parameters-version
|
||||||
|
%boot-parameters-version
|
||||||
read-boot-parameters
|
read-boot-parameters
|
||||||
read-boot-parameters-file
|
read-boot-parameters-file
|
||||||
boot-parameters->menu-entry
|
boot-parameters->menu-entry
|
||||||
|
@ -295,6 +297,9 @@ (define (operating-system-kernel-arguments os root-device)
|
||||||
;;; Boot parameters
|
;;; Boot parameters
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
;;; When bumping the boot-parameters version, increment it by one (1).
|
||||||
|
(define %boot-parameters-version 0)
|
||||||
|
|
||||||
(define-record-type* <boot-parameters>
|
(define-record-type* <boot-parameters>
|
||||||
boot-parameters make-boot-parameters boot-parameters?
|
boot-parameters make-boot-parameters boot-parameters?
|
||||||
(label boot-parameters-label)
|
(label boot-parameters-label)
|
||||||
|
@ -322,7 +327,9 @@ (define-record-type* <boot-parameters>
|
||||||
(kernel boot-parameters-kernel)
|
(kernel boot-parameters-kernel)
|
||||||
(kernel-arguments boot-parameters-kernel-arguments)
|
(kernel-arguments boot-parameters-kernel-arguments)
|
||||||
(initrd boot-parameters-initrd)
|
(initrd boot-parameters-initrd)
|
||||||
(multiboot-modules boot-parameters-multiboot-modules))
|
(multiboot-modules boot-parameters-multiboot-modules)
|
||||||
|
(version boot-parameters-version ;positive integer
|
||||||
|
(default %boot-parameters-version)))
|
||||||
|
|
||||||
(define (ensure-not-/dev device)
|
(define (ensure-not-/dev device)
|
||||||
"If DEVICE starts with a slash, return #f. This is meant to filter out
|
"If DEVICE starts with a slash, return #f. This is meant to filter out
|
||||||
|
@ -359,12 +366,18 @@ (define uuid-sexp->uuid
|
||||||
(warning (G_ "unrecognized uuid ~a at '~a'~%") x (port-filename port))
|
(warning (G_ "unrecognized uuid ~a at '~a'~%") x (port-filename port))
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
|
;; New versions are not backward-compatible, so only accept past and current
|
||||||
|
;; versions, not future ones.
|
||||||
|
(define (version? n)
|
||||||
|
(member n (iota (1+ %boot-parameters-version))))
|
||||||
|
|
||||||
(match (read port)
|
(match (read port)
|
||||||
(('boot-parameters ('version 0)
|
(('boot-parameters ('version (? version? version))
|
||||||
('label label) ('root-device root)
|
('label label) ('root-device root)
|
||||||
('kernel kernel)
|
('kernel kernel)
|
||||||
rest ...)
|
rest ...)
|
||||||
(boot-parameters
|
(boot-parameters
|
||||||
|
(version version)
|
||||||
(label label)
|
(label label)
|
||||||
(root-device (device-sexp->device root))
|
(root-device (device-sexp->device root))
|
||||||
|
|
||||||
|
@ -1500,7 +1513,7 @@ (define* (operating-system-boot-parameters-file os
|
||||||
system-kernel-arguments?)))
|
system-kernel-arguments?)))
|
||||||
(scheme-file "parameters"
|
(scheme-file "parameters"
|
||||||
#~(boot-parameters
|
#~(boot-parameters
|
||||||
(version 0)
|
(version #$(boot-parameters-version params))
|
||||||
(label #$(boot-parameters-label params))
|
(label #$(boot-parameters-label params))
|
||||||
(root-device
|
(root-device
|
||||||
#$(device->sexp
|
#$(device->sexp
|
||||||
|
|
|
@ -101,7 +101,7 @@ (define (quote-uuid uuid)
|
||||||
;; Call read-boot-parameters with the desired string as input.
|
;; Call read-boot-parameters with the desired string as input.
|
||||||
(define* (test-read-boot-parameters
|
(define* (test-read-boot-parameters
|
||||||
#:key
|
#:key
|
||||||
(version 0)
|
(version %boot-parameters-version)
|
||||||
(bootloader-name 'grub)
|
(bootloader-name 'grub)
|
||||||
(bootloader-menu-entries '())
|
(bootloader-menu-entries '())
|
||||||
(label %default-label)
|
(label %default-label)
|
||||||
|
|
Loading…
Reference in a new issue