summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorBrice Waegeneire <brice@waegenei.re>2019-11-26 21:17:21 +0100
committerLudovic Courtès <ludo@gnu.org>2019-12-11 12:13:03 +0100
commit263a267b75e472cb84428571580dabd99d5dff0c (patch)
tree884dc1ac258fbd136eebe2855fd9141f2e048056 /guix/import
parent4982de4c3299f367ab582e0865c39186a12ab3a1 (diff)
import: crate: Better handle license expressions.
* guix/import/crate.scm (%dual-license-rx): Removed function. (crate->guix-package): Handle most of the multi-licensing cases. * tests/crate.scm (licenses): Add tests for some licenses. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/crate.scm17
1 files changed, 8 insertions, 9 deletions
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 8dc014d232..4c3f8000d0 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -178,21 +178,20 @@ 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 (string->license string)
+ (filter-map (lambda (license)
+ (and (not (string-null? license))
+ (not (any (lambda (elem) (string=? elem license))
+ '("AND" "OR" "WITH")))
+ (or (spdx-string->license license)
+ 'unknown-license!)))
+ (string-split string (string->char-set " /"))))
(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))))))
(define (normal-dependency? dependency)
(eq? (crate-dependency-kind dependency) 'normal))