[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: import: utils: 'alist->package' allows false license.
From: |
Ludovic Courtès |
Subject: |
02/02: import: utils: 'alist->package' allows false license. |
Date: |
Fri, 16 Feb 2018 05:10:19 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 5e2495d09e5ad78f8ebb6bfa6fb4ff09fb305ec4
Author: Ludovic Courtès <address@hidden>
Date: Fri Feb 16 11:06:31 2018 +0100
import: utils: 'alist->package' allows false license.
Reported by <address@hidden>.
Fixes <https://bugs.gnu.org/30470>.
* guix/import/utils.scm (alist->package): Check whether 'license' is
false and set the 'license' field to #f in this case.
* tests/import-utils.scm ("alist->package with false license"): New
test.
---
guix/import/utils.scm | 12 +++++++-----
tests/import-utils.scm | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index d4cef6b..efc6169 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2018 Ludovic Courtès <address@hidden>
;;; Copyright © 2016 Jelle Licht <address@hidden>
;;; Copyright © 2016 David Craven <address@hidden>
;;; Copyright © 2017 Ricardo Wurmus <address@hidden>
@@ -330,10 +330,12 @@ the expected fields of an <origin> object."
(description
(assoc-ref meta "description"))
(license
- (let ((l (assoc-ref meta "license")))
- (or (module-ref (resolve-interface '(guix licenses) #:prefix 'license:)
- (spdx-string->license l))
- (license:fsdg-compatible l))))))
+ (match (assoc-ref meta "license")
+ (#f #f)
+ (l
+ (or (module-ref (resolve-interface '(guix licenses) #:prefix 'license:)
+ (spdx-string->license l))
+ (license:fsdg-compatible l)))))))
(define* (read-lines #:optional (port (current-input-port)))
"Read lines from PORT and return them as a list."
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index f4bbd33..5c0c041 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -79,4 +79,23 @@
(equal? (origin-sha256 (package-source pkg))
(base32
"0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
+(test-equal "alist->package with false license" ;<https://bugs.gnu.org/30470>
+ 'license-is-false
+ (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" . #f))))
+ ;; Note: Use 'or' because comparing with #f otherwise succeeds when
+ ;; there's an exception instead of an actual #f.
+ (or (package-license (alist->package meta))
+ 'license-is-false)))
+
(test-end "import-utils")