Hello,

SPDX seems to be a more general specification for licenses, but I still wonder whether its appropriate for (guix import utils), since its used only by the crate importer.


On 2016-09-22 08:18, David Craven wrote:
* guix/import/utils.scm (spdx-string->license): New variable.
---
guix/import/utils.scm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index b5dcc17..ca00baf 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013 Ludovic Courtès <l...@gnu.org>
 ;;; Copyright © 2014 David Thompson <da...@gnu.org>
 ;;; Copyright © 2015 Eric Bavier <bav...@member.fsf.org>
+;;; Copyright © 2016 Jelle Licht <jli...@fsfe.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,6 +39,7 @@
             json-fetch
             guix-hash-url

+            spdx-string->license
             license->symbol

             snake-case
@@ -112,7 +114,65 @@ 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 (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."
   (match str
+    ("AGPL-1.0"                    'license:AGPL-1.0)
+    ("AGPL-3.0"                    'license:AGPL-3.0)

These two don't exist in (guix licenses)

+    ("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-SA-4.0"                'license:cc-by-sa4.0)
+    ("CC-BY-SA-3.0"                'license:cc-by-sa3.0)

Maybe also "cc-by-sa2.0"?

+    ("CC-BY-3.0"                   'license:cc-by3.0)
+    ("CC-BY-2.0"                   'license:cc-by2.0)

Maybe numerically sort the cc licenses, like the others?

+    ("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)
+    ("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)
+    ("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)
+    ("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)
+    ("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)
+    ("Vim"                         'license:vim)

Alphabetically "vim" succeeds" "unlicense".

+    ("Unlicense"                   'license:unlicense)
+    ("X11"                         'license:x11)
+    ("ZPL-2.1"                     'license:zpl2.1)
+    ("Zlib"                        'license:zlib)
     (_ #f)))

 (define (license->symbol license)

Some that are missing(?):

"IPL-1.0" => 'license:ibmpl1.0
"CUA-OPL-1.0" => 'license:opl1.0
The "psfl" license. It appears our "psfl" doesn't seem to map cleanly to one in the SPDX list.

--
`~Eric

Reply via email to