From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:44966) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GES-0001ch-Js for guix-patches@gnu.org; Fri, 06 Sep 2019 11:33:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GER-0005hO-0S for guix-patches@gnu.org; Fri, 06 Sep 2019 11:33:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6GEQ-0005hA-SC for guix-patches@gnu.org; Fri, 06 Sep 2019 11:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i6GEQ-0003eJ-L3 for guix-patches@gnu.org; Fri, 06 Sep 2019 11:33:02 -0400 Subject: [bug#37322] [PATCH 1/2] adds the capability of importing a specified version to the crate importer Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:44848) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6GDq-00019a-LY for guix-patches@gnu.org; Fri, 06 Sep 2019 11:32:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6GDp-00051O-4l for guix-patches@gnu.org; Fri, 06 Sep 2019 11:32:26 -0400 Received: from mx1.riseup.net ([198.252.153.129]:43574) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6GDo-000503-PO for guix-patches@gnu.org; Fri, 06 Sep 2019 11:32:25 -0400 Received: from capuchin.riseup.net (capuchin-pn.riseup.net [10.0.1.176]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id 714CA1A0EB0 for ; Fri, 6 Sep 2019 08:32:22 -0700 (PDT) From: Martin Becze Date: Fri, 6 Sep 2019 11:32:10 -0400 Message-Id: <20190906153211.8613-1-mjbecze@riseup.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Cc: Martin Becze --- guix/import/crate.scm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index f6057dbf8b..3266ebdfec 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2016 David Craven ;;; Copyright =C2=A9 2019 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2019 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -181,8 +182,8 @@ and LICENSE." ;; This regexp matches that. (make-regexp "^(.*) OR (.*)$")) =20 -(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) @@ -193,13 +194,29 @@ and LICENSE." (define (normal-dependency? dependency) (eq? (crate-dependency-kind dependency) 'normal)) =20 + (define crate-name-version-list + (let ((lnv (string-split crate-name@version #\@))) + (if (=3D 1 (length lnv)) + (append lnv '(#f)) + lnv))) + + (define crate-name + (car crate-name-version-list)) + + (define crate (lookup-crate crate-name)) =20 + (define crate-version-string + (let ((version (cadr crate-name-version-list))) + (if version + version + (crate-latest-version crate)))) + (and crate (let* ((version (find (lambda (version) (string=3D? (crate-version-number = version) - (crate-latest-version cr= ate))) + crate-version-string)) (crate-versions crate))) (dependencies (crate-version-dependencies version)) (dep-crates (filter normal-dependency? dependencies)) --=20 2.23.0