@@ -55,6 +55,7 @@ (define-module (guix import cran)
#:use-module (guix packages)
#:use-module (gnu packages)
#:export (%input-style
+ %license-prefix
cran->guix-package
bioconductor->guix-package
@@ -82,6 +83,9 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
+(define %license-prefix
+ (make-parameter identity))
+
(define (string->licenses license-string)
(let ((licenses
(map string-trim-both
@@ -89,9 +93,9 @@ (define (string->licenses license-string)
(char-set-complement (char-set #\|))))))
(string->license licenses)))
-(define string->license
- (let ((prefix identity))
- (match-lambda
+(define (string->license license-string)
+ (let ((prefix (%license-prefix)))
+ (match license-string
("AGPL-3" (prefix 'agpl3))
("AGPL (>= 3)" (prefix 'agpl3+))
("Artistic-2.0" (prefix 'artistic2.0))
@@ -53,6 +53,9 @@ (define (show-help)
(display (G_ "
-s, --style=STYLE choose output style, either specification or variable"))
(display (G_ "
+ -p, --license-prefix=PREFIX
+ add custom prefix to licenses, useful for prefixed import of (guix licenses)"))
+ (display (G_ "
-V, --version display version information and exit"))
(newline)
(show-bug-report-information))
@@ -74,6 +77,10 @@ (define %options
(lambda (opt name arg result)
(alist-cons 'style (string->symbol arg)
(alist-delete 'style result))))
+ (option '(#\p "license-prefix") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'license-prefix arg
+ (alist-delete 'license-prefix result))))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
@@ -95,8 +102,15 @@ (define (parse-options)
(('argument . value)
value)
(_ #f))
- (reverse opts))))
- (parameterize ((%input-style (assoc-ref opts 'style)))
+ (reverse opts)))
+ (prefix (assoc-ref opts 'license-prefix))
+ (prefix-proc (if (string? prefix)
+ (lambda (symbol)
+ (string->symbol
+ (string-append prefix (symbol->string symbol))))
+ identity)))
+ (parameterize ((%input-style (assoc-ref opts 'style))
+ (%license-prefix prefix-proc))
(match args
((spec)
(let ((name version (package-name->name+version spec)))