diff options
author | Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> | 2016-05-17 16:41:13 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2016-12-17 19:13:41 +0100 |
commit | 64ce53eb5e8347e93574bf02e183d668c33e250c (patch) | |
tree | 25dcd8ce2641028d2c32eabef798368a88a9b46a | |
parent | 94e907b96252bda6bbf49552b89928f337aadcfd (diff) | |
download | guix-64ce53eb5e8347e93574bf02e183d668c33e250c.tar.gz guix-64ce53eb5e8347e93574bf02e183d668c33e250c.zip |
import cran: Add "recursive" option.
* guix/scripts/import/cran.scm: (%options): Add "recursive" option.
(guix-import-cran): Handle "recursive" option.
* doc/guix.texi (Invoking guix import): Document it.
-rw-r--r-- | doc/guix.texi | 4 | ||||
-rw-r--r-- | guix/scripts/import/cran.scm | 26 |
2 files changed, 24 insertions, 6 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index bd782cab03..5d3a1753bf 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5148,6 +5148,10 @@ R package: guix import cran Cairo @end example +When @code{--recursive} is added, the importer will traverse the +dependency graph of the given upstream package recursively and generate +package expressions for all those packages that are not yet in Guix. + When @code{--archive=bioconductor} is added, metadata is imported from @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R packages for for the analysis and comprehension of high-throughput diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index ace1123b90..66c660ae14 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -26,6 +26,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-41) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (guix-import-cran)) @@ -63,6 +64,9 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) (lambda (opt name arg result) (alist-cons 'repo (string->symbol arg) (alist-delete 'repo result)))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) %standard-import-options)) @@ -88,12 +92,22 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) (reverse opts)))) (match args ((package-name) - (let ((sexp (cran->guix-package package-name - (or (assoc-ref opts 'repo) 'cran)))) - (unless sexp - (leave (_ "failed to download description for package '~a'~%") - package-name)) - sexp)) + (if (assoc-ref opts 'recursive) + ;; Recursive import + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (stream->list (recursive-import package-name + (or (assoc-ref opts 'repo) 'cran)))) + ;; Single import + (let ((sexp (cran->guix-package package-name + (or (assoc-ref opts 'repo) 'cran)))) + (unless sexp + (leave (_ "failed to download description for package '~a'~%") + package-name)) + sexp))) (() (leave (_ "too few arguments~%"))) ((many ...) |