From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:55666) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icxP1-00039m-HJ for guix-patches@gnu.org; Thu, 05 Dec 2019 15:07:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icxP0-0007IO-7n for guix-patches@gnu.org; Thu, 05 Dec 2019 15:07:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icxOz-0007Fk-3j for guix-patches@gnu.org; Thu, 05 Dec 2019 15:07:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icxOy-0002ny-Ti for guix-patches@gnu.org; Thu, 05 Dec 2019 15:07:04 -0500 Subject: [bug#38408] [PATCH v2 5/5] guix: crate: Depublicated build and normal dependencies Resent-Message-ID: From: Martin Becze Date: Thu, 5 Dec 2019 15:05:35 -0500 Message-Id: <8ffe3fa2e5d612802069f2b214b03a66df05780b.1575575779.git.mjbecze@riseup.net> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 38408@debbugs.gnu.org Cc: Martin Becze * guix/import/crate.scm: (crate-version-dependencies): dedup deps --- guix/import/crate.scm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 5683369b7a..f3c36ba516 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -109,14 +109,26 @@ record or #f if it was not found." "Return the list of records of VERSION, a ." (let* ((path (assoc-ref (crate-version-links version) "dependencies")) - (url (string-append (%crate-base-url) path))) - (match (assoc-ref (or (json-fetch url) '()) "dependencies") - ((? vector? vector) - (filter (lambda (dep) - (not (eq? (crate-dependency-kind dep) 'dev))) - (map json->crate-dependency (vector->list vector)))) - (_ - '())))) + (url (string-append (%crate-base-url) path)) + (deps-list (match (assoc-ref (or (json-fetch url) '()) "dependencies") + ((? vector? vector) (vector->list vector)) + (_ + '()))) + ;; turn the raw list into 's and remove dev depenedencies + (deps (filter-map (lambda (json) + (let ((dep (json->crate-dependency json))) + (if (eq? (crate-dependency-kind dep) 'dev) + #f + dep))) + deps-list)) + ;; split normal and build dependencies + (deps-normal deps-build (partition (lambda (dep) + (eq? (crate-dependency-kind dep) 'normal)) + deps))) + ;;remove duplicate normal and build dependencies + (lset-union (lambda (a b) + (string= (crate-dependency-id a) (crate-dependency-id a))) + deps-normal deps-build))) ;;; -- 2.24.0