From: Chris Marusich <cmmarus...@gmail.com> In a future commit, we will restructure the grub.cfg generation logic to use this information, to enable the implementation of 'guix system switch-generation' and 'guix system roll-back'. --- gnu/system.scm | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 9 deletions(-)
diff --git a/gnu/system.scm b/gnu/system.scm index 38ae8f1..ff84b63 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <l...@gnu.org> ;;; Copyright © 2015 Mark H Weaver <m...@netris.org> ;;; Copyright © 2015, 2016 Alex Kost <alez...@gmail.com> +;;; Copyright © 2016 Chris Marusich <cmmarus...@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -99,6 +100,8 @@ boot-parameters? boot-parameters-label boot-parameters-root-device + boot-parameters-store-device + boot-parameters-store-fs-mount-point boot-parameters-kernel boot-parameters-kernel-arguments boot-parameters-initrd @@ -750,17 +753,25 @@ listed in OS. The C library expects to find it under this file is the reconstruction of GRUB menu entries for old configurations." (mlet %store-monad ((initrd (operating-system-initrd-file os)) (root -> (operating-system-root-file-system os)) + (store -> (operating-system-store-file-system os)) (label -> (kernel->grub-label (operating-system-kernel os)))) - (gexp->file "parameters" - #~(boot-parameters (version 0) - (label #$label) - (root-device #$(file-system-device root)) - (kernel #$(operating-system-kernel-file os)) - (kernel-arguments - #$(operating-system-kernel-arguments os)) - (initrd #$initrd)) - #:set-load-path? #f))) + (gexp->file + "parameters" + #~(boot-parameters (version 1) + (label #$label) + (root-device #$(file-system-device root)) + (store-device + #$(case (file-system-title store) + ((uuid) (file-system-device store)) + ((label) (file-system-device store)) + (else #f))) + (store-fs-mount-point #$(file-system-mount-point store)) + (kernel #$(operating-system-kernel-file os)) + (kernel-arguments + #$(operating-system-kernel-arguments os)) + (initrd #$initrd)) + #:set-load-path? #f))) ;;; @@ -770,7 +781,16 @@ this file is the reconstruction of GRUB menu entries for old configurations." (define-record-type* <boot-parameters> boot-parameters make-boot-parameters boot-parameters? (label boot-parameters-label) + ;; Because we will use the 'store-device' to create the GRUB search command, + ;; the 'store-device' has slightly different semantics than 'root-device'. + ;; The 'store-device' can be a file system uuid, a file system label, or #f, + ;; but it cannot be a device path such as "/dev/sda3", since GRUB would not + ;; understand that. The 'root-device', on the other hand, corresponds + ;; exactly to the device field of the <file-system> object representing the + ;; OS's root file system, so it might be a device path like "/dev/sda3". (root-device boot-parameters-root-device) + (store-device boot-parameters-store-device) + (store-fs-mount-point boot-parameters-store-fs-mount-point) (kernel boot-parameters-kernel) (kernel-arguments boot-parameters-kernel-arguments) (initrd boot-parameters-initrd)) @@ -786,6 +806,10 @@ this file is the reconstruction of GRUB menu entries for old configurations." (boot-parameters (label label) (root-device root) + ;; For backwards compatibility, we assume the store device and the + ;; root device are the same. + (store-device root) + (store-fs-mount-point "/") ;; In the past, we would store the directory name of the kernel instead ;; of the absolute file name of its image. Detect that and correct it. @@ -805,6 +829,22 @@ this file is the reconstruction of GRUB menu entries for old configurations." (string-append directory file)) (('initrd (? string? file)) file))))) + (('boot-parameters ('version 1) + ('label label) + ('root-device root) + ('store-device store) + ('store-fs-mount-point store-fs-mount-point) + ('kernel linux) + ('kernel-arguments arguments) + ('initrd initrd)) + (boot-parameters + (label label) + (root-device root) + (store-device store) + (store-fs-mount-point store-fs-mount-point) + (kernel linux) + (kernel-arguments arguments) + (initrd initrd))) (x ;unsupported format (warning (_ "unrecognized boot parameters for '~a'~%") system) -- 2.9.2