[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
16/18: installer: New procedure key-value-slurp.
From: |
John Darrington |
Subject: |
16/18: installer: New procedure key-value-slurp. |
Date: |
Thu, 2 Feb 2017 18:13:05 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 49c3bbe5a6b42982215cff87c1a07c74193f3a64
Author: John Darrington <address@hidden>
Date: Thu Feb 2 08:13:24 2017 +0100
installer: New procedure key-value-slurp.
* gnu/system/installer/utils.scm (key-value-slurp): New procedure.
* gnu/system/installer/format.scm: Use it where appropriate.
---
gnu/system/installer/format.scm | 12 +-----------
gnu/system/installer/utils.scm | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/gnu/system/installer/format.scm b/gnu/system/installer/format.scm
index f0a9aaf..b8c5f5e 100644
--- a/gnu/system/installer/format.scm
+++ b/gnu/system/installer/format.scm
@@ -36,17 +36,7 @@
(include "i18n.scm")
(define (device-attributes dev)
- (slurp (string-append "blkid -o export " dev)
- (lambda (x)
- (let ((idx (string-index x #\=)))
- (cons (string->symbol (string-fold
- (lambda (c acc)
- (string-append
- acc
- (make-string 1 (char-downcase c))))
- ""
- (substring x 0 idx)))
- (substring x (1+ idx) (string-length x)))))))
+ (key-value-slurp (string-append "blkid -o export " dev)))
(define (device-fs-uuid dev)
"Retrieve the UUID of the filesystem on DEV, where DEV is the name of the
diff --git a/gnu/system/installer/utils.scm b/gnu/system/installer/utils.scm
index e88524f..082dcc7 100644
--- a/gnu/system/installer/utils.scm
+++ b/gnu/system/installer/utils.scm
@@ -21,6 +21,7 @@
justify*
addstr*
slurp
+ key-value-slurp
quit-key?
push-cursor
@@ -162,6 +163,22 @@ This version assumes some external entity puts in the
carriage returns."
result
#f)))
+(define (key-value-slurp cmd)
+ "Slurp CMD, which is expected to give an output of key-value pairs -
+each pair terminated with a newline and the key/value delimited with ="
+ (slurp cmd
+ (lambda (x)
+ (let ((idx (string-index x #\=)))
+ (cons (string->symbol (string-fold
+ (lambda (c acc)
+ (string-append
+ acc
+ (make-string 1 (char-downcase c))))
+ ""
+ (substring x 0 idx)))
+ (substring x (1+ idx) (string-length x)))))))
+
+
(define (slurp-real port proc)
"Execute CMD in a shell and return a list of strings from its standard
output,
one per line. If PROC is not #f then it must be a procedure taking a string
- branch wip-installer updated (9ff399e -> 688f4f7), John Darrington, 2017/02/02
- 04/18: installer: Add optional arguments to addstr*., John Darrington, 2017/02/02
- 02/18: installer: New gettext keyword M_., John Darrington, 2017/02/02
- 01/18: installer: Avoid wpa_supplicant's output causing screen damage., John Darrington, 2017/02/02
- 05/18: installer: Main page: Redisplay translatable strings upon refresh., John Darrington, 2017/02/02
- 09/18: installer: Correct placement of gettext call., John Darrington, 2017/02/02
- 08/18: installer: Replace 'file-browser' with 'key-map'., John Darrington, 2017/02/02
- 06/18: installer: Use _ instead of M_ for host-name-refresh., John Darrington, 2017/02/02
- 14/18: gurses: Cache the windows of buttons., John Darrington, 2017/02/02
- 16/18: installer: New procedure key-value-slurp.,
John Darrington <=
- 18/18: installer: Fix bug when changing languages., John Darrington, 2017/02/02
- 07/18: installer: New page to select language., John Darrington, 2017/02/02
- 10/18: installer: Fix i18n in dialogs., John Darrington, 2017/02/02
- 17/18: installer: Provide verbose description of locale., John Darrington, 2017/02/02
- 03/18: installer: New file i18n.scm., John Darrington, 2017/02/02
- 11/18: installer: New convenience procedures., John Darrington, 2017/02/02
- 13/18: gurses: Avoid one use of car/cdr., John Darrington, 2017/02/02
- 15/18: gurses: Use match instead of car., John Darrington, 2017/02/02
- 12/18: installer: Improve i18n in ping page., John Darrington, 2017/02/02