aboutsummaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorDavid Craven <david@craven.ch>2016-09-22 11:35:13 +0200
committerDavid Craven <david@craven.ch>2016-09-28 13:17:15 +0200
commit11e296ef3092de1e5b659822d4dad4465abad34f (patch)
tree83e212847a966a3c31de2332ae88513cf3d9b60d /guix/import
parent59b2034787909cf7efa4e8d672a815b466d7d09d (diff)
downloadgnu-guix-11e296ef3092de1e5b659822d4dad4465abad34f.tar
gnu-guix-11e296ef3092de1e5b659822d4dad4465abad34f.tar.gz
import: utils: Refactor license->symbol.
* guix/import/utils.scm (license->symbol): Work for all licenses. * tests/import-utils.scm (license->symbol): Add test.
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/utils.scm14
1 files changed, 5 insertions, 9 deletions
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index ce0ba99fc0..e4059ca114 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -1,6 +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.
;;;
@@ -185,15 +186,10 @@ recursively apply the procedure to the sub-list."
(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