[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: import/utils: alist->package: Handle SPDX license names only as f
From: |
guix-commits |
Subject: |
02/02: import/utils: alist->package: Handle SPDX license names only as fallback. |
Date: |
Sun, 27 Dec 2020 06:07:47 -0500 (EST) |
rekado pushed a commit to branch master
in repository guix.
commit 5aae614868b8a7e3097ae70f6024352aa5c8de21
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Sun Dec 27 12:05:24 2020 +0100
import/utils: alist->package: Handle SPDX license names only as fallback.
Fixes <https://bugs.gnu.org/45453>.
* guix/import/utils.scm (alist->package): Find plain license names in (guix
licenses) first, and only fall back to SPDX names on error.
* tests/import-utils.scm ("alist->package with SPDX license name 1/2",
"alist->package with SPDX license name 2/2"): New tests.
---
guix/import/utils.scm | 8 ++++++--
tests/import-utils.scm | 32 ++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index e227c2e..cdbcf6b 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -372,8 +372,12 @@ specifications to look up and replace them with plain
symbols instead."
(match (assoc-ref meta "license")
(#f #f)
(l
- (or (module-ref (resolve-interface '(guix licenses) #:prefix 'license:)
- (spdx-string->license l))
+ (or (false-if-exception
+ (module-ref (resolve-interface '(guix licenses))
+ (string->symbol l)))
+ (false-if-exception
+ (module-ref (resolve-interface '(guix licenses) #:prefix
'license:)
+ (spdx-string->license l)))
(license:fsdg-compatible l)))))))
(define* (read-lines #:optional (port (current-input-port)))
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 2357ea5..8748164 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -122,6 +122,38 @@
(or (package-license (alist->package meta))
'license-is-false)))
+(test-equal "alist->package with SPDX license name 1/2"
;<https://bugs.gnu.org/45453>
+ license:expat
+ (let* ((meta '(("name" . "hello")
+ ("version" . "2.10")
+ ("source" . (("method" . "url-fetch")
+ ("uri" .
"mirror://gnu/hello/hello-2.10.tar.gz")
+ ("sha256" .
+ (("base32" .
+
"0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
+ ("build-system" . "gnu")
+ ("home-page" . "https://gnu.org")
+ ("synopsis" . "Say hi")
+ ("description" . "This package says hi.")
+ ("license" . "expat"))))
+ (package-license (alist->package meta))))
+
+(test-equal "alist->package with SPDX license name 2/2"
;<https://bugs.gnu.org/45453>
+ license:expat
+ (let* ((meta '(("name" . "hello")
+ ("version" . "2.10")
+ ("source" . (("method" . "url-fetch")
+ ("uri" .
"mirror://gnu/hello/hello-2.10.tar.gz")
+ ("sha256" .
+ (("base32" .
+
"0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
+ ("build-system" . "gnu")
+ ("home-page" . "https://gnu.org")
+ ("synopsis" . "Say hi")
+ ("description" . "This package says hi.")
+ ("license" . "MIT"))))
+ (package-license (alist->package meta))))
+
(test-equal "alist->package with dependencies"
`(("gettext" ,(specification->package "gettext")))
(let* ((meta '(("name" . "hello")