summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/pack.scm27
-rw-r--r--guix/scripts/package.scm36
2 files changed, 27 insertions, 36 deletions
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 3f76336abf..fbef079910 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -32,6 +32,7 @@
#:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix profiles)
+ #:use-module (guix describe)
#:use-module (guix derivations)
#:use-module (guix search-paths)
#:use-module (guix build-system gnu)
@@ -678,6 +679,9 @@ please email '~a'~%")
(x
(leave (G_ "~a: invalid symlink specification~%")
arg)))))
+ (option '("save-provenance") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'save-provenance? #t result)))
(option '("localstatedir") #f #f
(lambda (opt name arg result)
(alist-cons 'localstatedir? #t result)))
@@ -726,6 +730,8 @@ Create a bundle of PACKAGE.\n"))
(display (G_ "
-m, --manifest=FILE create a pack with the manifest from FILE"))
(display (G_ "
+ --save-provenance save provenance information"))
+ (display (G_ "
--localstatedir include /var/guix in the resulting pack"))
(display (G_ "
--profile-name=NAME
@@ -772,13 +778,32 @@ Create a bundle of PACKAGE.\n"))
(list (transform store package) "out")))
(filter-map maybe-package-argument opts)))
(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
((and manifest-file (not (null? packages)))
(leave (G_ "both a manifest and a package list were given~%")))
(manifest-file
(let ((user-module (make-user-module '((guix profiles) (gnu)))))
(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-store store
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 0e70315708..efff511299 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -36,7 +36,7 @@
#:use-module (guix config)
#:use-module (guix scripts)
#:use-module (guix scripts build)
- #:autoload (guix describe) (current-profile-entries)
+ #:autoload (guix describe) (package-provenance)
#:use-module ((guix build utils)
#:select (directory-exists? mkdir-p))
#:use-module (ice-9 format)
@@ -552,40 +552,6 @@ upgrading, #f otherwise."
(output "out") ;XXX: wild guess
(item item))))
-(define (package-provenance package)
- "Return the provenance of PACKAGE as an sexp for use as the 'provenance'
-property of manifest entries, or #f if it could not be determined."
- (define (entry-source entry)
- (match (assq 'source
- (manifest-entry-properties entry))
- (('source value) value)
- (_ #f)))
-
- (match (and=> (package-location package) location-file)
- (#f #f)
- (file
- (let ((file (if (string-prefix? "/" file)
- file
- (search-path %load-path file))))
- (and file
- (string-prefix? (%store-prefix) file)
-
- ;; Always store information about the 'guix' channel and
- ;; optionally about the specific channel FILE comes from.
- (or (let ((main (and=> (find (lambda (entry)
- (string=? "guix"
- (manifest-entry-name entry)))
- (current-profile-entries))
- entry-source))
- (extra (any (lambda (entry)
- (let ((item (manifest-entry-item entry)))
- (and (string-prefix? item file)
- (entry-source entry))))
- (current-profile-entries))))
- (and main
- `(,main
- ,@(if extra (list extra) '()))))))))))
-
(define (package->manifest-entry* package output)
"Like 'package->manifest-entry', but attach PACKAGE provenance meta-data to
the resulting manifest entry."