summaryrefslogtreecommitdiff
path: root/guix/scripts/archive.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-01-06 22:25:29 +0100
committerLudovic Courtès <ludo@gnu.org>2014-01-06 22:25:29 +0100
commit87236aed77bd57ecd143d84acf864fb112842118 (patch)
tree77ebed23b8267ab621a69051ba60e58dfe715689 /guix/scripts/archive.scm
parentb84612605204d604da84b30e56966994cc03d0a3 (diff)
archive: Add '--missing'.
* guix/scripts/archive.scm (show-help, %options): Add '--missing'. (guix-archive)[lines]: New procedure. Use it to honor '--missing'. * tests/guix-archive.sh: Add tests. * doc/guix.texi (Invoking guix archive): Document '--missing'.
Diffstat (limited to 'guix/scripts/archive.scm')
-rw-r--r--guix/scripts/archive.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index 3b778d8151..32690c6b45 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -27,6 +27,8 @@
#:use-module (guix pki)
#:use-module (guix pk-crypto)
#:use-module (ice-9 match)
+ #:use-module (ice-9 format)
+ #:use-module (ice-9 rdelim)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
@@ -55,6 +57,8 @@ Export/import one or more packages from/to the store.\n"))
--export export the specified files/packages to stdout"))
(display (_ "
--import import from the archive passed on stdin"))
+ (display (_ "
+ --missing print the files from stdin that are missing"))
(newline)
(display (_ "
--generate-key[=PARAMETERS]
@@ -102,6 +106,9 @@ Export/import one or more packages from/to the store.\n"))
(option '("import") #f #f
(lambda (opt name arg result)
(alist-cons 'import #t result)))
+ (option '("missing") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'missing #t result)))
(option '("generate-key") #f #t
(lambda (opt name arg result)
(catch 'gcry-error
@@ -294,6 +301,15 @@ the input port."
(alist-cons 'argument arg result))
%default-options))
+ (define (lines port)
+ ;; Return lines read from PORT.
+ (let loop ((line (read-line port))
+ (result '()))
+ (if (eof-object? line)
+ (reverse result)
+ (loop (read-line port)
+ (cons line result)))))
+
(with-error-handling
;; Ask for absolute file names so that .drv file names passed from the
;; user to 'read-derivation' are absolute when it returns.
@@ -310,6 +326,11 @@ the input port."
(export-from-store store opts))
((assoc-ref opts 'import)
(import-paths store (current-input-port)))
+ ((assoc-ref opts 'missing)
+ (let* ((files (lines (current-input-port)))
+ (missing (remove (cut valid-path? store <>)
+ files)))
+ (format #t "~{~a~%~}" missing)))
(else
(leave
(_ "either '--export' or '--import' \