From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:55594) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7Ljv-00043L-7G for guix-patches@gnu.org; Mon, 09 Sep 2019 11:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7Lju-0003X5-1m for guix-patches@gnu.org; Mon, 09 Sep 2019 11:38:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i7Ljt-0003Ww-UG for guix-patches@gnu.org; Mon, 09 Sep 2019 11:38:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i7Ljt-0001AZ-QX for guix-patches@gnu.org; Mon, 09 Sep 2019 11:38:01 -0400 Subject: [bug#37322] [PATCH v2 1/2] added versoining to crate import Resent-Message-ID: From: Martin Becze Date: Mon, 9 Sep 2019 11:36:04 -0400 Message-Id: <20190909153605.1484-1-mjbecze@riseup.net> In-Reply-To: <877e6j9dmj.fsf.org> References: <877e6j9dmj.fsf.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 37322@debbugs.gnu.org, ludo@gnu.org Cc: Martin Becze --- guix/import/crate.scm | 12 +++++++++--- guix/scripts/import/crate.scm | 10 +++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index f6057dbf8b..de56432e3c 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 David Craven ;;; Copyright © 2019 Ludovic Courtès +;;; Copyright © 2019 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -181,8 +182,8 @@ and LICENSE." ;; This regexp matches that. (make-regexp "^(.*) OR (.*)$")) -(define (crate->guix-package crate-name) - "Fetch the metadata for CRATE-NAME from crates.io, and return the +(define (crate->guix-package crate-name version) + "Fetch the metadata for CRATE-NAME@VERSION from crates.io, and return the `package' s-expression corresponding to that package, or #f on failure." (define (string->license string) (match (regexp-exec %dual-license-rx string) @@ -196,10 +197,15 @@ and LICENSE." (define crate (lookup-crate crate-name)) + (define crate-version-string + (if version + version + (crate-latest-version crate))) + (and crate (let* ((version (find (lambda (version) (string=? (crate-version-number version) - (crate-latest-version crate))) + crate-version-string)) (crate-versions crate))) (dependencies (crate-version-dependencies version)) (dep-crates (filter normal-dependency? dependencies)) diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index cab9a4397b..948b90ec15 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -2,6 +2,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 David Thompson ;;; Copyright © 2016 David Craven +;;; Copyright © 2019 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,6 +67,7 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) ;;; (define (guix-import-crate . args) + (define (parse-options) ;; Return the alist of option values. (args-fold* args %options @@ -75,6 +77,7 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (alist-cons 'argument arg result)) %default-options)) + (let* ((opts (parse-options)) (args (filter-map (match-lambda (('argument . value) @@ -83,7 +86,12 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (reverse opts)))) (match args ((package-name) - (let ((sexp (crate->guix-package package-name))) + (define-values (name version) + (match (string-split package-name #\@) + ((name version) (values name version)) + ((name) (values name #f)))) + + (let ((sexp (crate->guix-package name version))) (unless sexp (leave (G_ "failed to download meta-data for package '~a'~%") package-name)) -- 2.23.0