import: utils: 'alist->package' allows false license.

Reported by <pkill9@runbox.com>.
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.
This commit is contained in:
Ludovic Courtès 2018-02-16 11:06:31 +01:00
parent 469069b6e8
commit 5e2495d09e
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 26 additions and 5 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2012, 2013, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
@ -330,10 +330,12 @@ (define (alist->package meta)
(description
(assoc-ref meta "description"))
(license
(let ((l (assoc-ref meta "license")))
(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))))))
(license:fsdg-compatible l)))))))
(define* (read-lines #:optional (port (current-input-port)))
"Read lines from PORT and return them as a list."

View file

@ -79,4 +79,23 @@ (define-module (test-import-utils)
(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")