summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-09-01 16:32:11 +0200
committerLudovic Courtès <ludo@gnu.org>2019-09-04 13:02:27 +0200
commit191668bc9759dc87a27b5f4d55d214cc655f197f (patch)
treeaea247c0ff95c041dec543f7d20e43426ee903dc /guix/import
parent2791870d09afd247a011bc8cb6cf88661729bd98 (diff)
downloadguix-patches-191668bc9759dc87a27b5f4d55d214cc655f197f.tar
guix-patches-191668bc9759dc87a27b5f4d55d214cc655f197f.tar.gz
import: crate: Correct interpretation of dual-licensing strings.
* 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.
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/crate.scm11
1 files changed, 10 insertions, 1 deletions
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index b674323177..f6057dbf8b 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 (list (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))