From 87236aed77bd57ecd143d84acf864fb112842118 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 6 Jan 2014 22:25:29 +0100 Subject: 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'. --- guix/scripts/archive.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'guix/scripts/archive.scm') 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 @@ (define-module (guix scripts archive) #: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 @@ (define (show-help) --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 @@ (define %options (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 @@ (define (parse-options) (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 @@ (define (parse-options) (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' \ -- cgit v1.2.3