From patchwork Mon Nov 16 19:07:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25163 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B428927BBF6; Mon, 16 Nov 2020 19:30:44 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DFEAF27BBF5 for ; Mon, 16 Nov 2020 19:30:43 +0000 (GMT) Received: from localhost ([::1]:49848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekD5-0005WE-0v for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:30:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejr9-0001x2-Rk for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejr9-0001Ey-59 for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejr9-0002sS-0X for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 1/8] guix: self: Add guile-semver as a depenedency. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555365410912 (code B ref 38408); Mon, 16 Nov 2020 19:08:02 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:34 +0000 Received: from localhost ([127.0.0.1]:57239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqg-0002pv-0x for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:34 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:60694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqd-0002pn-W6 for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:33 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdql0yWHz1qs3l; Mon, 16 Nov 2020 20:07:30 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdqk6VRJz1qqkD; Mon, 16 Nov 2020 20:07:30 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id MypQoOscKymf; Mon, 16 Nov 2020 20:07:30 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:30 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id B19DC60052; Mon, 16 Nov 2020 20:08:27 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:21 +0100 Message-Id: X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Martin Becze * guix/self.scm (compiled-guix): Add guile-semver as a depenedency. --- guix/self.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guix/self.scm b/guix/self.scm index bbfd2f1b95..1a3f748bea 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -53,6 +54,7 @@ ("guile-json" (ref '(gnu packages guile) 'guile-json-4)) ("guile-ssh" (ref '(gnu packages ssh) 'guile-ssh)) ("guile-git" (ref '(gnu packages guile) 'guile-git)) + ("guile-semver" (ref '(gnu packages guile-xyz) 'guile3.0-semver)) ("guile-sqlite3" (ref '(gnu packages guile) 'guile-sqlite3)) ("guile-zlib" (ref '(gnu packages guile) 'guile-zlib)) ("guile-lzlib" (ref '(gnu packages guile) 'guile-lzlib)) @@ -799,6 +801,9 @@ Info manual." (define guile-gcrypt (specification->package "guile-gcrypt")) + (define guile-semver + (specification->package "guile-semver")) + (define gnutls (specification->package "gnutls")) @@ -807,7 +812,8 @@ Info manual." (cons (list "x" package) (package-transitive-propagated-inputs package))) (list guile-gcrypt gnutls guile-git guile-json - guile-ssh guile-sqlite3 guile-zlib guile-lzlib)) + guile-ssh guile-sqlite3 guile-zlib guile-lzlib + guile-semver)) (((labels packages _ ...) ...) packages))) From patchwork Mon Nov 16 19:07:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25166 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3219427BBF6; Mon, 16 Nov 2020 19:46:46 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1EDE627BBF5 for ; Mon, 16 Nov 2020 19:46:42 +0000 (GMT) Received: from localhost ([::1]:60428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekSX-0005So-7n for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:46:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejr9-0001x1-RX for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejr9-0001Ez-I9 for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejr9-0002sa-Ch for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 2/8] import: utils: 'recursive-import' accepts an optional version parameter. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555366910953 (code B ref 38408); Mon, 16 Nov 2020 19:08:03 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:49 +0000 Received: from localhost ([127.0.0.1]:57242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejql-0002qE-8X for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:48 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:55248) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqi-0002q4-A7 for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:37 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdqq3fjVz1rwDW; Mon, 16 Nov 2020 20:07:35 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdqq3SCxz1qqkD; Mon, 16 Nov 2020 20:07:35 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id iRBaeLz4ogJF; Mon, 16 Nov 2020 20:07:33 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:33 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id D652360355; Mon, 16 Nov 2020 20:08:27 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:22 +0100 Message-Id: X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Martin Becze This adds a key VERSION to 'recursive-import' and moves the parameter REPO to a key. This also changes all the places that rely on 'recursive-import'. * guix/import/utils.scm (recursive-import): Add the VERSION key. Make REPO a key. (package->definition): Add optional 'append-version?'. * guix/scripts/import/crate.scm (guix-import-crate): Add the VERSION key. * guix/import/crate.scm (crate->guix-package): Add the VERSION key. (crate-recursive-import): Pass VERSION to recursive-import, remove now unnecessary code. * guix/import/cran.scm (cran->guix-package, cran-recursive-import): Change the REPO parameter to a key. * guix/import/elpa.scm (elpa->guix-package, elpa-recursive-import): Likewise. * guix/import/gem.scm (gem->guix-package, recursive-import): Likewise. * guix/import/opam.scm (opam-recurive-import): Likewise. * guix/import/pypi.scm (pypi-recursive-import): Likewise. * guix/import/stackage.scm (stackage-recursive-import): Likewise. * guix/scripts/import/cran.scm (guix-import-cran): Likewise. * guix/scripts/import/elpa.scm (guix-import-elpa): Likewise. * tests/elpa.scm (eval-test-with-elpa): Likewise. * tests/import-utils.scm (recursive-import): Likewise. Co-authored-by: Hartmut Goebel --- guix/import/cran.scm | 8 +++-- guix/import/crate.scm | 13 +++----- guix/import/elpa.scm | 6 ++-- guix/import/gem.scm | 6 ++-- guix/import/opam.scm | 8 ++--- guix/import/pypi.scm | 8 ++--- guix/import/stackage.scm | 5 +-- guix/import/utils.scm | 57 ++++++++++++++++++++++------------- guix/scripts/import/cran.scm | 5 +-- guix/scripts/import/crate.scm | 4 +-- guix/scripts/import/elpa.scm | 4 ++- tests/elpa.scm | 3 +- tests/import-utils.scm | 8 +++-- 13 files changed, 80 insertions(+), 55 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index a1275b4822..d8240a6b2f 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus ;;; Copyright © 2015, 2016, 2017, 2019, 2020 Ludovic Courtès ;;; Copyright © 2017 Mathieu Othacehe +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -568,7 +569,7 @@ from the alist META, which was derived from the R package's DESCRIPTION file." (define cran->guix-package (memoize - (lambda* (package-name #:optional (repo 'cran)) + (lambda* (package-name #:key (repo 'cran) version) "Fetch the metadata for PACKAGE-NAME from REPO and return the `package' s-expression corresponding to that package, or #f on failure." (let ((description (fetch-description repo package-name))) @@ -586,8 +587,9 @@ s-expression corresponding to that package, or #f on failure." (cran->guix-package package-name 'cran)) (else (values #f '())))))))) -(define* (cran-recursive-import package-name #:optional (repo 'cran)) - (recursive-import package-name repo +(define* (cran-recursive-import package-name #:key (repo 'cran)) + (recursive-import package-name + #:repo repo #:repo->guix-package cran->guix-package #:guix-name cran-guix-name)) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 8c2b76cab4..47bfc16105 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -187,7 +187,7 @@ and LICENSE." 'unknown-license!))) (string-split string (string->char-set " /")))) -(define* (crate->guix-package crate-name #:optional version) +(define* (crate->guix-package crate-name #:key version repo) "Fetch the metadata for CRATE-NAME from crates.io, and return the `package' s-expression corresponding to that package, or #f on failure. When VERSION is specified, attempt to fetch that version; otherwise fetch the @@ -233,13 +233,10 @@ latest version of CRATE-NAME." string->license)) (append cargo-inputs cargo-development-inputs))))) -(define* (crate-recursive-import crate-name #:optional version) - (recursive-import crate-name #f - #:repo->guix-package - (lambda (name repo) - (let ((version (and (string=? name crate-name) - version))) - (crate->guix-package name version))) +(define* (crate-recursive-import crate-name #:key version) + (recursive-import crate-name + #:repo->guix-package crate->guix-package + #:version version #:guix-name crate-name->package-name)) (define (guix-package->crate-name package) diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm index 871b918f88..c4e8e84aba 100644 --- a/guix/import/elpa.scm +++ b/guix/import/elpa.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2015, 2016, 2017, 2018, 2020 Ludovic Courtès ;;; Copyright © 2018 Oleg Pykhalov +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -245,7 +246,7 @@ type ''." (license ,license)) dependencies-names))) -(define* (elpa->guix-package name #:optional (repo 'gnu)) +(define* (elpa->guix-package name #:key (repo 'gnu) version) "Fetch the package NAME from REPO and produce a Guix package S-expression." (match (fetch-elpa-package name repo) (#f #f) @@ -299,7 +300,8 @@ type ''." (define elpa-guix-name (cut guix-name "emacs-" <>)) (define* (elpa-recursive-import package-name #:optional (repo 'gnu)) - (recursive-import package-name repo + (recursive-import package-name + #:repo repo #:repo->guix-package elpa->guix-package #:guix-name elpa-guix-name)) diff --git a/guix/import/gem.scm b/guix/import/gem.scm index 3fe240f36a..1f6f94532e 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2018 Oleg Pykhalov ;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -122,7 +123,7 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES." ((license) (license->symbol license)) (_ `(list ,@(map license->symbol licenses))))))) -(define* (gem->guix-package package-name #:optional (repo 'rubygems) version) +(define* (gem->guix-package package-name #:key (repo 'rubygems) version) "Fetch the metadata for PACKAGE-NAME from rubygems.org, and return the `package' s-expression corresponding to that package, or #f on failure." (let ((gem (rubygems-fetch package-name))) @@ -188,6 +189,7 @@ package on RubyGems." (latest latest-release))) (define* (gem-recursive-import package-name #:optional version) - (recursive-import package-name '() + (recursive-import package-name + #:repo '() #:repo->guix-package gem->guix-package #:guix-name ruby-package-name)) diff --git a/guix/import/opam.scm b/guix/import/opam.scm index 6d9eb0a092..867812124d 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Julien Lepiller +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -260,7 +261,7 @@ path to the repository." (substring version 1) version))))) -(define* (opam->guix-package name #:key (repository (get-opam-repository))) +(define* (opam->guix-package name #:key (repository (get-opam-repository)) version) "Import OPAM package NAME from REPOSITORY (a directory name) or, if REPOSITORY is #f, from the official OPAM repository. Return a 'package' sexp or #f on failure." @@ -322,9 +323,8 @@ or #f on failure." dependencies)))))))) (define (opam-recursive-import package-name) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) - (opam->guix-package name)) + (recursive-import package-name + #:repo->guix-package opam->guix-package #:guix-name ocaml-name->guix-name)) (define (guix-name->opam-name name) diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index 15116e349d..bf4dc50138 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Lars-Dominik Braun ;;; Copyright © 2020 Arun Isaac +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -471,7 +472,7 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE." (define pypi->guix-package (memoize - (lambda* (package-name) + (lambda* (package-name #:key repo version) "Fetch the metadata for PACKAGE-NAME from pypi.org, and return the `package' s-expression corresponding to that package, or #f on failure." (let* ((project (pypi-fetch package-name)) @@ -495,9 +496,8 @@ VERSION, SOURCE-URL, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE." (project-info-license info))))))))) (define (pypi-recursive-import package-name) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) - (pypi->guix-package name)) + (recursive-import package-name + #:repo->guix-package pypi->guix-package #:guix-name python->package-name)) (define (string->license str) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 93cf214127..0a60adffc8 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Federico Beffa ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -107,8 +108,8 @@ included in the Stackage LTS release." (leave-with-message "~a: Stackage package not found" package-name)))))) (define (stackage-recursive-import package-name . args) - (recursive-import package-name #f - #:repo->guix-package (lambda (name repo) + (recursive-import package-name + #:repo->guix-package (lambda* (name #:key repo version) (apply stackage->guix-package (cons name args))) #:guix-name hackage-name->package-name)) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 145515c489..895fbb11a8 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Oleg Pykhalov ;;; Copyright © 2019 Robert Vollmert ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -45,6 +46,7 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-71) #:export (factorize-uri flatten @@ -254,13 +256,15 @@ package definition." ((package-inputs ...) `((native-inputs (,'quasiquote ,package-inputs)))))) -(define (package->definition guix-package) +(define* (package->definition guix-package #:optional append-version?) (match guix-package - (('package ('name (? string? name)) _ ...) - `(define-public ,(string->symbol name) - ,guix-package)) - (('let anything ('package ('name (? string? name)) _ ...)) - `(define-public ,(string->symbol name) + ((or + ('package ('name name) ('version version) . rest) + ('let _ ('package ('name name) ('version version) . rest))) + + `(define-public ,(string->symbol (if append-version? + (string-append name "-" version) + version)) ,guix-package)))) (define (build-system-modules) @@ -409,32 +413,43 @@ obtain a node's uniquely identifying \"key\"." (cons head result) (set-insert (node-name head) visited)))))))) -(define* (recursive-import package-name repo - #:key repo->guix-package guix-name +(define* (recursive-import package-name + #:key repo->guix-package guix-name version repo #:allow-other-keys) "Return a list of package expressions for PACKAGE-NAME and all its dependencies, sorted in topological order. For each package, -call (REPO->GUIX-PACKAGE NAME REPO), which should return a package expression -and a list of dependencies; call (GUIX-NAME NAME) to obtain the Guix package -name corresponding to the upstream name." +call (REPO->GUIX-PACKAGE NAME :KEYS version repo), which should return a +package expression and a list of dependencies; call (GUIX-NAME NAME) to +obtain the Guix package name corresponding to the upstream name." (define-record-type - (make-node name package dependencies) + (make-node name version package dependencies) node? (name node-name) + (version node-version) (package node-package) (dependencies node-dependencies)) - (define (exists? name) - (not (null? (find-packages-by-name (guix-name name))))) + (define (exists? name version) + (not (null? (find-packages-by-name (guix-name name) version)))) - (define (lookup-node name) - (receive (package dependencies) (repo->guix-package name repo) - (make-node name package dependencies))) + (define (lookup-node name version) + (let* ((package dependencies (repo->guix-package name + #:version version + #:repo repo)) + (normalizied-deps (map (match-lambda + ((name version) (list name version)) + (name (list name #f))) dependencies))) + (make-node name version package normalizied-deps))) (map node-package - (topological-sort (list (lookup-node package-name)) + (topological-sort (list (lookup-node package-name version)) (lambda (node) - (map lookup-node - (remove exists? + (map (lambda (name-version) + (apply lookup-node name-version)) + (remove (lambda (name-version) + (apply exists? name-version)) (node-dependencies node)))) - node-name))) + (lambda (node) + (string-append + (node-name node) + (or (node-version node) "")))))) diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index d6f371ef3a..bc266ad9da 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2015, 2017, 2019 Ricardo Wurmus +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -98,10 +99,10 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) ;; Recursive import (map package->definition (cran-recursive-import package-name - (or (assoc-ref opts 'repo) 'cran))) + #:repo (or (assoc-ref opts 'repo) 'cran))) ;; Single import (let ((sexp (cran->guix-package package-name - (or (assoc-ref opts 'repo) 'cran)))) + #:repo (or (assoc-ref opts 'repo) 'cran)))) (unless sexp (leave (G_ "failed to download description for package '~a'~%") package-name)) diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index d834518c18..9c4286f8bd 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -100,8 +100,8 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) `(define-public ,(string->symbol name) ,pkg)) (_ #f)) - (crate-recursive-import name version)) - (let ((sexp (crate->guix-package name version))) + (crate-recursive-import name #:version version)) + (let ((sexp (crate->guix-package name #:version version))) (unless sexp (leave (G_ "failed to download meta-data for package '~a'~%") (if version diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm index d270d2b4bc..07ac07a3d5 100644 --- a/guix/scripts/import/elpa.scm +++ b/guix/scripts/import/elpa.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2018 Oleg Pykhalov +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -102,7 +103,8 @@ Import the latest package named PACKAGE-NAME from an ELPA repository.\n")) (_ #f)) (elpa-recursive-import package-name (or (assoc-ref opts 'repo) 'gnu))) - (let ((sexp (elpa->guix-package package-name (assoc-ref opts 'repo)))) + (let ((sexp (elpa->guix-package package-name + #:repo (assoc-ref opts 'repo)))) (unless sexp (leave (G_ "failed to download package '~a'~%") package-name)) sexp))) diff --git a/tests/elpa.scm b/tests/elpa.scm index b70539bda6..a008cf993c 100644 --- a/tests/elpa.scm +++ b/tests/elpa.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2020 Ludovic Courtès +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -51,7 +52,7 @@ (200 "This is the description.") (200 "fake tarball contents")) (parameterize ((current-http-proxy (%local-url))) - (match (elpa->guix-package pkg 'gnu/http) + (match (elpa->guix-package pkg #:repo 'gnu/http) (('package ('name "emacs-auctex") ('version "11.88.6") diff --git a/tests/import-utils.scm b/tests/import-utils.scm index 87dda3238f..2357ea5c40 100644 --- a/tests/import-utils.scm +++ b/tests/import-utils.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2017 Ricardo Wurmus ;;; Copyright © 2016 Ben Woodcroft +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -48,15 +49,16 @@ (package (name "foo") (inputs `(("bar" ,bar))))) - (recursive-import "foo" 'repo + (recursive-import "foo" + #:repo 'repo #:repo->guix-package (match-lambda* - (("foo" 'repo) + (("foo" #:version #f #:repo 'repo) (values '(package (name "foo") (inputs `(("bar" ,bar)))) '("bar"))) - (("bar" 'repo) + (("bar" #:version #f #:repo 'repo) (values '(package (name "bar")) '()))) From patchwork Mon Nov 16 19:07:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25160 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8A41527BBF6; Mon, 16 Nov 2020 19:27:22 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 173D727BBF5 for ; Mon, 16 Nov 2020 19:27:20 +0000 (GMT) Received: from localhost ([::1]:40188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kek9n-0001W4-7A for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:27:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xW-Ht for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejr9-0001FG-Ui for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejr9-0002sm-QG for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 3/8] import: crate: Use guile-semver to resolve module versions. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555367010963 (code B ref 38408); Mon, 16 Nov 2020 19:08:03 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:50 +0000 Received: from localhost ([127.0.0.1]:57248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqu-0002qc-Um for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:50 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:35585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqn-0002qH-CR for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:42 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdqw6mBWz1qs3x; Mon, 16 Nov 2020 20:07:40 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdqw6XlYz1qqkD; Mon, 16 Nov 2020 20:07:40 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id wOgynv-k9qHL; Mon, 16 Nov 2020 20:07:38 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:38 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id 16C44603C9; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:23 +0100 Message-Id: X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Martin Becze * guix/import/crate.scm: Add guile-semver as a soft dependency. (make-crate-sexp): Don't allow other keys. Add '#:skip-build?' to build system args. Pass a VERSION argument to 'cargo-inputs'. (crate->guix-package): Use guile-semver to resolve the correct module versions. Treat "build" dependencies as normal dependencies. (crate-name->package-name): Reuse the procedure 'guix-name' instead of duplicating its logic. * guix/import/utils.scm (package-names->package-inputs): Implement handling of (name version) pairs. * guix/scripts/import/crate.scm (guix-import-crate): Use crate-recursive-import instead of duplicate code. * tests/crate.scm (recursive-import): Change test packages versions to be distinguishable. Add version data to the test. Check created symbols, too. Co-authored-by: Hartmut Goebel --- guix/import/crate.scm | 91 +++++-- guix/import/utils.scm | 21 +- guix/scripts/import/crate.scm | 11 +- tests/crate.scm | 500 +++++++++++++++++++++------------- 4 files changed, 391 insertions(+), 232 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 47bfc16105..5498d1f0ff 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 David Craven ;;; Copyright © 2019, 2020 Ludovic Courtès -;;; Copyright © 2019 Martin Becze +;;; Copyright © 2019, 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +37,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-71) #:export (crate->guix-package guix-package->crate-name string->license @@ -85,10 +86,15 @@ crate-dependency? json->crate-dependency (id crate-dependency-id "crate_id") ;string - (kind crate-dependency-kind "kind" ;'normal | 'dev + (kind crate-dependency-kind "kind" ;'normal | 'dev | 'build string->symbol) (requirement crate-dependency-requirement "req")) ;string +(module-autoload! (current-module) + '(semver) '(string->semver semversemver-range semver-range-contains?)) + (define (lookup-crate name) "Look up NAME on https://crates.io and return the corresopnding record or #f if it was not found." @@ -142,16 +148,21 @@ record or #f if it was not found." `((arguments (,'quasiquote ,args)))))) (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inputs - home-page synopsis description license - #:allow-other-keys) + home-page synopsis description license) "Return the `package' s-expression for a rust package with the given NAME, VERSION, CARGO-INPUTS, CARGO-DEVELOPMENT-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE." + (define (format-inputs inputs) + (map + (match-lambda + ((name version) + (list (crate-name->package-name name) version))) + inputs)) + (let* ((port (http-fetch (crate-uri name version))) (guix-name (crate-name->package-name name)) - (cargo-inputs (map crate-name->package-name cargo-inputs)) - (cargo-development-inputs (map crate-name->package-name - cargo-development-inputs)) + (cargo-inputs (format-inputs cargo-inputs)) + (cargo-development-inputs (format-inputs cargo-development-inputs)) (pkg `(package (name ,guix-name) (version ,version) @@ -163,7 +174,8 @@ and LICENSE." (base32 ,(bytevector->nix-base32-string (port-sha256 port)))))) (build-system cargo-build-system) - ,@(maybe-arguments (append (maybe-cargo-inputs cargo-inputs) + ,@(maybe-arguments (append '(#:skip-build? #t) + (maybe-cargo-inputs cargo-inputs) (maybe-cargo-development-inputs cargo-development-inputs))) (home-page ,(match home-page @@ -176,7 +188,7 @@ and LICENSE." ((license) license) (_ `(list ,@license))))))) (close-port port) - pkg)) + (package->definition pkg #t))) (define (string->license string) (filter-map (lambda (license) @@ -190,11 +202,17 @@ and LICENSE." (define* (crate->guix-package crate-name #:key version repo) "Fetch the metadata for CRATE-NAME from crates.io, and return the `package' s-expression corresponding to that package, or #f on failure. -When VERSION is specified, attempt to fetch that version; otherwise fetch the -latest version of CRATE-NAME." +When VERSION is specified, convert it into a semver range and attempt to fetch +the latest version matching this semver range; otherwise fetch the latest +version of CRATE-NAME." + + (define (semver-range-contains-string? range version) + (semver-range-contains? (string->semver-range range) + (string->semver version))) (define (normal-dependency? dependency) - (eq? (crate-dependency-kind dependency) 'normal)) + (or (eq? (crate-dependency-kind dependency) 'build) + (eq? (crate-dependency-kind dependency) 'normal))) (define crate (lookup-crate crate-name)) @@ -204,22 +222,45 @@ latest version of CRATE-NAME." (or version (crate-latest-version crate)))) + ;; find the highest version of a crate that fulfills the semver + (define (find-crate-version crate range) + (let* ((semver-range (string->semver-range range)) + (versions + (sort + (filter (lambda (entry) + (semver-range-contains? semver-range (first entry))) + (map (lambda (ver) + (list (string->semver (crate-version-number ver)) + ver)) + (crate-versions crate))) + (match-lambda* (((semver _) ...) + (apply semverpackage-name name) - (string-append "rust-" (string-join (string-split name #\_) "-"))) + (guix-name "rust-" name)) ;;; diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 895fbb11a8..10eb030188 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -229,13 +229,20 @@ into a proper sentence and by using two spaces between sentences." cleaned 'pre ". " 'post))) (define* (package-names->package-inputs names #:optional (output #f)) - "Given a list of PACKAGE-NAMES, and an optional OUTPUT, tries to generate a -quoted list of inputs, as suitable to use in an 'inputs' field of a package -definition." - (map (lambda (input) - (cons* input (list 'unquote (string->symbol input)) - (or (and output (list output)) - '()))) + "Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an +optional OUTPUT, tries to generate a quoted list of inputs, as suitable to +use in an 'inputs' field of a package definition." + (define (make-input input version) + (cons* input (list 'unquote (string->symbol + (if version + (string-append input "-" version) + input))) + (or (and output (list output)) + '()))) + + (map (match-lambda + ((input version) (make-input input version)) + (input (make-input input #f))) names)) (define* (maybe-inputs package-names #:optional (output #f)) diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index 9c4286f8bd..33dae56561 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -2,7 +2,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 David Thompson ;;; Copyright © 2016 David Craven -;;; Copyright © 2019 Martin Becze +;;; Copyright © 2019, 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -95,19 +95,14 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (package-name->name+version spec)) (if (assoc-ref opts 'recursive) - (map (match-lambda - ((and ('package ('name name) . rest) pkg) - `(define-public ,(string->symbol name) - ,pkg)) - (_ #f)) - (crate-recursive-import name #:version version)) + (crate-recursive-import name #:version version) (let ((sexp (crate->guix-package name #:version version))) (unless sexp (leave (G_ "failed to download meta-data for package '~a'~%") (if version (string-append name "@" version) name))) - sexp))) + (list sexp)))) (() (leave (G_ "too few arguments~%"))) ((many ...) diff --git a/tests/crate.scm b/tests/crate.scm index 61a04f986b..4465e12767 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 David Thompson ;;; Copyright © 2016 David Craven ;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2020 Martin Becze ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,23 +29,67 @@ #:use-module (ice-9 match) #:use-module (srfi srfi-64)) + +;; crate versions and dependencies used here +;; foo-0.8.1 +;; foo-1.0.0 +;; foo-1.0.3 +;; leaf-alice 0.7.5 +;; +;; root-1.0.0 +;; root-1.0.4 +;; intermediate-a 1.0.42 +;; intermeidate-b ^1.0.0 +;; leaf-alice ^0.7 +;; leaf-bob ^3 +;; +;; intermediate-a-1.0.40 +;; intermediate-a-1.0.42 +;; intermediate-a-1.1.0-alpha.1 +;; intermediate-a 1.2.3 +;; leaf-alice 0.7.5 +;; leaf-bob ^3 +;; +;; intermediate-b-1.2.3 +;; leaf-bob 3.0.1 +;; +;; leaf-alice-0.7.3 +;; leaf-alice-0.7.5 +;; +;; leaf-bob-3.0.1 + + (define test-foo-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", + \"max_version\": \"1.0.3\", \"name\": \"foo\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], - \"categories\": [\"test\"] + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"foo\", + { \"id\": 234210, + \"num\": \"0.8.1\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/foo/0.8.1/dependencies\" + } + }, + { \"id\": 234212, \"num\": \"1.0.0\", \"license\": \"MIT OR Apache-2.0\", \"links\": { \"dependencies\": \"/api/v1/crates/foo/1.0.0/dependencies\" } + }, + { \"id\": 234214, + \"num\": \"1.0.3\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/foo/1.0.3/dependencies\" + } } ] } @@ -54,8 +99,9 @@ "{ \"dependencies\": [ { - \"crate_id\": \"bar\", - \"kind\": \"normal\" + \"crate_id\": \"leaf-alice\", + \"kind\": \"normal\", + \"req\": \"0.7.5\" } ] }") @@ -63,20 +109,27 @@ (define test-root-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", + \"max_version\": \"1.0.4\", \"name\": \"root\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], - \"categories\": [\"test\"] + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"foo\", + { \"id\": 234240, \"num\": \"1.0.0\", \"license\": \"MIT OR Apache-2.0\", \"links\": { \"dependencies\": \"/api/v1/crates/root/1.0.0/dependencies\" } + }, + { \"id\": 234242, + \"num\": \"1.0.4\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/root/1.0.4/dependencies\" + } } ] } @@ -86,92 +139,114 @@ "{ \"dependencies\": [ { - \"crate_id\": \"intermediate-1\", - \"kind\": \"normal\" + \"crate_id\": \"intermediate-a\", + \"kind\": \"normal\", + \"req\": \"1.0.42\" }, { - \"crate_id\": \"intermediate-2\", - \"kind\": \"normal\" + \"crate_id\": \"intermediate-b\", + \"kind\": \"normal\", + \"req\": \"^1.0.0\" } { \"crate_id\": \"leaf-alice\", - \"kind\": \"normal\" + \"kind\": \"normal\", + \"req\": \"^0.7\" }, { \"crate_id\": \"leaf-bob\", - \"kind\": \"normal\" + \"kind\": \"normal\", + \"req\": \"^3\" } ] }") -(define test-intermediate-1-crate +(define test-intermediate-a-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", - \"name\": \"intermediate-1\", + \"max_version\": \"1.1.0-alpha.1\", + \"name\": \"intermediate-a\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], - \"categories\": [\"test\"] + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"intermediate-1\", - \"num\": \"1.0.0\", + { \"id\": 234251, + \"num\": \"1.0.40\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.40/dependencies\" + } + }, + { \"id\": 234250, + \"num\": \"1.0.42\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.42/dependencies\" + } + }, + { \"id\": 234252, + \"num\": \"1.1.0-alpha.1\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/intermediate-1/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/intermediate-a/1.1.0-alpha.1/dependencies\" } } ] } }") -(define test-intermediate-1-dependencies +(define test-intermediate-a-dependencies "{ \"dependencies\": [ { - \"crate_id\": \"intermediate-2\", - \"kind\": \"normal\" + \"crate_id\": \"intermediate-b\", + \"kind\": \"normal\", + \"req\": \"1.2.3\" }, { \"crate_id\": \"leaf-alice\", - \"kind\": \"normal\" + \"kind\": \"normal\", + \"req\": \"0.7.5\" }, { \"crate_id\": \"leaf-bob\", - \"kind\": \"normal\" + \"kind\": \"normal\", + \"req\": \"^3\" } ] }") -(define test-intermediate-2-crate +(define test-intermediate-b-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", - \"name\": \"intermediate-2\", + \"max_version\": \"1.2.3\", + \"name\": \"intermediate-b\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], - \"categories\": [\"test\"] + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"intermediate-2\", - \"num\": \"1.0.0\", + { \"id\": 234260, + \"num\": \"1.2.3\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/intermediate-2/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/intermediate-b/1.2.3/dependencies\" } } ] } }") -(define test-intermediate-2-dependencies +(define test-intermediate-b-dependencies "{ \"dependencies\": [ { \"crate_id\": \"leaf-bob\", - \"kind\": \"normal\" + \"kind\": \"normal\", + \"req\": \"3.0.1\" } ] }") @@ -179,19 +254,26 @@ (define test-leaf-alice-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", + \"max_version\": \"0.7.5\", \"name\": \"leaf-alice\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], - \"categories\": [\"test\"] + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"leaf-alice\", - \"num\": \"1.0.0\", + { \"id\": 234270, + \"num\": \"0.7.3\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/leaf-alice/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.3/dependencies\" + } + }, + { \"id\": 234272, + \"num\": \"0.7.5\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/leaf-alice/0.7.5/dependencies\" } } ] @@ -206,19 +288,19 @@ (define test-leaf-bob-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", + \"max_version\": \"3.0.1\", \"name\": \"leaf-bob\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", - \"keywords\": [\"dummy\" \"test\"], + \"keywords\": [\"dummy\", \"test\"], \"categories\": [\"test\"] \"actual_versions\": [ - { \"id\": \"leaf-bob\", - \"num\": \"1.0.0\", + { \"id\": 234280, + \"num\": \"3.0.1\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/leaf-bob/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/leaf-bob/3.0.1/dependencies\" } } ] @@ -251,36 +333,51 @@ (match url ("https://crates.io/api/v1/crates/foo" (open-input-string test-foo-crate)) - ("https://crates.io/api/v1/crates/foo/1.0.0/download" + ("https://crates.io/api/v1/crates/foo/1.0.3/download" (set! test-source-hash - (bytevector->nix-base32-string - (sha256 (string->bytevector "empty file\n" "utf-8")))) + (bytevector->nix-base32-string + (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/foo/1.0.0/dependencies" + ("https://crates.io/api/v1/crates/foo/1.0.3/dependencies" (open-input-string test-foo-dependencies)) + ("https://crates.io/api/v1/crates/leaf-alice" + (open-input-string test-leaf-alice-crate)) + ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download" + (set! test-source-hash + (bytevector->nix-base32-string + (sha256 (string->bytevector "empty file\n" "utf-8")))) + (open-input-string "empty file\n")) + ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies" + (open-input-string test-leaf-alice-dependencies)) (_ (error "Unexpected URL: " url))))) - (match (crate->guix-package "foo") - (('package - ('name "rust-foo") - ('version "1.0.0") - ('source ('origin - ('method 'url-fetch) - ('uri ('crate-uri "foo" 'version)) - ('file-name ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('arguments - ('quasiquote - ('#:cargo-inputs (("rust-bar" ('unquote rust-bar)))))) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0))) - (string=? test-source-hash hash)) - (x - (pk 'fail x #f))))) + + (match (crate->guix-package "foo") + ((define-public 'rust-foo-1.0.3 + (package (name "rust-foo") + (version "1.0.3") + (source + (origin + (method url-fetch) + (uri (crate-uri "foo" 'version)) + (file-name (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system 'cargo-build-system) + (arguments + ('quasiquote + (#:skip-build? #t + #:cargo-inputs + (("rust-leaf-alice" + ('unquote 'rust-leaf-alice-0.7.5)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + + (string=? test-source-hash hash)) + (x + (pk 'fail x #f))))) (test-assert "cargo-recursive-import" ;; Replace network resources with sample data. @@ -289,151 +386,170 @@ (match url ("https://crates.io/api/v1/crates/root" (open-input-string test-root-crate)) - ("https://crates.io/api/v1/crates/root/1.0.0/download" + ("https://crates.io/api/v1/crates/root/1.0.4/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/root/1.0.0/dependencies" + ("https://crates.io/api/v1/crates/root/1.0.4/dependencies" (open-input-string test-root-dependencies)) - ("https://crates.io/api/v1/crates/intermediate-1" - (open-input-string test-intermediate-1-crate)) - ("https://crates.io/api/v1/crates/intermediate-1/1.0.0/download" + ("https://crates.io/api/v1/crates/intermediate-a" + (open-input-string test-intermediate-a-crate)) + ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/intermediate-1/1.0.0/dependencies" - (open-input-string test-intermediate-1-dependencies)) - ("https://crates.io/api/v1/crates/intermediate-2" - (open-input-string test-intermediate-2-crate)) - ("https://crates.io/api/v1/crates/intermediate-2/1.0.0/download" + ("https://crates.io/api/v1/crates/intermediate-a/1.0.42/dependencies" + (open-input-string test-intermediate-a-dependencies)) + ("https://crates.io/api/v1/crates/intermediate-b" + (open-input-string test-intermediate-b-crate)) + ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/intermediate-2/1.0.0/dependencies" - (open-input-string test-intermediate-2-dependencies)) + ("https://crates.io/api/v1/crates/intermediate-b/1.2.3/dependencies" + (open-input-string test-intermediate-b-dependencies)) ("https://crates.io/api/v1/crates/leaf-alice" (open-input-string test-leaf-alice-crate)) - ("https://crates.io/api/v1/crates/leaf-alice/1.0.0/download" + ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/leaf-alice/1.0.0/dependencies" + ("https://crates.io/api/v1/crates/leaf-alice/0.7.5/dependencies" (open-input-string test-leaf-alice-dependencies)) ("https://crates.io/api/v1/crates/leaf-bob" (open-input-string test-leaf-bob-crate)) - ("https://crates.io/api/v1/crates/leaf-bob/1.0.0/download" + ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/leaf-bob/1.0.0/dependencies" + ("https://crates.io/api/v1/crates/leaf-bob/3.0.1/dependencies" (open-input-string test-leaf-bob-dependencies)) (_ (error "Unexpected URL: " url))))) (match (crate-recursive-import "root") - ;; rust-intermediate-2 has no dependency on the rust-leaf-alice package, so this is a valid ordering - ((('package - ('name "rust-leaf-alice") - ('version (? string? ver)) - ('source - ('origin - ('method 'url-fetch) - ('uri ('crate-uri "leaf-alice" 'version)) - ('file-name - ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0))) - ('package - ('name "rust-leaf-bob") - ('version (? string? ver)) - ('source - ('origin - ('method 'url-fetch) - ('uri ('crate-uri "leaf-bob" 'version)) - ('file-name - ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0))) - ('package - ('name "rust-intermediate-2") - ('version (? string? ver)) - ('source - ('origin - ('method 'url-fetch) - ('uri ('crate-uri "intermediate-2" 'version)) - ('file-name - ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('arguments - ('quasiquote - ('#:cargo-inputs (("rust-leaf-bob" ('unquote rust-leaf-bob)))))) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0))) - ('package - ('name "rust-intermediate-1") - ('version (? string? ver)) - ('source - ('origin - ('method 'url-fetch) - ('uri ('crate-uri "intermediate-1" 'version)) - ('file-name - ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('arguments - ('quasiquote - ('#:cargo-inputs (("rust-intermediate-2" ('unquote rust-intermediate-2)) - ("rust-leaf-alice" ('unquote rust-leaf-alice)) - ("rust-leaf-bob" ('unquote rust-leaf-bob)))))) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0))) - ('package - ('name "rust-root") - ('version (? string? ver)) - ('source - ('origin - ('method 'url-fetch) - ('uri ('crate-uri "root" 'version)) - ('file-name - ('string-append 'name "-" 'version ".tar.gz")) - ('sha256 - ('base32 - (? string? hash))))) - ('build-system 'cargo-build-system) - ('arguments - ('quasiquote - ('#:cargo-inputs (("rust-intermediate-1" ('unquote rust-intermediate-1)) - ("rust-intermediate-2" ('unquote rust-intermediate-2)) - ("rust-leaf-alice" ('unquote rust-leaf-alice)) - ("rust-leaf-bob" ('unquote rust-leaf-bob)))))) - ('home-page "http://example.com") - ('synopsis "summary") - ('description "summary") - ('license ('list 'license:expat 'license:asl2.0)))) + ;; rust-intermediate-b has no dependency on the rust-leaf-alice + ;; package, so this is a valid ordering + (((define-public 'rust-leaf-alice-0.7.5 + (package + (name "rust-leaf-alice") + (version "0.7.5") + (source + (origin + (method url-fetch) + (uri (crate-uri "leaf-alice" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments ('quasiquote (#:skip-build? #t))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + (define-public 'rust-leaf-bob-3.0.1 + (package + (name "rust-leaf-bob") + (version "3.0.1") + (source + (origin + (method url-fetch) + (uri (crate-uri "leaf-bob" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments ('quasiquote (#:skip-build? #t))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + (define-public 'rust-intermediate-b-1.2.3 + (package + (name "rust-intermediate-b") + (version "1.2.3") + (source + (origin + (method url-fetch) + (uri (crate-uri "intermediate-b" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments + ('quasiquote (#:skip-build? #t + #:cargo-inputs + (("rust-leaf-bob" + ('unquote 'rust-leaf-bob-3.0.1)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + (define-public 'rust-intermediate-a-1.0.42 + (package + (name "rust-intermediate-a") + (version "1.0.42") + (source + (origin + (method url-fetch) + (uri (crate-uri "intermediate-a" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments + ('quasiquote (#:skip-build? #t + #:cargo-inputs + (("rust-intermediate-b" + ('unquote 'rust-intermediate-b-1.2.3)) + ("rust-leaf-alice" + ('unquote 'rust-leaf-alice-0.7.5)) + ("rust-leaf-bob" + ('unquote 'rust-leaf-bob-3.0.1)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + (define-public 'rust-root-1.0.4 + (package + (name "rust-root") + (version "1.0.4") + (source + (origin + (method url-fetch) + (uri (crate-uri "root" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments + ('quasiquote (#:skip-build? #t + #:cargo-inputs + (("rust-intermediate-a" + ('unquote 'rust-intermediate-a-1.0.42)) + ("rust-intermediate-b" + ('unquote 'rust-intermediate-b-1.2.3)) + ("rust-leaf-alice" + ('unquote 'rust-leaf-alice-0.7.5)) + ("rust-leaf-bob" + ('unquote 'rust-leaf-bob-3.0.1)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0))))) #t) (x (pk 'fail x #f))))) From patchwork Mon Nov 16 19:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25167 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8A43E27BBF6; Mon, 16 Nov 2020 19:46:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 20E0127BBF5 for ; Mon, 16 Nov 2020 19:46:49 +0000 (GMT) Received: from localhost ([::1]:60876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekSe-0005eG-Ag for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:46:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xY-HL for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrA-0001FL-Av for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrA-0002st-6U for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 4/8] import: crate: Memorize crate->guix-package. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555367010969 (code B ref 38408); Mon, 16 Nov 2020 19:08:04 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:50 +0000 Received: from localhost ([127.0.0.1]:57250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqw-0002qm-5m for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:50 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:41996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqr-0002qS-VG for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:46 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdr13qxhz1rwDW; Mon, 16 Nov 2020 20:07:45 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdr13Yn7z1qqkD; Mon, 16 Nov 2020 20:07:45 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id WlBhByZuV2Kr; Mon, 16 Nov 2020 20:07:43 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:43 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id 4A98D604C7; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:24 +0100 Message-Id: <31b17421ebdbd8b2e8037b1163a7c90835dea7e6.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Martin Becze This adds memorization to procedures that involve network lookups. 'lookup-crate*' is used on every dependency of a package to get its version list. It is also used to lookup a package's metadata. 'crate-recursive-import' is also memorized since creating the same package twice will trigger a lookup on its dependencies. * guix/import/crate.scm (lookup-crate*): New procedure. (crate->guix-package): Memorize package metadata lookups. (crate-recursive-import): Memorize package creation. --- guix/import/crate.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 5498d1f0ff..c830449555 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -27,6 +27,7 @@ #:use-module (guix import json) #:use-module (guix import utils) #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix memoization) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix upstream) @@ -110,6 +111,8 @@ record or #f if it was not found." (json->crate `(,@alist ("actual_versions" . ,versions)))))))) +(define lookup-crate* (memoize lookup-crate)) + (define (crate-version-dependencies version) "Return the list of records of VERSION, a ." @@ -215,7 +218,7 @@ version of CRATE-NAME." (eq? (crate-dependency-kind dependency) 'normal))) (define crate - (lookup-crate crate-name)) + (lookup-crate* crate-name)) (define version-number (and crate @@ -247,7 +250,7 @@ version of CRATE-NAME." (define (sort-map-dependencies deps) (sort (map (lambda (dep) (let* ((name (crate-dependency-id dep)) - (crate (lookup-crate name)) + (crate (lookup-crate* name)) (req (crate-dependency-requirement dep)) (ver (find-crate-version crate req))) (list name @@ -276,7 +279,7 @@ version of CRATE-NAME." (define* (crate-recursive-import crate-name #:key version) (recursive-import crate-name - #:repo->guix-package crate->guix-package + #:repo->guix-package (memoize crate->guix-package) #:version version #:guix-name crate-name->package-name)) From patchwork Mon Nov 16 19:07:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25164 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DC27D27BBF6; Mon, 16 Nov 2020 19:31:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id ECF0327BBF5 for ; Mon, 16 Nov 2020 19:31:09 +0000 (GMT) Received: from localhost ([::1]:50634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekDV-0005yj-33 for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:31:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xa-IE for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrA-0001FM-OV for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrA-0002t1-Jw for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 5/8] import: crate: Parameterized importing of dev dependencies. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555367310997 (code B ref 38408); Mon, 16 Nov 2020 19:08:04 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:53 +0000 Received: from localhost ([127.0.0.1]:57255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqy-0002rD-Oa for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:53 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:53236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqw-0002qy-US for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:51 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdr63hRBz1qs3l; Mon, 16 Nov 2020 20:07:50 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdr63SWZz1qqkX; Mon, 16 Nov 2020 20:07:50 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 4BiOvC2Mfjtm; Mon, 16 Nov 2020 20:07:49 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:49 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id 7CD86604CB; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:25 +0100 Message-Id: <9f232ed0dad2b1e41c821f5c446ea2a323d6feae.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: Martin Becze The recursive crate importer will now include development dependencies only for the top level package, but not for any of the recursively imported packages. Also #:skip-build will be false for the top-most package. * guix/import/crate.scm (make-crate-sexp): Add the key BUILD?. (crate->guix-package): Add the key INCLUDE-DEV-DEPS?. (crate-recursive-import): Likewise. * guix/scripts/import/crate.scm (guix-import-crate): Likewise. * tests/crate.scm (cargo-recursive-import): Likewise. --- guix/import/crate.scm | 25 ++++++++++++++++++------- guix/scripts/import/crate.scm | 2 +- tests/crate.scm | 3 +-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index c830449555..9704b3087b 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -151,7 +151,7 @@ record or #f if it was not found." `((arguments (,'quasiquote ,args)))))) (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inputs - home-page synopsis description license) + home-page synopsis description license build?) "Return the `package' s-expression for a rust package with the given NAME, VERSION, CARGO-INPUTS, CARGO-DEVELOPMENT-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE." @@ -177,7 +177,9 @@ and LICENSE." (base32 ,(bytevector->nix-base32-string (port-sha256 port)))))) (build-system cargo-build-system) - ,@(maybe-arguments (append '(#:skip-build? #t) + ,@(maybe-arguments (append (if build? + '() + '(#:skip-build? #t)) (maybe-cargo-inputs cargo-inputs) (maybe-cargo-development-inputs cargo-development-inputs))) @@ -202,12 +204,13 @@ and LICENSE." 'unknown-license!))) (string-split string (string->char-set " /")))) -(define* (crate->guix-package crate-name #:key version repo) +(define* (crate->guix-package crate-name #:key version include-dev-deps? repo) "Fetch the metadata for CRATE-NAME from crates.io, and return the `package' s-expression corresponding to that package, or #f on failure. When VERSION is specified, convert it into a semver range and attempt to fetch the latest version matching this semver range; otherwise fetch the latest -version of CRATE-NAME." +version of CRATE-NAME. If INCLUDE-DEV-DEPS is true then this will also +look up the development dependencs for the given crate." (define (semver-range-contains-string? range version) (semver-range-contains? (string->semver-range range) @@ -263,9 +266,12 @@ version of CRATE-NAME." (let* ((dependencies (crate-version-dependencies version*)) (dep-crates dev-dep-crates (partition normal-dependency? dependencies)) (cargo-inputs (sort-map-dependencies dep-crates)) - (cargo-development-inputs '())) + (cargo-development-inputs (if include-dev-deps? + (sort-map-dependencies dev-dep-crates) + '()))) (values - (make-crate-sexp #:name crate-name + (make-crate-sexp #:build? include-dev-deps? + #:name crate-name #:version (crate-version-number version*) #:cargo-inputs cargo-inputs #:cargo-development-inputs cargo-development-inputs @@ -279,7 +285,12 @@ version of CRATE-NAME." (define* (crate-recursive-import crate-name #:key version) (recursive-import crate-name - #:repo->guix-package (memoize crate->guix-package) + #:repo->guix-package (lambda* params + ;; download development dependencies only for the top level package + (let ((include-dev-deps? (equal? (car params) crate-name)) + (crate->guix-package* (memoize crate->guix-package))) + (apply crate->guix-package* + (append params `(#:include-dev-deps? ,include-dev-deps?))))) #:version version #:guix-name crate-name->package-name)) diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index 33dae56561..9252c52dfa 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -96,7 +96,7 @@ Import and convert the crate.io package for PACKAGE-NAME.\n")) (if (assoc-ref opts 'recursive) (crate-recursive-import name #:version version) - (let ((sexp (crate->guix-package name #:version version))) + (let ((sexp (crate->guix-package name #:version version #:include-dev-deps? #t))) (unless sexp (leave (G_ "failed to download meta-data for package '~a'~%") (if version diff --git a/tests/crate.scm b/tests/crate.scm index 4465e12767..b6cd577552 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -536,8 +536,7 @@ (? string? hash))))) (build-system cargo-build-system) (arguments - ('quasiquote (#:skip-build? #t - #:cargo-inputs + ('quasiquote (#:cargo-inputs (("rust-intermediate-a" ('unquote 'rust-intermediate-a-1.0.42)) ("rust-intermediate-b" From patchwork Mon Nov 16 19:07:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25162 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F3C5B27BBF6; Mon, 16 Nov 2020 19:30:41 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AE8CE27BBF5 for ; Mon, 16 Nov 2020 19:30:40 +0000 (GMT) Received: from localhost ([::1]:49566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekD1-0005P9-QW for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:30:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xb-HQ for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrB-0001FN-6X for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrB-0002t9-18 for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 6/8] import: utils: Trim patch version from names. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555367611013 (code B ref 38408); Mon, 16 Nov 2020 19:08:04 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:56 +0000 Received: from localhost ([127.0.0.1]:57258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejr2-0002rY-5d for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:56 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:35167) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejr0-0002rR-Vy for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:55 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdrB3z4dz1qs3l for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:54 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdrB3tcZz1rYDf for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:54 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id A4y7C3GtLgX4 for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:53 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:53 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id B044C604D4; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:26 +0100 Message-Id: <80ceca7e7d470e9f1e59edc219c80bbfd9b9a4d0.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This remove the patch version from generated package names. For example 'rust-my-crate-1.1.2' now becomes 'rust-my-crate-1.1'. * guix/import/utils.scm (package->definition): Trim patch version from generated package names. * tests/crate.scm: (cargo>guix-package, cargo-recursive-import): Likewise. --- guix/import/crate.scm | 3 ++- guix/import/utils.scm | 7 ++++--- tests/crate.scm | 30 +++++++++++++++--------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 9704b3087b..20efa131d5 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -159,7 +159,8 @@ and LICENSE." (map (match-lambda ((name version) - (list (crate-name->package-name name) version))) + (list (crate-name->package-name name) + (version-major+minor version)))) inputs)) (let* ((port (http-fetch (crate-uri name version))) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 10eb030188..b74393e617 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -269,9 +269,10 @@ package definition." ('package ('name name) ('version version) . rest) ('let _ ('package ('name name) ('version version) . rest))) - `(define-public ,(string->symbol (if append-version? - (string-append name "-" version) - version)) + `(define-public ,(string->symbol + (if append-version? + (string-append name "-" (version-major+minor version)) + version)) ,guix-package)))) (define (build-system-modules) diff --git a/tests/crate.scm b/tests/crate.scm index b6cd577552..3fbf6762c5 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -352,7 +352,7 @@ (_ (error "Unexpected URL: " url))))) (match (crate->guix-package "foo") - ((define-public 'rust-foo-1.0.3 + ((define-public 'rust-foo-1.0 (package (name "rust-foo") (version "1.0.3") (source @@ -369,7 +369,7 @@ (#:skip-build? #t #:cargo-inputs (("rust-leaf-alice" - ('unquote 'rust-leaf-alice-0.7.5)))))) + ('unquote 'rust-leaf-alice-0.7)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") @@ -433,7 +433,7 @@ (match (crate-recursive-import "root") ;; rust-intermediate-b has no dependency on the rust-leaf-alice ;; package, so this is a valid ordering - (((define-public 'rust-leaf-alice-0.7.5 + (((define-public 'rust-leaf-alice-0.7 (package (name "rust-leaf-alice") (version "0.7.5") @@ -452,7 +452,7 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-leaf-bob-3.0.1 + (define-public 'rust-leaf-bob-3.0 (package (name "rust-leaf-bob") (version "3.0.1") @@ -471,7 +471,7 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-intermediate-b-1.2.3 + (define-public 'rust-intermediate-b-1.2 (package (name "rust-intermediate-b") (version "1.2.3") @@ -489,12 +489,12 @@ ('quasiquote (#:skip-build? #t #:cargo-inputs (("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0.1)))))) + ('unquote 'rust-leaf-bob-3.0)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-intermediate-a-1.0.42 + (define-public 'rust-intermediate-a-1.0 (package (name "rust-intermediate-a") (version "1.0.42") @@ -512,16 +512,16 @@ ('quasiquote (#:skip-build? #t #:cargo-inputs (("rust-intermediate-b" - ('unquote 'rust-intermediate-b-1.2.3)) + ('unquote 'rust-intermediate-b-1.2)) ("rust-leaf-alice" - ('unquote 'rust-leaf-alice-0.7.5)) + ('unquote 'rust-leaf-alice-0.7)) ("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0.1)))))) + ('unquote 'rust-leaf-bob-3.0)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-root-1.0.4 + (define-public 'rust-root-1.0 (package (name "rust-root") (version "1.0.4") @@ -538,13 +538,13 @@ (arguments ('quasiquote (#:cargo-inputs (("rust-intermediate-a" - ('unquote 'rust-intermediate-a-1.0.42)) + ('unquote 'rust-intermediate-a-1.0)) ("rust-intermediate-b" - ('unquote 'rust-intermediate-b-1.2.3)) + ('unquote 'rust-intermediate-b-1.2)) ("rust-leaf-alice" - ('unquote 'rust-leaf-alice-0.7.5)) + ('unquote 'rust-leaf-alice-0.7)) ("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0.1)))))) + ('unquote 'rust-leaf-bob-3.0)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") From patchwork Mon Nov 16 19:07:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25165 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 78B3E27BBF6; Mon, 16 Nov 2020 19:31:46 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A593527BBF5 for ; Mon, 16 Nov 2020 19:31:45 +0000 (GMT) Received: from localhost ([::1]:51430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekE4-0006Nd-NB for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:31:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xl-Il for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrB-0001FZ-L9 for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrB-0002tH-Gi for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 7/8] import: crate: Trim version for names after left-most non-zero part. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555368011030 (code B ref 38408); Mon, 16 Nov 2020 19:08:05 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:08:00 +0000 Received: from localhost ([127.0.0.1]:57261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejr6-0002rp-G4 for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:08:00 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:57527) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejr4-0002rh-Hb for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:59 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdrG0rDTz1qs3l for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdrG0lwGz1qqkX for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:58 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id SVQJn9IQWF2K for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:56 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for <38408@debbugs.gnu.org>; Mon, 16 Nov 2020 20:07:56 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id D34E4604D9; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:27 +0100 Message-Id: <2e2f414b859139f6f41d7106b3fbcd6ae5d17649.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This complies to how versions are matched for caret requirements in crates: An update is allowed if the new version number does not modify the left-most non-zero digit in the major, minor, patch grouping. * guix/import/crate.scm (version->semver-prefix): New function. (make-crate-sexp)[format-inputs]: Use it. (make-crate-sexp): Use it to pass shorter version to package->definition. * guix/import/utils.scm (package->definition): Change optional parameter APPEND-VERSION? into APPEND-VERSION?/STRING. If it is a string, append its value to name. * tests/crate.scm: Adjust tests accordingly. --- guix/import/crate.scm | 10 ++++++++-- guix/import/utils.scm | 13 +++++++++---- tests/crate.scm | 25 ++++++++++++------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 20efa131d5..b133529ba7 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -150,6 +150,12 @@ record or #f if it was not found." ((args ...) `((arguments (,'quasiquote ,args)))))) +(define (version->semver-prefix version) + "Return the version up to and including the first non-zero part" + (first + (map match:substring + (list-matches "^(0+\\.){,2}[0-9]+" version)))) + (define* (make-crate-sexp #:key name version cargo-inputs cargo-development-inputs home-page synopsis description license build?) "Return the `package' s-expression for a rust package with the given NAME, @@ -160,7 +166,7 @@ and LICENSE." (match-lambda ((name version) (list (crate-name->package-name name) - (version-major+minor version)))) + (version->semver-prefix version)))) inputs)) (let* ((port (http-fetch (crate-uri name version))) @@ -194,7 +200,7 @@ and LICENSE." ((license) license) (_ `(list ,@license))))))) (close-port port) - (package->definition pkg #t))) + (package->definition pkg (version->semver-prefix version)))) (define (string->license string) (filter-map (lambda (license) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index b74393e617..7de95349cd 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -263,16 +263,21 @@ package definition." ((package-inputs ...) `((native-inputs (,'quasiquote ,package-inputs)))))) -(define* (package->definition guix-package #:optional append-version?) +(define* (package->definition guix-package #:optional append-version?/string) + "If APPEND-VERSION?/STRING is #t, append the package's major+minor +version. If APPEND-VERSION?/string is a string, append this string." (match guix-package ((or ('package ('name name) ('version version) . rest) ('let _ ('package ('name name) ('version version) . rest))) `(define-public ,(string->symbol - (if append-version? - (string-append name "-" (version-major+minor version)) - version)) + (cond + ((string? append-version?/string) + (string-append name "-" append-version?/string)) + ((= append-version?/string #t) + (string-append name "-" (version-major+minor version))) + ((#t) version))) ,guix-package)))) (define (build-system-modules) diff --git a/tests/crate.scm b/tests/crate.scm index 3fbf6762c5..1506daeadd 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -352,7 +352,7 @@ (_ (error "Unexpected URL: " url))))) (match (crate->guix-package "foo") - ((define-public 'rust-foo-1.0 + ((define-public 'rust-foo-1 (package (name "rust-foo") (version "1.0.3") (source @@ -368,8 +368,7 @@ ('quasiquote (#:skip-build? #t #:cargo-inputs - (("rust-leaf-alice" - ('unquote 'rust-leaf-alice-0.7)))))) + (("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") @@ -452,7 +451,7 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-leaf-bob-3.0 + (define-public 'rust-leaf-bob-3 (package (name "rust-leaf-bob") (version "3.0.1") @@ -471,7 +470,7 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-intermediate-b-1.2 + (define-public 'rust-intermediate-b-1 (package (name "rust-intermediate-b") (version "1.2.3") @@ -489,12 +488,12 @@ ('quasiquote (#:skip-build? #t #:cargo-inputs (("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0)))))) + ('unquote rust-leaf-bob-3)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-intermediate-a-1.0 + (define-public 'rust-intermediate-a-1 (package (name "rust-intermediate-a") (version "1.0.42") @@ -512,16 +511,16 @@ ('quasiquote (#:skip-build? #t #:cargo-inputs (("rust-intermediate-b" - ('unquote 'rust-intermediate-b-1.2)) + ('unquote rust-intermediate-b-1)) ("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7)) ("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0)))))) + ('unquote rust-leaf-bob-3)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public 'rust-root-1.0 + (define-public 'rust-root-1 (package (name "rust-root") (version "1.0.4") @@ -538,13 +537,13 @@ (arguments ('quasiquote (#:cargo-inputs (("rust-intermediate-a" - ('unquote 'rust-intermediate-a-1.0)) + ('unquote rust-intermediate-a-1)) ("rust-intermediate-b" - ('unquote 'rust-intermediate-b-1.2)) + ('unquote rust-intermediate-b-1)) ("rust-leaf-alice" ('unquote 'rust-leaf-alice-0.7)) ("rust-leaf-bob" - ('unquote 'rust-leaf-bob-3.0)))))) + ('unquote rust-leaf-bob-3)))))) (home-page "http://example.com") (synopsis "summary") (description "summary") From patchwork Mon Nov 16 19:07:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25161 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6089B27BBF6; Mon, 16 Nov 2020 19:30:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6EDF927BBF5 for ; Mon, 16 Nov 2020 19:30:13 +0000 (GMT) Received: from localhost ([::1]:48780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekCa-00053G-GC for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:30:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xm-Hd for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrC-0001GE-Fj for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrC-0002tb-AI for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:06 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 8/8] import: crate: Use existing package satisfying semver requirement. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org X-Debbugs-Original-To: 38408@debbugs.gnu.org, guix-patches@gnu.org Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555368511120 (code B ref 38408); Mon, 16 Nov 2020 19:08:06 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:08:05 +0000 Received: from localhost ([127.0.0.1]:57272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejrA-0002t8-Se for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:40235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejr9-0002sQ-1r for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:08:03 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdrL3d8wz1qs3l; Mon, 16 Nov 2020 20:08:02 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdrL3M4Xz1qqkX; Mon, 16 Nov 2020 20:08:02 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id NPa1t-ZMq-AK; Mon, 16 Nov 2020 20:08:00 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:08:00 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id F189060505; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:28 +0100 Message-Id: <7a551f3ffbd32779fdc46f0e39198ba55c2cefbe.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches If a package satisfying the dependency's semver requirement already exists, use it. Prior to this change the highest version matching the semver requirement was used (and imported in case it was not defined as package already). When resolving a dependency (now done in `sort-map-dependencies`), first search for a package matching the semver requirement and only if this fails reach out for a crate. * guix/import/crate.scm (crate->guix-package)[find-package-version]: New function. [dependency-name+version]: New function. [sort-map-dependencies]: Use it instead of lambda function. * tests/crate.scm (test-doctool-crate, test-doctool-dependencies): New variables. ("self-test …", "cargo-recursive-import-hoors-existing-packages"): New tests. --- guix/import/crate.scm | 37 ++++++++++++++----- tests/crate.scm | 83 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index b133529ba7..3bc261b04e 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -32,6 +32,7 @@ #:use-module (guix packages) #:use-module (guix upstream) #:use-module (guix utils) + #:use-module (gnu packages) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (json) @@ -92,7 +93,7 @@ (requirement crate-dependency-requirement "req")) ;string (module-autoload! (current-module) - '(semver) '(string->semver semversemver semver->string semversemver-range semver-range-contains?)) @@ -235,6 +236,21 @@ look up the development dependencs for the given crate." (or version (crate-latest-version crate)))) + ;; find the highest existing package that fulfills the semver + (define (find-package-version name range) + (let* ((semver-range (string->semver-range range)) + (versions + (sort + (filter (lambda (version) + (semver-range-contains? semver-range version)) + (map (lambda (pkg) + (string->semver (package-version pkg))) + (find-packages-by-name + (crate-name->package-name name)))) + semverstring (last versions))))) + ;; find the highest version of a crate that fulfills the semver (define (find-crate-version crate range) (let* ((semver-range (string->semver-range range)) @@ -251,6 +267,17 @@ look up the development dependencs for the given crate." (and (not (null-list? versions)) (second (last versions))))) + (define (dependency-name+version dep) + (let* ((name (crate-dependency-id dep)) + (req (crate-dependency-requirement dep)) + (existing-version (find-package-version name req))) + (if existing-version + (list name existing-version) + (let* ((crate (lookup-crate* name)) + (ver (find-crate-version crate req))) + (list name + (crate-version-number ver)))))) + (define version* (and crate (find-crate-version crate version-number))) @@ -258,13 +285,7 @@ look up the development dependencs for the given crate." ;; sort and map the dependencies to a list containing ;; pairs of (name version) (define (sort-map-dependencies deps) - (sort (map (lambda (dep) - (let* ((name (crate-dependency-id dep)) - (crate (lookup-crate* name)) - (req (crate-dependency-requirement dep)) - (ver (find-crate-version crate req))) - (list name - (crate-version-number ver)))) + (sort (map dependency-name+version deps) (match-lambda* (((name _) ...) (apply string-cilicense "MIT/Apache-2.0")) + + +(define test-doctool-crate + "{ + \"crate\": { + \"max_version\": \"2.2.2\", + \"name\": \"leaf-bob\", + \"description\": \"summary\", + \"homepage\": \"http://example.com\", + \"repository\": \"http://example.com\", + \"keywords\": [\"dummy\", \"test\"], + \"categories\": [\"test\"] + \"actual_versions\": [ + { \"id\": 234280, + \"num\": \"2.2.2\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/doctool/2.2.2/dependencies\" + } + } + ] + } +}") + +;; FIXME: This test depends on some existing packages +(define test-doctool-dependencies + "{ + \"dependencies\": [ + { + \"crate_id\": \"docopt\", + \"kind\": \"normal\", + \"req\": \"^0.8.1\" + } + ] +}") + + +(test-assert "self-test: rust-docopt 0.8.x is gone, please adjust the test case" + (not (null? (find-packages-by-name "rust-docopt" "0.8")))) + +(test-assert "cargo-recursive-import-hoors-existing-packages" + (mock ((guix http-client) http-fetch + (lambda (url . rest) + (match url + ("https://crates.io/api/v1/crates/doctool" + (open-input-string test-doctool-crate)) + ("https://crates.io/api/v1/crates/doctool/2.2.2/download" + (set! test-source-hash + (bytevector->nix-base32-string + (sha256 (string->bytevector "empty file\n" "utf-8")))) + (open-input-string "empty file\n")) + ("https://crates.io/api/v1/crates/doctool/2.2.2/dependencies" + (open-input-string test-doctool-dependencies)) + (_ (error "Unexpected URL: " url))))) + (match (crate-recursive-import "doctool") + (((define-public 'rust-doctool-2 + (package + (name "rust-doctool") + (version "2.2.2") + (source + (origin + (method url-fetch) + (uri (crate-uri "doctool" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments + ('quasiquote (#:cargo-inputs + (("rust-docopt" + ('unquote 'rust-docopt-0.8)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0))))) + #t) + (x + (pk 'fail x #f))))) + (test-end "crate")