From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: [PATCH 1/2] profiles: manifest-lookup-package: Optionally match version prefix. Date: Thu, 22 Sep 2016 22:28:26 +0200 Message-ID: <20160922202827.22039-1-rekado@elephly.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnAbt-0006yP-SH for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnAbq-0008En-HT for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:45 -0400 Received: from sender163-mail.zoho.com ([74.201.84.163]:21412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnAbq-0008DZ-A9 for guix-devel@gnu.org; Thu, 22 Sep 2016 16:28:42 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * 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