unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] profiles: manifest-lookup-package: Optionally match version prefix.
@ 2016-09-22 20:28 Ricardo Wurmus
  2016-09-22 20:28 ` [PATCH 2/2] profiles: Build GTK+ input module cache Ricardo Wurmus
  2016-09-26 10:41 ` [PATCH 1/2] profiles: manifest-lookup-package: Optionally match version prefix Ludovic Courtès
  0 siblings, 2 replies; 7+ messages in thread
From: Ricardo Wurmus @ 2016-09-22 20:28 UTC (permalink / raw)
  To: guix-devel

* guix/profiles.scm (manifest-lookup-package): Optionally filter store
item matches by version prefix.
---
 guix/profiles.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 4a2ba1c..78deeb7 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.
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-10-30  7:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 20:28 [PATCH 1/2] profiles: manifest-lookup-package: Optionally match version prefix Ricardo Wurmus
2016-09-22 20:28 ` [PATCH 2/2] profiles: Build GTK+ input module cache Ricardo Wurmus
2016-09-25 11:25   ` 宋文武
2016-09-26  5:56     ` Ricardo Wurmus
2016-09-26 11:04   ` Ludovic Courtès
2016-10-30  7:05     ` Ricardo Wurmus
2016-09-26 10:41 ` [PATCH 1/2] profiles: manifest-lookup-package: Optionally match version prefix Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).