aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-20 11:52:45 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-20 12:13:39 +0200
commitdbc31ab25c355eae373e1766b4a77fccbe462bf3 (patch)
treebadd7863749d9f3783eae95a33751abf0bfe0857 /guix
parent755e1147aa33d1c305bb9db6c5e03cf1063079fc (diff)
downloadgnu-guix-dbc31ab25c355eae373e1766b4a77fccbe462bf3.tar
gnu-guix-dbc31ab25c355eae373e1766b4a77fccbe462bf3.tar.gz
guix package: Add optional argument to --search-paths.
* guix/scripts/package.scm (search-path-environment-variables): Add #:kind parameter. Pass it to 'environment-variable-definition'. (display-search-paths): Add #:kind parameter and pass it to 'search-path-environment-variables'. (%options): Add an optional parameter for "--search-paths". (guix-package)[process-query]: Handle it. * tests/guix-package-net.sh: Adjust existing test. * tests/guix-package.sh: Adjust existing tests and add new test. * doc/guix.texi (Invoking guix package): Document it.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/package.scm38
1 files changed, 27 insertions, 11 deletions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 300af681c2..d6d7c66cf3 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -376,10 +376,13 @@ an output path different than CURRENT-PATH."
;;;
(define* (search-path-environment-variables entries profile
- #:optional (getenv getenv))
+ #:optional (getenv getenv)
+ #:key (kind 'exact))
"Return environment variable definitions that may be needed for the use of
ENTRIES, a list of manifest entries, in PROFILE. Use GETENV to determine the
-current settings and report only settings not already effective."
+current settings and report only settings not already effective. KIND
+must be one of 'exact, 'prefix, or 'suffix, depending on the kind of search
+path definition to be returned."
(let ((search-paths (delete-duplicates
(cons $PATH
(append-map manifest-entry-search-paths
@@ -388,17 +391,19 @@ current settings and report only settings not already effective."
((spec . value)
(let ((variable (search-path-specification-variable spec))
(sep (search-path-specification-separator spec)))
- ;; TODO: Offer the choice between exact/prefix/suffix.
(environment-variable-definition variable value
- #:separator sep))))
+ #:separator sep
+ #:kind kind))))
(evaluate-search-paths search-paths (list profile)
getenv))))
-(define (display-search-paths entries profile)
+(define* (display-search-paths entries profile
+ #:key (kind 'exact))
"Display the search path environment variables that may need to be set for
ENTRIES, a list of manifest entries, in the context of PROFILE."
(let* ((profile (user-friendly-profile profile))
- (settings (search-path-environment-variables entries profile)))
+ (settings (search-path-environment-variables entries profile
+ #:kind kind)))
(unless (null? settings)
(format #t (_ "The following environment variable definitions may be needed:~%"))
(format #t "~{ ~a~%~}" settings))))
@@ -533,10 +538,20 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
(lambda (opt name arg result arg-handler)
(values (alist-cons 'switch-generation arg result)
#f)))
- (option '("search-paths") #f #f
+ (option '("search-paths") #f #t
(lambda (opt name arg result arg-handler)
- (values (cons `(query search-paths) result)
- #f)))
+ (let ((kind (match arg
+ ((or "exact" "prefix" "suffix")
+ (string->symbol arg))
+ (#f
+ 'exact)
+ (x
+ (leave (_ "~a: unsupported \
+kind of search path~%")
+ x)))))
+ (values (cons `(query search-paths ,kind)
+ result)
+ #f))))
(option '(#\p "profile") #t #f
(lambda (opt name arg result arg-handler)
(values (alist-cons 'profile (canonicalize-profile arg)
@@ -977,12 +992,13 @@ more information.~%"))
(find-packages-by-name name version)))
#t))
- (('search-paths)
+ (('search-paths kind)
(let* ((manifest (profile-manifest profile))
(entries (manifest-entries manifest))
(profile (user-friendly-profile profile))
(settings (search-path-environment-variables entries profile
- (const #f))))
+ (const #f)
+ #:kind kind)))
(format #t "~{~a~%~}" settings)
#t))