diff options
Diffstat (limited to 'guix/import/utils.scm')
-rw-r--r-- | guix/import/utils.scm | 104 |
1 files changed, 81 insertions, 23 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 93cd0f0fa5..e4059ca114 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -1,5 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org> +;;; Copyright © 2016 David Craven <david@craven.ch> ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,14 +19,15 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (guix import utils) - #:use-module (ice-9 match) - #:use-module (ice-9 regex) - #:use-module (srfi srfi-1) - #:use-module (guix hash) #:use-module (guix base32) + #:use-module ((guix build download) #:prefix build:) + #:use-module (guix hash) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) - #:use-module ((guix build download) #:prefix build:) + #:use-module (ice-9 match) + #:use-module (ice-9 regex) + #:use-module (json) + #:use-module (srfi srfi-1) #:export (factorize-uri hash-table->alist @@ -34,7 +37,7 @@ url-fetch guix-hash-url - string->license + spdx-string->license license->symbol snake-case @@ -109,29 +112,84 @@ recursively apply the procedure to the sub-list." "Return the hash of FILENAME in nix-base32 format." (bytevector->nix-base32-string (file-sha256 filename))) -(define (string->license str) - "Convert the string STR into a license object." +(define (spdx-string->license str) + "Convert STR, a SPDX formatted license identifier, to a license object. + Return #f if STR does not match any known identifiers." + ;; https://spdx.org/licenses/ + ;; The psfl, gfl1.0, nmap, repoze + ;; licenses doesn't have SPDX identifiers (match str - ("GNU LGPL" license:lgpl2.0) - ("GPL" license:gpl3) - ((or "BSD" "BSD License") license:bsd-3) - ((or "MIT" "MIT license" "Expat license") license:expat) - ("Public domain" license:public-domain) - ((or "Apache License, Version 2.0" "Apache 2.0") license:asl2.0) + ("AGPL-1.0" 'license:agpl-1.0) + ("AGPL-3.0" 'license:agpl-3.0) + ("Apache-1.1" 'license:asl1.1) + ("Apache-2.0" 'license:asl2.0) + ("BSL-1.0" 'license:boost1.0) + ("BSD-2-Clause-FreeBSD" 'license:bsd-2) + ("BSD-3-Clause" 'license:bsd-3) + ("BSD-4-Clause" 'license:bsd-4) + ("CC0-1.0" 'license:cc0) + ("CC-BY-2.0" 'license:cc-by2.0) + ("CC-BY-3.0" 'license:cc-by3.0) + ("CC-BY-SA-2.0" 'license:cc-by-sa2.0) + ("CC-BY-SA-3.0" 'license:cc-by-sa3.0) + ("CC-BY-SA-4.0" 'license:cc-by-sa4.0) + ("CDDL-1.0" 'license:cddl1.0) + ("CECILL-C" 'license:cecill-c) + ("Artistic-2.0" 'license:artistic2.0) + ("ClArtistic" 'license:clarified-artistic) + ("CPL-1.0" 'license:cpl1.0) + ("EPL-1.0" 'license:epl1.0) + ("MIT" 'license:expat) + ("FTL" 'license:freetype) + ("GFDL-1.1" 'license:fdl1.1+) + ("GFDL-1.2" 'license:fdl1.2+) + ("GFDL-1.3" 'license:fdl1.3+) + ("Giftware" 'license:giftware) + ("GPL-1.0" 'license:gpl1) + ("GPL-1.0+" 'license:gpl1+) + ("GPL-2.0" 'license:gpl2) + ("GPL-2.0+" 'license:gpl2+) + ("GPL-3.0" 'license:gpl3) + ("GPL-3.0+" 'license:gpl3+) + ("ISC" 'license:isc) + ("IJG" 'license:ijg) + ("Imlib2" 'license:imlib2) + ("IPA" 'license:ipa) + ("IPL-1.0" 'license:ibmpl1.0) + ("LGPL-2.0" 'license:lgpl2.0) + ("LGPL-2.0+" 'license:lgpl2.0+) + ("LGPL-2.1" 'license:lgpl2.1) + ("LGPL-2.1+" 'license:lgpl2.1+) + ("LGPL-3.0" 'license:lgpl3.0) + ("LGPL-3.0+" 'license:lgpl3.0+) + ("MPL-1.0" 'license:mpl1.0) + ("MPL-1.1" 'license:mpl1.1) + ("MPL-2.0" 'license:mpl2.0) + ("MS-PL" 'license:ms-pl) + ("NCSA" 'license:ncsa) + ("OpenSSL" 'license:openssl) + ("OLDAP-2.8" 'license:openldap2.8) + ("CUA-OPL-1.0" 'license:opl1.0) + ("QPL-1.0" 'license:qpl) + ("Ruby" 'license:ruby) + ("SGI-B-2.0" 'license:sgifreeb2.0) + ("OFL-1.1" 'license:silofl1.1) + ("Sleepycat" 'license:sleepycat) + ("TCL" 'license:tcl/tk) + ("Unlicense" 'license:unlicense) + ("Vim" 'license:vim) + ("X11" 'license:x11) + ("ZPL-2.1" 'license:zpl2.1) + ("Zlib" 'license:zlib) (_ #f))) (define (license->symbol license) "Convert license to a symbol representing the variable the object is bound to in the (guix licenses) module, or #f if there is no such known license." - ;; TODO: Traverse list public variables in (guix licenses) instead so we - ;; don't have to maintain a list manualy. - (assoc-ref `((,license:lgpl2.0 . license:lgpl2.0) - (,license:gpl3 . license:gpl3) - (,license:bsd-3 . license:bsd-3) - (,license:expat . license:expat) - (,license:public-domain . license:public-domain) - (,license:asl2.0 . license:asl2.0)) - license)) + (define licenses + (module-map (lambda (sym var) `(,(variable-ref var) . ,sym)) + (resolve-interface '(guix licenses) #:prefix 'license:))) + (assoc-ref licenses license)) (define (snake-case str) "Return a downcased version of the string STR where underscores are replaced |