unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 37254@debbugs.gnu.org
Subject: [bug#37254] [PATCH 4/4] import: crate: Correct interpretation of dual-licensing strings.
Date: Sun,  1 Sep 2019 16:56:03 +0200	[thread overview]
Message-ID: <20190901145603.15515-4-ludo@gnu.org> (raw)
In-Reply-To: <20190901145603.15515-1-ludo@gnu.org>

* guix/import/crate.scm (%dual-license-rx): New variable.
(crate->guix-package)[string->license]: Rewrite to match it.
* tests/crate.scm (test-crate): Adjust "license" field to current
practice.
---
 guix/import/crate.scm | 11 ++++++++++-
 tests/crate.scm       |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index bcd5068e6c..a1cbf33361 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -32,6 +32,7 @@
   #:use-module (guix upstream)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 regex)
   #:use-module (json)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
@@ -175,11 +176,19 @@ 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)
   "Fetch the metadata for CRATE-NAME from crates.io, and return the
 `package' s-expression corresponding to that package, or #f on failure."
   (define (string->license string)
-    (map spdx-string->license (string-split string #\/)))
+    (match (regexp-exec %dual-license-rx string)
+      (#f (spdx-string->license string))
+      (m  (list (spdx-string->license (match:substring m 1))
+                (spdx-string->license (match:substring m 2))))))
 
   (define (normal-dependency? dependency)
     (eq? (crate-dependency-kind dependency) 'normal))
diff --git a/tests/crate.scm b/tests/crate.scm
index 8a232ba06c..c14862ad9f 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -41,7 +41,7 @@
     \"actual_versions\": [
       { \"id\": \"foo\",
         \"num\": \"1.0.0\",
-        \"license\": \"MIT/Apache-2.0\",
+        \"license\": \"MIT OR Apache-2.0\",
         \"links\": {
           \"dependencies\": \"/api/v1/crates/foo/1.0.0/dependencies\"
         }
-- 
2.23.0

  parent reply	other threads:[~2019-09-01 14:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-01 14:46 [bug#37254] [PATCH 0/4] Refactor (guix ci) and (guix import crate) Ludovic Courtès
2019-09-01 14:56 ` [bug#37254] [PATCH 1/4] Add (guix json) Ludovic Courtès
2019-09-01 14:56   ` [bug#37254] [PATCH 2/4] ci: Use (guix json) and adjust for Guile-JSON 3.x Ludovic Courtès
2019-09-01 14:56   ` [bug#37254] [PATCH 3/4] import: create: Separate crates.io API from actual conversion Ludovic Courtès
2019-09-01 14:56   ` Ludovic Courtès [this message]
2019-09-01 16:05 ` [bug#37254] [PATCH 0/4] Refactor (guix ci) and (guix import crate) Efraim Flashner
2019-09-04 11:04   ` bug#37254: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190901145603.15515-4-ludo@gnu.org \
    --to=ludo@gnu.org \
    --cc=37254@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).