GNU bug report logs - #37928
Better handle license expressions in 'guix import crate'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Brice Waegeneire <brice@HIDDEN>; Keywords: patch; merged with #37927; dated Fri, 25 Oct 2019 20:28:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Changed bug title to 'Better handle license expressions in 'guix import crate'' from '[PATCH] import: crate: Fix licenses.' Request was from Ludovic Courtès <ludo@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 37928 <at> debbugs.gnu.org:


Received: (at 37928) by debbugs.gnu.org; 4 Nov 2019 22:27:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 04 17:27:40 2019
Received: from localhost ([127.0.0.1]:37678 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iRkp2-00075J-JI
	for submit <at> debbugs.gnu.org; Mon, 04 Nov 2019 17:27:40 -0500
Received: from eggs.gnu.org ([209.51.188.92]:50179)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>)
 id 1iRkow-00074q-Br; Mon, 04 Nov 2019 17:27:37 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39206)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1iRkoq-0006aB-HZ; Mon, 04 Nov 2019 17:27:28 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36208 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1iRkoo-0002M7-Uq; Mon, 04 Nov 2019 17:27:27 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Brice Waegeneire <brice@HIDDEN>
Subject: Re: [bug#37928] [PATCH] import: crate: Fix licenses.
References: <20191025202713.7739-1-brice@HIDDEN>
 <20191025202713.7739-2-brice@HIDDEN>
Date: Mon, 04 Nov 2019 23:27:24 +0100
In-Reply-To: <20191025202713.7739-2-brice@HIDDEN> (Brice Waegeneire's
 message of "Fri, 25 Oct 2019 22:27:13 +0200")
Message-ID: <87mudb46r7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37928
Cc: 37927 <at> debbugs.gnu.org, 37928 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Brice,

Brice Waegeneire <brice@HIDDEN> skribis:

> * guix/import/crate.scm (%dual-license-rx): Removed function.
> (crate->guix-package): Handle most of the multi-licensing cases.

Nice!

>  (define* (crate->guix-package crate-name #:optional version)
>    "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 fetc=
h the
>  latest version of CRATE-NAME."
>    (define (string->license string)
> -    (match (regexp-exec %dual-license-rx string)
> -      (#f (list (spdx-string->license string)))
> -      (m  (list (spdx-string->license (match:substring m 1))
> -                (spdx-string->license (match:substring m 2))))))
> +    (filter
> +     (lambda (word)
> +       (and (not (string-null? word))
> +            (not (any (lambda (elem) (string=3D? elem word))
> +                      '("AND" "OR" "WITH"))) ))
> +     (string-split string (string->char-set " /"))))

It would be great to have tests for that in tests/crate.scm.  To that
end, I think you could lift =E2=80=98string->license=E2=80=99 to the top le=
vel (that is,
outside =E2=80=98crate->guix-package=E2=80=99), and then have a few tests a=
long these
lines:

  (define string->license
    (@@ (guix import crate) string->license))

  (test-equal "GPL OR LGPL"
    (list license:gpl3+ license:lgpl3+)
    (string->license "GPL OR LGPL"))

(See
<https://guix.gnu.org/manual/en/html_node/Running-the-Test-Suite.html>.)

Let me know if anything is unclear.

Could you send an updated patch?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#37928; Package guix-patches. Full text available.
Merged 37927 37928. Request was from Mathieu Othacehe <m.othacehe@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 25 Oct 2019 20:27:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 25 16:27:42 2019
Received: from localhost ([127.0.0.1]:39409 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iO6BS-0001Lg-3e
	for submit <at> debbugs.gnu.org; Fri, 25 Oct 2019 16:27:42 -0400
Received: from lists.gnu.org ([209.51.188.17]:39004)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <brice@HIDDEN>) id 1iO6BQ-0001LS-GQ
 for submit <at> debbugs.gnu.org; Fri, 25 Oct 2019 16:27:40 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34611)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <brice@HIDDEN>) id 1iO6BP-0007FH-83
 for guix-patches@HIDDEN; Fri, 25 Oct 2019 16:27:40 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <brice@HIDDEN>) id 1iO6BN-0003xU-1Q
 for guix-patches@HIDDEN; Fri, 25 Oct 2019 16:27:39 -0400
Received: from relay3-d.mail.gandi.net ([217.70.183.195]:47827)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <brice@HIDDEN>) id 1iO6BL-0003uV-1m
 for guix-patches@HIDDEN; Fri, 25 Oct 2019 16:27:36 -0400
X-Originating-IP: 78.237.113.178
Received: from localhost (luy13-1-78-237-113-178.fbx.proxad.net
 [78.237.113.178]) (Authenticated sender: brice@HIDDEN)
 by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 1855960004
 for <guix-patches@HIDDEN>; Fri, 25 Oct 2019 20:27:31 +0000 (UTC)
From: Brice Waegeneire <brice@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] import: crate: Fix licenses.
Date: Fri, 25 Oct 2019 22:27:13 +0200
Message-Id: <20191025202713.7739-2-brice@HIDDEN>
X-Mailer: git-send-email 2.19.2
In-Reply-To: <20191025202713.7739-1-brice@HIDDEN>
References: <20191025202713.7739-1-brice@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 217.70.183.195
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

* guix/import/crate.scm (%dual-license-rx): Removed function.
(crate->guix-package): Handle most of the multi-licensing cases.
---
 guix/import/crate.scm | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 8dc014d232..e08028db15 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -178,21 +178,18 @@ and LICENSE."
          (close-port port)
          pkg))
 
-(define %dual-license-rx
-  ;; Dual licensing is represented by a string such as "MIT OR Apache-2.0".
-  ;; This regexp matches that.
-  (make-regexp "^(.*) OR (.*)$"))
-
 (define* (crate->guix-package crate-name #:optional version)
   "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."
   (define (string->license string)
-    (match (regexp-exec %dual-license-rx string)
-      (#f (list (spdx-string->license string)))
-      (m  (list (spdx-string->license (match:substring m 1))
-                (spdx-string->license (match:substring m 2))))))
+    (filter
+     (lambda (word)
+       (and (not (string-null? word))
+            (not (any (lambda (elem) (string=? elem word))
+                      '("AND" "OR" "WITH"))) ))
+     (string-split string (string->char-set " /"))))
 
   (define (normal-dependency? dependency)
     (eq? (crate-dependency-kind dependency) 'normal))
-- 
2.19.2





Acknowledgement sent to Brice Waegeneire <brice@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#37928; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 4 Nov 2019 22:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.