mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
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'.
This commit is contained in:
parent
b846126052
commit
87236aed77
3 changed files with 51 additions and 1 deletions
|
@ -938,6 +938,12 @@ package to a machine connected over SSH, one would run:
|
||||||
guix archive --export emacs | ssh the-machine guix archive --import
|
guix archive --export emacs | ssh the-machine guix archive --import
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
@noindent
|
||||||
|
However, note that, in this example, all of @code{emacs} and its
|
||||||
|
dependencies are transferred, regardless of what is already available in
|
||||||
|
the target machine's store. The @code{--missing} option can help figure
|
||||||
|
out which items are missing from the target's store.
|
||||||
|
|
||||||
Archives are stored in the ``Nix archive'' or ``Nar'' format, which is
|
Archives are stored in the ``Nix archive'' or ``Nar'' format, which is
|
||||||
comparable in spirit to `tar'. When exporting, the daemon digitally
|
comparable in spirit to `tar'. When exporting, the daemon digitally
|
||||||
signs the contents of the archive, and that digital signature is
|
signs the contents of the archive, and that digital signature is
|
||||||
|
@ -959,6 +965,11 @@ therein into the store. Abort if the archive has an invalid digital
|
||||||
signature, or if it is signed by a public key not among the authorized
|
signature, or if it is signed by a public key not among the authorized
|
||||||
keys (see @code{--authorize} below.)
|
keys (see @code{--authorize} below.)
|
||||||
|
|
||||||
|
@item --missing
|
||||||
|
Read a list of store file names from the standard input, one per line,
|
||||||
|
and write on the standard output the subset of these files missing from
|
||||||
|
the store.
|
||||||
|
|
||||||
@item --generate-key[=@var{parameters}]
|
@item --generate-key[=@var{parameters}]
|
||||||
@cindex signing, archives
|
@cindex signing, archives
|
||||||
Generate a new key pair for the daemons. This is a prerequisite before
|
Generate a new key pair for the daemons. This is a prerequisite before
|
||||||
|
|
|
@ -27,6 +27,8 @@ (define-module (guix scripts archive)
|
||||||
#:use-module (guix pki)
|
#:use-module (guix pki)
|
||||||
#:use-module (guix pk-crypto)
|
#:use-module (guix pk-crypto)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
|
#:use-module (ice-9 format)
|
||||||
|
#:use-module (ice-9 rdelim)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
|
@ -55,6 +57,8 @@ (define (show-help)
|
||||||
--export export the specified files/packages to stdout"))
|
--export export the specified files/packages to stdout"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
--import import from the archive passed on stdin"))
|
--import import from the archive passed on stdin"))
|
||||||
|
(display (_ "
|
||||||
|
--missing print the files from stdin that are missing"))
|
||||||
(newline)
|
(newline)
|
||||||
(display (_ "
|
(display (_ "
|
||||||
--generate-key[=PARAMETERS]
|
--generate-key[=PARAMETERS]
|
||||||
|
@ -102,6 +106,9 @@ (define %options
|
||||||
(option '("import") #f #f
|
(option '("import") #f #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'import #t 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
|
(option '("generate-key") #f #t
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(catch 'gcry-error
|
(catch 'gcry-error
|
||||||
|
@ -294,6 +301,15 @@ (define (parse-options)
|
||||||
(alist-cons 'argument arg result))
|
(alist-cons 'argument arg result))
|
||||||
%default-options))
|
%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
|
(with-error-handling
|
||||||
;; Ask for absolute file names so that .drv file names passed from the
|
;; Ask for absolute file names so that .drv file names passed from the
|
||||||
;; user to 'read-derivation' are absolute when it returns.
|
;; user to 'read-derivation' are absolute when it returns.
|
||||||
|
@ -310,6 +326,11 @@ (define (parse-options)
|
||||||
(export-from-store store opts))
|
(export-from-store store opts))
|
||||||
((assoc-ref opts 'import)
|
((assoc-ref opts 'import)
|
||||||
(import-paths store (current-input-port)))
|
(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
|
(else
|
||||||
(leave
|
(leave
|
||||||
(_ "either '--export' or '--import' \
|
(_ "either '--export' or '--import' \
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# GNU Guix --- Functional package management for GNU
|
# GNU Guix --- Functional package management for GNU
|
||||||
# Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
|
# Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Guix.
|
# This file is part of GNU Guix.
|
||||||
#
|
#
|
||||||
|
@ -44,5 +44,23 @@ guix archive --import < "$archive" 2>&1 | grep "import.*guile-bootstrap"
|
||||||
if guix archive something-that-does-not-exist
|
if guix archive something-that-does-not-exist
|
||||||
then false; else true; fi
|
then false; else true; fi
|
||||||
|
|
||||||
|
# This one must not be listed as missing.
|
||||||
|
guix build guile-bootstrap > "$archive"
|
||||||
|
guix archive --missing < "$archive"
|
||||||
|
test "`guix archive --missing < "$archive"`" = ""
|
||||||
|
|
||||||
|
# Two out of three should be listed as missing.
|
||||||
|
echo "$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo" >> "$archive"
|
||||||
|
echo "$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bar" >> "$archive"
|
||||||
|
guix archive --missing < "$archive" > "$archive_alt"
|
||||||
|
echo "$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo" > "$archive"
|
||||||
|
echo "$NIX_STORE_DIR/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bar" >> "$archive"
|
||||||
|
cmp "$archive" "$archive_alt"
|
||||||
|
|
||||||
|
# This is not a valid store file name, so an error.
|
||||||
|
echo something invalid > "$archive"
|
||||||
|
if guix archive --missing < "$archive"
|
||||||
|
then false; else true; fi
|
||||||
|
|
||||||
if echo foo | guix archive --authorize
|
if echo foo | guix archive --authorize
|
||||||
then false; else true; fi
|
then false; else true; fi
|
||||||
|
|
Loading…
Reference in a new issue