pack: Add '--save-provenance'.

* guix/scripts/pack.scm (show-help, %options): Add '--save-provenance'.
(guix-pack)[manifest-from-args]: Honor it.
* doc/guix.texi (Invoking guix pack): Document it.
This commit is contained in:
Ludovic Courtès 2019-03-06 23:53:08 +01:00
parent 2cb658a9a7
commit d40ec4a0d0
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 43 additions and 1 deletions

View File

@ -4777,6 +4777,23 @@ symlink target.
For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin} For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
symlink pointing to the @file{bin} sub-directory of the profile. symlink pointing to the @file{bin} sub-directory of the profile.
@item --save-provenance
Save provenance information for the packages passed on the command line.
Provenance information includes the URL and commit of the channels in use
(@pxref{Channels}).
Provenance information is saved in the
@file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
usual package metadata---the name and version of each package, their
propagated inputs, and so on. It is useful information to the recipient of
the pack, who then knows how the pack was (supposedly) obtained.
This option is not enabled by default because, like timestamps, provenance
information contributes nothing to the build process. In other words, there
is an infinity of channel URLs and commit IDs that can lead to the same pack.
Recording such ``silent'' metadata in the output thus potentially breaks the
source-to-binary bitwise reproducibility property.
@item --localstatedir @item --localstatedir
@itemx --profile-name=@var{name} @itemx --profile-name=@var{name}
Include the ``local state directory'', @file{/var/guix}, in the resulting Include the ``local state directory'', @file{/var/guix}, in the resulting

View File

@ -32,6 +32,7 @@
#:use-module (guix modules) #:use-module (guix modules)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix profiles) #:use-module (guix profiles)
#:use-module (guix describe)
#:use-module (guix derivations) #:use-module (guix derivations)
#:use-module (guix search-paths) #:use-module (guix search-paths)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
@ -678,6 +679,9 @@ please email '~a'~%")
(x (x
(leave (G_ "~a: invalid symlink specification~%") (leave (G_ "~a: invalid symlink specification~%")
arg))))) arg)))))
(option '("save-provenance") #f #f
(lambda (opt name arg result)
(alist-cons 'save-provenance? #t result)))
(option '("localstatedir") #f #f (option '("localstatedir") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'localstatedir? #t result))) (alist-cons 'localstatedir? #t result)))
@ -725,6 +729,8 @@ Create a bundle of PACKAGE.\n"))
-S, --symlink=SPEC create symlinks to the profile according to SPEC")) -S, --symlink=SPEC create symlinks to the profile according to SPEC"))
(display (G_ " (display (G_ "
-m, --manifest=FILE create a pack with the manifest from FILE")) -m, --manifest=FILE create a pack with the manifest from FILE"))
(display (G_ "
--save-provenance save provenance information"))
(display (G_ " (display (G_ "
--localstatedir include /var/guix in the resulting pack")) --localstatedir include /var/guix in the resulting pack"))
(display (G_ " (display (G_ "
@ -772,13 +778,32 @@ Create a bundle of PACKAGE.\n"))
(list (transform store package) "out"))) (list (transform store package) "out")))
(filter-map maybe-package-argument opts))) (filter-map maybe-package-argument opts)))
(manifest-file (assoc-ref opts 'manifest))) (manifest-file (assoc-ref opts 'manifest)))
(define properties
(if (assoc-ref opts 'save-provenance?)
(lambda (package)
(match (package-provenance package)
(#f
(warning (G_ "could not determine provenance of package ~a~%")
(package-full-name package))
'())
(sexp
`((provenance . ,sexp)))))
(const '())))
(cond (cond
((and manifest-file (not (null? packages))) ((and manifest-file (not (null? packages)))
(leave (G_ "both a manifest and a package list were given~%"))) (leave (G_ "both a manifest and a package list were given~%")))
(manifest-file (manifest-file
(let ((user-module (make-user-module '((guix profiles) (gnu))))) (let ((user-module (make-user-module '((guix profiles) (gnu)))))
(load* manifest-file user-module))) (load* manifest-file user-module)))
(else (packages->manifest packages))))) (else
(manifest
(map (match-lambda
((package output)
(package->manifest-entry package output
#:properties
(properties package))))
packages))))))
(with-error-handling (with-error-handling
(with-store store (with-store store