From patchwork Wed Nov 30 16:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 44985 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 BF28A27BBE9; Wed, 30 Nov 2022 16:59:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2AF3227BBEB for ; Wed, 30 Nov 2022 16:59:44 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0QQP-0003Dg-9S; Wed, 30 Nov 2022 11:59:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0QQN-0003CI-21 for guix-patches@gnu.org; Wed, 30 Nov 2022 11:59:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0QQM-0004CU-P0 for guix-patches@gnu.org; Wed, 30 Nov 2022 11:59:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0QFd-00076p-S8 for guix-patches@gnu.org; Wed, 30 Nov 2022 11:48:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#58623] [PATCH v2 0/6] import/cran: Parameterize for guix-cran. Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 30 Nov 2022 16:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58623 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: rekado@elephly.net, 58623@debbugs.gnu.org Received: via spool by 58623-submit@debbugs.gnu.org id=B58623.166982684227320 (code B ref 58623); Wed, 30 Nov 2022 16:48:01 +0000 Received: (at 58623) by debbugs.gnu.org; 30 Nov 2022 16:47:22 +0000 Received: from localhost ([127.0.0.1]:33834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0QEy-00076a-3B for submit@debbugs.gnu.org; Wed, 30 Nov 2022 11:47:21 -0500 Received: from mout-p-101.mailbox.org ([80.241.56.151]:60870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0QEt-00076I-Aw for 58623@debbugs.gnu.org; Wed, 30 Nov 2022 11:47:18 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4NMlVK4JDmz9sZl; Wed, 30 Nov 2022 17:47:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1669826825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BbLbQPN6ora5p4bw5HKbuhM5MnY69aP/szpKQSPvGsM=; b=bmRE/AV6hGI3rFeRuGuq7fLe/+movIZUwzz8IeH6m8yUEItiyiheaZrSWOCGrGkmhM+XmG YVbuyrkPe2Eh85kKOI48MYp2QA4SQOmxehfi0M/Rjtd5HfXe+pqhRLMi/lltJQmSvXwz+U Xw82wyelrzQzC+yIbcnG3mdzxmz36rweI6TzQYlLhLtG1IQC9Lq4xxn8rWbxgGnB/GFp60 OXFe4L1HQM60QL0Mgn4/fjierCTIL6rtE8ye4MwCCC+v0c7TW8v5ZI0NA8I3w2feftkhTj u3NrJ4KKvgTxGmKJBGsssVbn0Oapu6EDvXbZgYC1Z6tVFQf7rUFT6gphm+fjyA== Date: Wed, 30 Nov 2022 17:47:02 +0100 From: Lars-Dominik Braun Message-ID: References: <87iljti0w9.fsf@gnu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87iljti0w9.fsf@gnu.org> 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi Ludo, here’s a v2, which hopefully addresses your comments. Passing in arguments required some refactoring in import/utils.scm. I also added another commit, which speeds up imports significantly. There I tried to use VALUES (and LET*-VALUES), but ultimately failed and fell back to LIST and CAR/CADR. There’s probably a better solution? Cheers, Lars Lars-Dominik Braun (6): import/utils: Pass all arguments through to package builder. import/cran: Allow custom license prefix. import/cran: Allow overriding description fetch function. import/cran: Allow overriding tarball download. import/cran: Translate more package dependencies. import/cran: Always operate on source directory. doc/guix.texi | 4 + guix/import/cran.scm | 156 +++++++++++++++++------------------ guix/import/crate.scm | 3 +- guix/import/egg.scm | 3 +- guix/import/elm.scm | 2 +- guix/import/gem.scm | 3 +- guix/import/gnu.scm | 3 +- guix/import/go.scm | 5 +- guix/import/hackage.scm | 5 +- guix/import/hexpm.scm | 2 +- guix/import/minetest.scm | 5 +- guix/import/opam.scm | 2 +- guix/import/pypi.scm | 2 +- guix/import/stackage.scm | 5 +- guix/import/texlive.scm | 4 +- guix/import/utils.scm | 10 +-- guix/scripts/import/cran.scm | 21 ++++- 17 files changed, 130 insertions(+), 105 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index a02e746417..41e5d45acf 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -639,7 +639,7 @@ (define (description->package repository meta) (define cran->guix-package (memoize - (lambda* (package-name #:key (repo 'cran) version) + (lambda* (package-name #:key (repo 'cran) version #:allow-other-keys) "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 version))) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index c76d7e9c1a..415b816a9b 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -216,7 +216,8 @@ (define (string->license string) 'unknown-license!))) (string-split string (string->char-set " /")))) -(define* (crate->guix-package crate-name #:key version include-dev-deps? repo) +(define* (crate->guix-package crate-name #:key version include-dev-deps? + #:allow-other-keys) "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 diff --git a/guix/import/egg.scm b/guix/import/egg.scm index 0d6d72c465..6a189994fb 100644 --- a/guix/import/egg.scm +++ b/guix/import/egg.scm @@ -170,7 +170,8 @@ (define string->license ;;; Egg importer. ;;; -(define* (egg->guix-package name version #:key (file #f) (source #f)) +(define* (egg->guix-package name version #:key (file #f) (source #f) + #:allow-other-keys) "Import a CHICKEN egg called NAME from either the given .egg FILE, or from the latest NAME metadata downloaded from the official repository if FILE is #f. Return a record or #f on failure. If VERSION is specified, import diff --git a/guix/import/elm.scm b/guix/import/elm.scm index 74902b8617..c8fb15343f 100644 --- a/guix/import/elm.scm +++ b/guix/import/elm.scm @@ -190,7 +190,7 @@ (define guix-name (define elm->guix-package (memoize - (lambda* (package-name #:key repo version) + (lambda* (package-name #:key version #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME, an Elm package registered at package.elm.org, and return two values: the `package' s-expression corresponding to that package (or #f on failure) and a list of Elm diff --git a/guix/import/gem.scm b/guix/import/gem.scm index ad1343bff4..eaaae5dc9e 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm @@ -123,7 +123,8 @@ (define (make-gem-sexp name version hash home-page synopsis description ((license) (license->symbol license)) (_ `(list ,@(map license->symbol licenses))))))) -(define* (gem->guix-package package-name #:key (repo 'rubygems) version) +(define* (gem->guix-package package-name #:key (repo 'rubygems) version + #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME from rubygems.org, and return the `package' s-expression corresponding to that package, or #f on failure. Optionally include a VERSION string to fetch a specific version gem." diff --git a/guix/import/gnu.scm b/guix/import/gnu.scm index 2b9b71feb0..130844923e 100644 --- a/guix/import/gnu.scm +++ b/guix/import/gnu.scm @@ -109,7 +109,8 @@ (define sig-url #f)))) (define* (gnu->guix-package name - #:key (key-download 'interactive)) + #:key (key-download 'interactive) + #:allow-other-keys) "Return the package declaration for NAME as an s-expression. Use KEY-DOWNLOAD as the OpenPGP key download policy (see 'download-tarball' for details.)" diff --git a/guix/import/go.scm b/guix/import/go.scm index d00c13475a..90d4c8931d 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -602,7 +602,8 @@ (define (validate-version version available-versions module-path) (define* (go-module->guix-package module-path #:key (goproxy "https://proxy.golang.org") version - pin-versions?) + pin-versions? + #:allow-other-keys) "Return the package S-expression corresponding to MODULE-PATH at VERSION, a Go package. The meta-data is fetched from the GOPROXY server and https://pkg.go.dev/. When VERSION is unspecified, the latest version available is used." @@ -687,7 +688,7 @@ (define* (go-module-recursive-import package-name package-name #:repo->guix-package (memoize - (lambda* (name #:key version repo) + (lambda* (name #:key version repo #:allow-other-keys) (receive (package-sexp dependencies) (go-module->guix-package* name #:goproxy goproxy #:version version diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 878a7d2f9c..bbce8b1fdc 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -323,7 +323,8 @@ (define (maybe-arguments) (define* (hackage->guix-package package-name #:key (include-test-dependencies? #t) (port #f) - (cabal-environment '())) + (cabal-environment '()) + #:allow-other-keys) "Fetch the Cabal file for PACKAGE-NAME from hackage.haskell.org, or, if the called with keyword parameter PORT, from PORT. Return the `package' S-expression corresponding to that package, or #f on failure. @@ -350,7 +351,7 @@ (define hackage->guix-package/m ;memoized variant (define* (hackage-recursive-import package-name . args) (recursive-import package-name - #:repo->guix-package (lambda* (name #:key repo version) + #:repo->guix-package (lambda* (name #:key version #:allow-other-keys) (apply hackage->guix-package/m (cons name args))) #:guix-name hackage-name->package-name)) diff --git a/guix/import/hexpm.scm b/guix/import/hexpm.scm index 2a7a9f3d82..de5e4c6e8e 100644 --- a/guix/import/hexpm.scm +++ b/guix/import/hexpm.scm @@ -234,7 +234,7 @@ (define (hexpm-latest-release package) (fold (lambda (a b) (if (version>? a b) a b)) (car versions) versions))))) -(define* (hexpm->guix-package package-name #:key repo version) +(define* (hexpm->guix-package package-name #:key version #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME from hexpms.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 diff --git a/guix/import/minetest.scm b/guix/import/minetest.scm index 43cfb533e2..3bdc02120e 100644 --- a/guix/import/minetest.scm +++ b/guix/import/minetest.scm @@ -439,7 +439,8 @@ (define (filter-deduplicate-map f list) #f))))) dependency-list)) -(define* (%minetest->guix-package author/name #:key (sort %default-sort-key)) +(define* (%minetest->guix-package author/name #:key (sort %default-sort-key) + #:allow-other-keys) "Fetch the metadata for AUTHOR/NAME from https://content.minetest.net, and return the 'package' S-expression corresponding to that package, or raise an exception on failure. On success, also return the upstream dependencies as a @@ -475,7 +476,7 @@ (define minetest->guix-package (memoize %minetest->guix-package)) (define* (minetest-recursive-import author/name #:key (sort %default-sort-key)) - (define* (minetest->guix-package* author/name #:key repo version) + (define* (minetest->guix-package* author/name #:key version #:allow-other-keys) (minetest->guix-package author/name #:sort sort)) (recursive-import author/name #:repo->guix-package minetest->guix-package* diff --git a/guix/import/opam.scm b/guix/import/opam.scm index b4b5a6eaad..7097281371 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -338,7 +338,7 @@ (define (opam->guix-source url-dict) (sha256 (base32 ,(guix-hash-url temp))))))) 'no-source-information))) -(define* (opam->guix-package name #:key (repo 'opam) version) +(define* (opam->guix-package name #:key (repo 'opam) version #:allow-other-keys) "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." diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index 4760fc3dae..f92cb46f84 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm @@ -491,7 +491,7 @@ (define (maybe-upstream-name name) (define pypi->guix-package (memoize - (lambda* (package-name #:key repo version) + (lambda* (package-name #:key version #:allow-other-keys) "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)) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 49be982a7f..bde6d05762 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -108,7 +108,8 @@ (define stackage->guix-package (lts-version %default-lts-version) (packages (stackage-lts-packages - (stackage-lts-info-fetch lts-version)))) + (stackage-lts-info-fetch lts-version))) + #:allow-other-keys) "Fetch Cabal file for PACKAGE-NAME from hackage.haskell.org. The retrieved version corresponds to the version of PACKAGE-NAME specified in the LTS-VERSION release at stackage.org. Return the `package' S-expression corresponding to @@ -125,7 +126,7 @@ (define stackage->guix-package (define (stackage-recursive-import package-name . args) (recursive-import package-name - #:repo->guix-package (lambda* (name #:key repo version) + #:repo->guix-package (lambda* (name #:key version #:allow-other-keys) (apply stackage->guix-package (cons name args))) #:guix-name hackage-name->package-name)) diff --git a/guix/import/texlive.scm b/guix/import/texlive.scm index 116bd1f66a..6bf7f92e60 100644 --- a/guix/import/texlive.scm +++ b/guix/import/texlive.scm @@ -303,9 +303,9 @@ (define (tlpdb->package name version package-database) (define texlive->guix-package (memoize (lambda* (name #:key - repo (version (number->string %texlive-revision)) - (package-database tlpdb)) + (package-database tlpdb) + #:allow-other-keys) "Find the metadata for NAME in the tlpdb and return the `package' s-expression corresponding to that package, or #f on failure." (tlpdb->package name version (package-database))))) diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d6b179b57c..45e55f1df6 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -580,11 +580,11 @@ (define (topological-sort nodes (set-insert (node-name head) visited)))))))) (define* (recursive-import package-name - #:key repo->guix-package guix-name version repo - #:allow-other-keys) + #:key repo->guix-package guix-name version + #:allow-other-keys #:rest rest) "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 :KEYS version repo), which should return a +call (REPO->GUIX-PACKAGE NAME :KEYS version), which should return a package expression and a list of dependencies; call (GUIX-NAME PACKAGE-NAME) to obtain the Guix package name corresponding to the upstream name." (define-record-type @@ -599,9 +599,7 @@ (define (exists? name version) (not (null? (find-packages-by-name (guix-name name) version)))) (define (lookup-node name version) - (let* ((package dependencies (repo->guix-package name - #:version version - #:repo repo)) + (let* ((package dependencies (apply repo->guix-package (cons name rest))) (normalized-deps (map (match-lambda ((name version) (list name version)) (name (list name #f))) dependencies)))