diff options
| author | zero@fedora <zero@fedora> | 2024-01-10 04:29:56 +0300 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2024-11-23 16:23:19 +0100 |
| commit | 2d3bf6a2a33fae685c03320f289d73ba3e7275f6 (patch) | |
| tree | 485b1c0f6ab90cbd39b5458abc1049a1ac9f1e02 /guix/scripts/import | |
| parent | ea5ee89274d47d06d05feed927c0eb50ae316db3 (diff) | |
import: cpan: Support recursive imports.
* guix/import/cpan.scm (cpan-module->sexp): Return two values.
(cpan->guix-package): Add #:version. Return two values.
(cpan-recursive-import): New procedure.
* guix/scripts/import/cpan.scm (show-help, %options): Add ‘-r’.
(guix-import-cpan): Adjust accordingly.
Change-Id: Id167c7ddd079f4e04650ce7cc1692a9de36cd8fe
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/scripts/import')
| -rw-r--r-- | guix/scripts/import/cpan.scm | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm index bdf5a1e423..4ddd85ee57 100644 --- a/guix/scripts/import/cpan.scm +++ b/guix/scripts/import/cpan.scm @@ -44,6 +44,8 @@ Import and convert the CPAN package for PACKAGE-NAME.\n")) (display (G_ " -h, --help display this help and exit")) (display (G_ " + -r, --recursive import missing packages recursively")) + (display (G_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) @@ -54,6 +56,9 @@ Import and convert the CPAN package for PACKAGE-NAME.\n")) (lambda args (show-help) (exit 0))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix import cpan"))) @@ -78,11 +83,20 @@ Import and convert the CPAN package for PACKAGE-NAME.\n")) (reverse opts)))) (match args ((package-name) - (let ((sexp (cpan->guix-package package-name))) - (unless sexp - (leave (G_ "failed to download meta-data for package '~a'~%") - package-name)) - sexp)) + (let ((sexp + (if (assoc-ref opts 'recursive) + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (cpan-recursive-import package-name)) + (let ((sexp (cpan->guix-package package-name))) + sexp)))) + (unless sexp + (leave (G_ "failed to download meta-data for package '~a'~%") + package-name)) + sexp)) (() (leave (G_ "too few arguments~%"))) ((many ...) |
