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.
This commit is contained in:
Ricardo Wurmus 2016-05-17 16:41:13 +02:00 committed by Ricardo Wurmus
parent 94e907b962
commit 64ce53eb5e
No known key found for this signature in database
GPG key ID: 197A5888235FACAC
2 changed files with 24 additions and 6 deletions

View file

@ -5148,6 +5148,10 @@ R package:
guix import cran Cairo guix import cran Cairo
@end example @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 When @code{--archive=bioconductor} is added, metadata is imported from
@uref{http://www.bioconductor.org/, Bioconductor}, a repository of R @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R
packages for for the analysis and comprehension of high-throughput packages for for the analysis and comprehension of high-throughput

View file

@ -26,6 +26,7 @@ (define-module (guix scripts import cran)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-11) #:use-module (srfi srfi-11)
#:use-module (srfi srfi-37) #:use-module (srfi srfi-37)
#:use-module (srfi srfi-41)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:export (guix-import-cran)) #:export (guix-import-cran))
@ -63,6 +64,9 @@ (define %options
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'repo (string->symbol arg) (alist-cons 'repo (string->symbol arg)
(alist-delete 'repo result)))) (alist-delete 'repo result))))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
%standard-import-options)) %standard-import-options))
@ -88,12 +92,22 @@ (define (parse-options)
(reverse opts)))) (reverse opts))))
(match args (match args
((package-name) ((package-name)
(let ((sexp (cran->guix-package package-name (if (assoc-ref opts 'recursive)
(or (assoc-ref opts 'repo) 'cran)))) ;; Recursive import
(unless sexp (map (match-lambda
(leave (_ "failed to download description for package '~a'~%") ((and ('package ('name name) . rest) pkg)
package-name)) `(define-public ,(string->symbol name)
sexp)) ,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~%"))) (leave (_ "too few arguments~%")))
((many ...) ((many ...)