import: crate: Add '--recursive'.
* guix/scripts/import/crate.scm (show-help, guix-import-crate): Add '--recursive'. * doc/guix.texi (Invoking guix import): Mention '--recursive'. Co-authored-by: Ludovic Courtès <ludo@gnu.org>master
parent
f837293202
commit
ed661e38d8
|
@ -9083,6 +9083,16 @@ The crate importer also allows you to specify a version string:
|
||||||
guix import crate constant-time-eq@@0.1.0
|
guix import crate constant-time-eq@@0.1.0
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
Additional options include:
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
@item --recursive
|
||||||
|
@itemx -r
|
||||||
|
Traverse the dependency graph of the given upstream package recursively
|
||||||
|
and generate package expressions for all those packages that are not yet
|
||||||
|
in Guix.
|
||||||
|
@end table
|
||||||
|
|
||||||
@item opam
|
@item opam
|
||||||
@cindex OPAM
|
@cindex OPAM
|
||||||
@cindex OCaml
|
@cindex OCaml
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#: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-crate))
|
#:export (guix-import-crate))
|
||||||
|
@ -43,6 +44,9 @@
|
||||||
(define (show-help)
|
(define (show-help)
|
||||||
(display (G_ "Usage: guix import crate PACKAGE-NAME
|
(display (G_ "Usage: guix import crate PACKAGE-NAME
|
||||||
Import and convert the crate.io package for PACKAGE-NAME.\n"))
|
Import and convert the crate.io package for PACKAGE-NAME.\n"))
|
||||||
|
(display (G_ "
|
||||||
|
-r, --recursive import packages recursively"))
|
||||||
|
(newline)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
-h, --help display this help and exit"))
|
-h, --help display this help and exit"))
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
|
@ -59,6 +63,9 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
|
||||||
(option '(#\V "version") #f #f
|
(option '(#\V "version") #f #f
|
||||||
(lambda args
|
(lambda args
|
||||||
(show-version-and-exit "guix import crate")))
|
(show-version-and-exit "guix import crate")))
|
||||||
|
(option '(#\r "recursive") #f #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'recursive #t result)))
|
||||||
%standard-import-options))
|
%standard-import-options))
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,22 +86,31 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
|
||||||
|
|
||||||
(let* ((opts (parse-options))
|
(let* ((opts (parse-options))
|
||||||
(args (filter-map (match-lambda
|
(args (filter-map (match-lambda
|
||||||
(('argument . value)
|
(('argument . value)
|
||||||
value)
|
value)
|
||||||
(_ #f))
|
(_ #f))
|
||||||
(reverse opts))))
|
(reverse opts))))
|
||||||
(match args
|
(match args
|
||||||
((spec)
|
((spec)
|
||||||
(define-values (name version)
|
(define-values (name version)
|
||||||
(package-name->name+version spec))
|
(package-name->name+version spec))
|
||||||
|
|
||||||
(let ((sexp (crate->guix-package name version)))
|
(if (assoc-ref opts 'recursive)
|
||||||
(unless sexp
|
(map (match-lambda
|
||||||
(leave (G_ "failed to download meta-data for package '~a'~%")
|
((and ('package ('name name) . rest) pkg)
|
||||||
(if version
|
`(define-public ,(string->symbol name)
|
||||||
(string-append name "@" version)
|
,pkg))
|
||||||
name)))
|
(_ #f))
|
||||||
sexp))
|
(reverse
|
||||||
|
(stream->list
|
||||||
|
(crate-recursive-import name))))
|
||||||
|
(let ((sexp (crate->guix-package name version)))
|
||||||
|
(unless sexp
|
||||||
|
(leave (G_ "failed to download meta-data for package '~a'~%")
|
||||||
|
(if version
|
||||||
|
(string-append name "@" version)
|
||||||
|
name)))
|
||||||
|
sexp)))
|
||||||
(()
|
(()
|
||||||
(leave (G_ "too few arguments~%")))
|
(leave (G_ "too few arguments~%")))
|
||||||
((many ...)
|
((many ...)
|
||||||
|
|
Reference in New Issue