[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/10: guix system: Check mapped devices upon 'init' and 'reconfigure'.
From: |
Ludovic Courtès |
Subject: |
09/10: guix system: Check mapped devices upon 'init' and 'reconfigure'. |
Date: |
Fri, 22 Dec 2017 04:04:12 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 893d0b0bf320eb20b9dd7c57eefcd2fc1371225d
Author: Ludovic Courtès <address@hidden>
Date: Mon Dec 18 15:05:55 2017 +0100
guix system: Check mapped devices upon 'init' and 'reconfigure'.
* guix/scripts/system.scm (check-mapped-devices): New procedure.
(perform-action): Add call to 'check-mapped-devices'.
---
guix/scripts/system.scm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 36aed33..ebcf3e4 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -44,6 +44,7 @@
#:use-module (gnu system)
#:use-module (gnu bootloader)
#:use-module (gnu system file-systems)
+ #:use-module (gnu system mapped-devices)
#:use-module (gnu system linux-container)
#:use-module (gnu system uuid)
#:use-module (gnu system vm)
@@ -621,6 +622,22 @@ any, are available. Raise an error if they're not."
;; Better be safe than sorry.
(exit 1))))
+(define (check-mapped-devices mapped-devices)
+ "Check that each of MAPPED-DEVICES is valid according to the 'check'
+procedure of its type."
+ (for-each (lambda (md)
+ (let ((check (mapped-device-kind-check
+ (mapped-device-type md))))
+ ;; We expect CHECK to raise an exception with a detailed
+ ;; '&message' if something goes wrong, but handle the case
+ ;; where it just returns #f.
+ (unless (check md)
+ (leave (G_ "~a: invalid '~a' mapped device~%")
+ (location->string
+ (source-properties->location
+ (mapped-device-location md)))))))
+ mapped-devices))
+
;;;
;;; Action.
@@ -710,9 +727,10 @@ output when building a system derivation, such as a disk
image."
;; Check whether the declared file systems exist. This is better than
;; instantiating a broken configuration. Assume that we can only check if
;; running as root.
- (when (and (memq action '(init reconfigure))
- (zero? (getuid)))
- (check-file-system-availability (operating-system-file-systems os)))
+ (when (memq action '(init reconfigure))
+ (when (zero? (getuid))
+ (check-file-system-availability (operating-system-file-systems os)))
+ (check-mapped-devices (operating-system-mapped-devices os)))
(mlet* %store-monad
((sys (system-derivation-for-action os action
- branch master updated (a468f89 -> d633f2f), Ludovic Courtès, 2017/12/22
- 03/10: services: urandom-seed: Become a dependency of 'user-processes'., Ludovic Courtès, 2017/12/22
- 06/10: gnu: Add python-activepapers., Ludovic Courtès, 2017/12/22
- 08/10: mapped-devices: 'luks-device-mapping' checks its source device., Ludovic Courtès, 2017/12/22
- 02/10: services: 'user-processes-service-type' can now be extended., Ludovic Courtès, 2017/12/22
- 04/10: services: urandom-seed: Deprecate the 'urandom-seed-service' procedure., Ludovic Courtès, 2017/12/22
- 10/10: gnu: mutter: Add xorg-xserver-xwayland input., Ludovic Courtès, 2017/12/22
- 07/10: mapped-devices: Add 'location' and 'check' fields., Ludovic Courtès, 2017/12/22
- 09/10: guix system: Check mapped devices upon 'init' and 'reconfigure'.,
Ludovic Courtès <=
- 01/10: doc: Document fixed-output derivations., Ludovic Courtès, 2017/12/22
- 05/10: services: urandom-seed: Depend on udev., Ludovic Courtès, 2017/12/22