summaryrefslogtreecommitdiff
path: root/guix/scripts/import
diff options
context:
space:
mode:
Diffstat (limited to 'guix/scripts/import')
-rw-r--r--guix/scripts/import/cran.scm46
-rw-r--r--guix/scripts/import/crate.scm15
-rw-r--r--guix/scripts/import/elpa.scm19
-rw-r--r--guix/scripts/import/opam.scm10
4 files changed, 51 insertions, 39 deletions
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index d6f371ef3a..4767bc082d 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2015, 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -66,6 +67,10 @@ 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 '(#\s "style") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'style (string->symbol arg)
+ (alist-delete 'style result))))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
@@ -92,21 +97,24 @@ Import and convert the CRAN package for PACKAGE-NAME.\n"))
value)
(_ #f))
(reverse opts))))
- (match args
- ((package-name)
- (if (assoc-ref opts 'recursive)
- ;; Recursive import
- (map package->definition
- (cran-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 (G_ "failed to download description for package '~a'~%")
- package-name))
- sexp)))
- (()
- (leave (G_ "too few arguments~%")))
- ((many ...)
- (leave (G_ "too many arguments~%"))))))
+ (parameterize ((%input-style (assoc-ref opts 'style)))
+ (match args
+ ((package-name)
+ (if (assoc-ref opts 'recursive)
+ ;; Recursive import
+ (with-error-handling
+ (map package->definition
+ (filter identity
+ (cran-recursive-import package-name
+ #:repo (or (assoc-ref opts 'repo) 'cran)))))
+ ;; Single import
+ (let ((sexp (cran->guix-package package-name
+ #:repo (or (assoc-ref opts 'repo) 'cran))))
+ (unless sexp
+ (leave (G_ "failed to download description for package '~a'~%")
+ package-name))
+ sexp)))
+ (()
+ (leave (G_ "too few arguments~%")))
+ ((many ...)
+ (leave (G_ "too many arguments~%")))))))
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index d834518c18..3a96defb86 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -2,7 +2,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2016 David Craven <david@craven.ch>
-;;; Copyright © 2019 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -42,7 +42,7 @@
(define (show-help)
(display (G_ "Usage: guix import crate PACKAGE-NAME
-Import and convert the crate.io package for PACKAGE-NAME.\n"))
+Import and convert the crates.io package for PACKAGE-NAME.\n"))
(display (G_ "
-r, --recursive import packages recursively"))
(newline)
@@ -95,19 +95,14 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(package-name->name+version spec))
(if (assoc-ref opts 'recursive)
- (map (match-lambda
- ((and ('package ('name name) . rest) pkg)
- `(define-public ,(string->symbol name)
- ,pkg))
- (_ #f))
- (crate-recursive-import name version))
- (let ((sexp (crate->guix-package name version)))
+ (crate-recursive-import name #:version version)
+ (let ((sexp (crate->guix-package name #:version version #:include-dev-deps? #t)))
(unless sexp
(leave (G_ "failed to download meta-data for package '~a'~%")
(if version
(string-append name "@" version)
name)))
- sexp)))
+ (list sexp))))
(()
(leave (G_ "too few arguments~%")))
((many ...)
diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index d270d2b4bc..d6b38e5c4b 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -95,14 +96,16 @@ Import the latest package named PACKAGE-NAME from an ELPA repository.\n"))
(match args
((package-name)
(if (assoc-ref opts 'recursive)
- (map (match-lambda
- ((and ('package ('name name) . rest) pkg)
- `(define-public ,(string->symbol name)
- ,pkg))
- (_ #f))
- (elpa-recursive-import package-name
- (or (assoc-ref opts 'repo) 'gnu)))
- (let ((sexp (elpa->guix-package package-name (assoc-ref opts 'repo))))
+ (with-error-handling
+ (map (match-lambda
+ ((and ('package ('name name) . rest) pkg)
+ `(define-public ,(string->symbol name)
+ ,pkg))
+ (_ #f))
+ (elpa-recursive-import package-name
+ (or (assoc-ref opts 'repo) 'gnu))))
+ (let ((sexp (elpa->guix-package package-name
+ #:repo (assoc-ref opts 'repo))))
(unless sexp
(leave (G_ "failed to download package '~a'~%") package-name))
sexp)))
diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm
index 20da1437fe..da9392821c 100644
--- a/guix/scripts/import/opam.scm
+++ b/guix/scripts/import/opam.scm
@@ -45,6 +45,8 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(display (G_ "
-r, --recursive import packages recursively"))
(display (G_ "
+ --repo import packages from this opam repository"))
+ (display (G_ "
-V, --version display version information and exit"))
(newline)
(show-bug-report-information))
@@ -58,6 +60,9 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(option '(#\V "version") #f #f
(lambda args
(show-version-and-exit "guix import opam")))
+ (option '(#f "repo") #t #f
+ (lambda (opt name arg result)
+ (alist-cons 'repo arg result)))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
@@ -79,6 +84,7 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
%default-options))
(let* ((opts (parse-options))
+ (repo (and=> (assoc-ref opts 'repo) string->symbol))
(args (filter-map (match-lambda
(('argument . value)
value)
@@ -93,9 +99,9 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
`(define-public ,(string->symbol name)
,pkg))
(_ #f))
- (opam-recursive-import package-name))
+ (opam-recursive-import package-name #:repo repo))
;; Single import
- (let ((sexp (opam->guix-package package-name)))
+ (let ((sexp (opam->guix-package package-name #:repo repo)))
(unless sexp
(leave (G_ "failed to download meta-data for package '~a'~%")
package-name))