[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
132/197: installer: Add new procedure to check file system specification
From: |
Danny Milosavljevic |
Subject: |
132/197: installer: Add new procedure to check file system specifications. |
Date: |
Mon, 3 Jul 2017 20:37:13 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 0db2908e39db90b25acd234eeb288cc1af8fd52d
Author: John Darrington <address@hidden>
Date: Sun Jan 22 20:14:12 2017 +0100
installer: Add new procedure to check file system specifications.
* gnu/system/installer/filesystems.scm (file-system-spec-not-valid?): New
procedure.
---
gnu/system/installer/filesystems.scm | 76 ++++++++++++++----------------------
1 file changed, 29 insertions(+), 47 deletions(-)
diff --git a/gnu/system/installer/filesystems.scm
b/gnu/system/installer/filesystems.scm
index 0e69fdb..bc20f28 100644
--- a/gnu/system/installer/filesystems.scm
+++ b/gnu/system/installer/filesystems.scm
@@ -40,6 +40,7 @@
#:export (file-system-spec-label)
#:export (file-system-spec-type)
#:export (file-system-spec-uuid)
+ #:export (file-system-spec-not-valid?)
#:export (minimum-store-size)
#:export (filesystem-task-complete?)
@@ -62,6 +63,25 @@
(define valid-file-system-types `("ext2" "ext3" "ext4" "btrfs" "swap"))
+(define (file-system-spec-not-valid? fss)
+ (or
+ (and (not (file-system-spec? fss))
+ (M_ "Invalid file system specification"))
+
+ (and (not (member (symbol->string (file-system-spec-type fss))
+ valid-file-system-types))
+ (format #f (M_ "~a is not a valid file system type.")
+ (file-system-spec-type fss)))
+
+ (and (eq? (file-system-spec-type fss) 'swap)
+ (not (zero? (string-length (file-system-spec-mount-point fss))))
+ (M_ "Swap systems should not have a mount point."))
+
+ (and (not (eq? (file-system-spec-type fss) 'swap))
+ (not (absolute-file-name? (file-system-spec-mount-point fss)))
+ (format #f (M_ "~a is not an absolute file name.")
+ (file-system-spec-mount-point fss)))))
+
(define (make-file-system-spec mount-point label type)
(if (member type valid-file-system-types)
(let ((uuid (slurp "uuidgen" identity)))
@@ -83,35 +103,14 @@
(and (not (find-mount-device "/" mount-points))
(M_ "You must specify a mount point for the root (/)."))
- (fold (lambda (x prev)
- (or prev
- (match x
- ((dev . ($ <file-system-spec> mp label type uuid))
- (if (and (eq? type 'swap) (not (zero? (string-length
mp))))
- (gettext "Swap systems should not have a mount
point")
- #f)))))
- #f mount-points)
-
- (let ((non-absolute-list
- (fold (lambda (x prev)
- (match x
- ((dev . fss)
- (if (or
- (eq? (file-system-spec-type fss) 'swap)
- (absolute-file-name?
(file-system-spec-mount-point fss)))
- prev
- (cons (file-system-spec-mount-point fss)
prev)))))
- '()
- mount-points)))
- (and (not (null? non-absolute-list))
- (ngettext
- (format #f
- (M_ "The mount point ~s is a relative path. All mount
points must be absolute.")
- (car non-absolute-list))
- (format #f
- (M_ "The mount points ~s are relative paths. All mount
points must be absolute.")
- non-absolute-list)
- (length non-absolute-list))))
+ (let loop ((ll mount-points))
+ (match ll
+ ('() #f)
+ (((_ . (? file-system-spec? fss)) . rest)
+ (let ((msg (file-system-spec-not-valid? fss)))
+ (if msg
+ msg
+ (loop (cdr ll)))))))
(and (< (size-of-partition (find-mount-device (%store-directory)
mount-points))
minimum-store-size)
@@ -128,24 +127,7 @@
(format #f
(M_ "You have specified the mount point ~a more than
once.")
(file-system-spec-mount-point fss))
- (loop rest (cons fss ac))))))
-
- (let ((partitions-without-filesystems
- (fold (lambda (x prev)
- (match x
- ((dev . ($ <file-system-spec> mp label type uuid))
- (if type prev
- (cons dev prev)))))
- '() mount-points)))
-
- (if (null? partitions-without-filesystems)
- #f
- (ngettext
- (format #f (M_ "The filesystem type for partition ~a is not valid.")
- (car partitions-without-filesystems))
- (format #f (M_ "The filesystem type for partitions ~a are not
valid.")
- partitions-without-filesystems)
- (length partitions-without-filesystems))))))
+ (loop rest (cons fss ac))))))))
(define (make-filesystem-page parent title)
(make-page (page-surface parent)
- 93/197: installer: Add a dedicated make to format filesystems., (continued)
- 93/197: installer: Add a dedicated make to format filesystems., Danny Milosavljevic, 2017/07/03
- 100/197: installer: Do not perform tasks more than once., Danny Milosavljevic, 2017/07/03
- 106/197: installer: Properly handle swap partitions when generating the configuration., Danny Milosavljevic, 2017/07/03
- 114/197: installer: Check that swap spaces have not been assigned mount points, Danny Milosavljevic, 2017/07/03
- 112/197: gurses: form: Use match instead of car, cdr etc., Danny Milosavljevic, 2017/07/03
- 125/197: installer: Do not assume the root file system is of type "ext4"., Danny Milosavljevic, 2017/07/03
- 130/197: installer: Delete unused procedure "justify"., Danny Milosavljevic, 2017/07/03
- 134/197: installer: Tolerate an undefined system role in config generation., Danny Milosavljevic, 2017/07/03
- 137/197: installer: Prepare for new wireless network features., Danny Milosavljevic, 2017/07/03
- 140/197: installer: Fix the key map option., Danny Milosavljevic, 2017/07/03
- 132/197: installer: Add new procedure to check file system specifications.,
Danny Milosavljevic <=
- 145/197: gurses: Avoid yet another use of car and cdr., Danny Milosavljevic, 2017/07/03
- 129/197: installer: Emphasise that writing filesystems destroys existing data., Danny Milosavljevic, 2017/07/03
- 150/197: gurses: Reimplement pad-complex-string., Danny Milosavljevic, 2017/07/03
- 159/197: installer: Fix i18n in dialogs., Danny Milosavljevic, 2017/07/03
- 154/197: installer: Main page: Redisplay translatable strings upon refresh., Danny Milosavljevic, 2017/07/03
- 157/197: installer: Replace 'file-browser' with 'key-map'., Danny Milosavljevic, 2017/07/03
- 161/197: installer: Improve i18n in ping page., Danny Milosavljevic, 2017/07/03
- 162/197: gurses: Avoid one use of car/cdr., Danny Milosavljevic, 2017/07/03
- 166/197: installer: Provide verbose description of locale., Danny Milosavljevic, 2017/07/03
- 167/197: installer: Fix bug when changing languages., Danny Milosavljevic, 2017/07/03