From patchwork Wed Oct 19 09:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 43710 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 8218D27BBEA; Wed, 19 Oct 2022 10:30:38 +0100 (BST) 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 972E927BBE9 for ; Wed, 19 Oct 2022 10:30:37 +0100 (BST) Received: from localhost ([::1]:57670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol5PI-0003Js-EB for patchwork@mira.cbaines.net; Wed, 19 Oct 2022 05:30:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol5Om-0003IF-0Z for guix-patches@gnu.org; Wed, 19 Oct 2022 05:30:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ol5Ok-0002Qm-SD; Wed, 19 Oct 2022 05:30:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ol5Ok-0002Ct-FI; Wed, 19 Oct 2022 05:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58623] [PATCH 0/3] import/cran: Parameterize for guix-cran. Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, guix-patches@gnu.org Resent-Date: Wed, 19 Oct 2022 09:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58623 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58623@debbugs.gnu.org Cc: ludo@gnu.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16661717648415 (code B ref -1); Wed, 19 Oct 2022 09:30:02 +0000 Received: (at submit) by debbugs.gnu.org; 19 Oct 2022 09:29:24 +0000 Received: from localhost ([127.0.0.1]:55828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ol5O4-0002Bb-PY for submit@debbugs.gnu.org; Wed, 19 Oct 2022 05:29:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:57842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ol5O0-0002BS-K6 for submit@debbugs.gnu.org; Wed, 19 Oct 2022 05:29:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol5O0-0002i3-ET for guix-patches@gnu.org; Wed, 19 Oct 2022 05:29:16 -0400 Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]:47726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1ol5Nv-0002ME-1P for guix-patches@gnu.org; Wed, 19 Oct 2022 05:29:16 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4Mslm66ptPz9sRK for ; Wed, 19 Oct 2022 11:28:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1666171734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=IY97NhsoWi9hmGUYa+SiV/6gKD8n3vPyRyINtcyMcvA=; b=dJymWNasCEcBShVHgHdIh8l7Cl2i5GZDxIVIC9bxHZe12Z1D8jZQsl2uCmS6evwGnKvrjr nwNaXgeuJgxtGSz7MlhDgcuz+M4u5ZW3PkRuwX2NmNrXFTqk0lZKsQpPV7rEU7n7/xvnVz z4kKBjIeNCDyQHirpiBAiibTWxccThQf02MLwKDDz6oNuffBcJmSnRcLqmjZjFxQAjfU20 63CrmSsnzyTzp01N3Sw2i4NWwvT56z4DTdC2liMNZd/iEWBoCXIjvJjkxMBr7qkZqEP1wU Q0lX1Rr4kV9eEBQC5DhQP8Yfme7tBe7GbetuYnXXGWJ4of7zXgAi2EUyGDpUoQ== Date: Wed, 19 Oct 2022 11:28:53 +0200 From: Lars-Dominik Braun Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: 4Mslm66ptPz9sRK Received-SPF: pass client-ip=2001:67c:2050:0:465::202; envelope-from=lars@6xq.net; helo=mout-p-202.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 Hi, the attached patches are required for guix-cran (https://github.com/guix-science/guix-cran). import/cran already has the ability to add a prefix to licenses, but it was not exposed. Additionally I need to parameterize fetch/download functions, so I can cache the tarballs/DESCRIPTION files. Cheers, Lars Lars-Dominik Braun (3): import/cran: Allow custom license prefix. import/cran: Allow overriding description fetch function. import/cran: Allow overriding tarball download. guix/import/cran.scm | 30 +++++++++++++++++++++--------- guix/scripts/import/cran.scm | 18 ++++++++++++++++-- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 17e33d5f52..d13231f633 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -55,6 +55,7 @@ (define-module (guix import cran) #:use-module (guix packages) #:use-module (gnu packages) #:export (%input-style + %license-prefix cran->guix-package bioconductor->guix-package @@ -82,6 +83,9 @@ (define-module (guix import cran) (define %input-style (make-parameter 'variable)) ; or 'specification +(define %license-prefix + (make-parameter identity)) + (define (string->licenses license-string) (let ((licenses (map string-trim-both @@ -89,9 +93,9 @@ (define (string->licenses license-string) (char-set-complement (char-set #\|)))))) (string->license licenses))) -(define string->license - (let ((prefix identity)) - (match-lambda +(define (string->license license-string) + (let ((prefix (%license-prefix))) + (match license-string ("AGPL-3" (prefix 'agpl3)) ("AGPL (>= 3)" (prefix 'agpl3+)) ("Artistic-2.0" (prefix 'artistic2.0)) diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index 2934d4300a..3186bf9248 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -53,6 +53,9 @@ (define (show-help) (display (G_ " -s, --style=STYLE choose output style, either specification or variable")) (display (G_ " + -p, --license-prefix=PREFIX + add custom prefix to licenses, useful for prefixed import of (guix licenses)")) + (display (G_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) @@ -74,6 +77,10 @@ (define %options (lambda (opt name arg result) (alist-cons 'style (string->symbol arg) (alist-delete 'style result)))) + (option '(#\p "license-prefix") #t #f + (lambda (opt name arg result) + (alist-cons 'license-prefix arg + (alist-delete 'license-prefix result)))) (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive #t result))) @@ -95,8 +102,15 @@ (define (parse-options) (('argument . value) value) (_ #f)) - (reverse opts)))) - (parameterize ((%input-style (assoc-ref opts 'style))) + (reverse opts))) + (prefix (assoc-ref opts 'license-prefix)) + (prefix-proc (if (string? prefix) + (lambda (symbol) + (string->symbol + (string-append prefix (symbol->string symbol)))) + identity))) + (parameterize ((%input-style (assoc-ref opts 'style)) + (%license-prefix prefix-proc)) (match args ((spec) (let ((name version (package-name->name+version spec)))