summaryrefslogtreecommitdiff
path: root/guix/profiles.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2016-09-22 22:25:12 +0200
committerRicardo Wurmus <rekado@elephly.net>2016-09-26 07:58:17 +0200
commit2c9f4786c967d2e5090cef2a18bebf8d840e9428 (patch)
treef7cb849672ea764d89b6b098b69cc93e812d4bda /guix/profiles.scm
parentf3cfe4515ad747fe64999b9904d9866ef0921081 (diff)
profiles: manifest-lookup-package: Optionally match version prefix.
* guix/profiles.scm (manifest-lookup-package): Optionally filter store item matches by version prefix.
Diffstat (limited to 'guix/profiles.scm')
-rw-r--r--guix/profiles.scm19
1 files changed, 14 insertions, 5 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 4a2ba1c2f4..78deeb7977 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -472,21 +472,30 @@ replace it."
(cons (gexp-input thing output) deps)))
(manifest-entries manifest)))
-(define (manifest-lookup-package manifest name)
+(define* (manifest-lookup-package manifest name #:optional version)
"Return as a monadic value the first package or store path referenced by
-MANIFEST that named NAME, or #f if not found."
+MANIFEST that is named NAME and optionally has the given VERSION prefix, or #f
+if not found."
;; Return as a monadic value the package or store path referenced by the
;; manifest ENTRY, or #f if not referenced.
(define (entry-lookup-package entry)
(define (find-among-inputs inputs)
(find (lambda (input)
(and (package? input)
- (equal? name (package-name input))))
+ (equal? name (package-name input))
+ (if version
+ (string-prefix? version (package-version input))
+ #t)))
inputs))
(define (find-among-store-items items)
(find (lambda (item)
- (equal? name (package-name->name+version
- (store-path-package-name item))))
+ (let-values (((pkg-name pkg-version)
+ (package-name->name+version
+ (store-path-package-name item))))
+ (and (equal? name pkg-name)
+ (if version
+ (string-prefix? version pkg-version)
+ #t))))
items))
;; TODO: Factorize.