summaryrefslogtreecommitdiff
path: root/guix/scripts/import
diff options
context:
space:
mode:
authorMartin Becze <mjbecze@riseup.net>2019-09-09 11:36:04 -0400
committerLudovic Courtès <ludo@gnu.org>2019-09-10 00:34:40 +0200
commitfd63ecbe050bf8fa7c8ff0a003d56cce97b6ded1 (patch)
treef39aa889848227be7f1ea76d22d380d0c8c7ab9a /guix/scripts/import
parent7c101c4c175b7abcb43279d1c66b41a91b9c64bc (diff)
import: crate: Allow imports of a specific version.
* guix/import/crate.scm (crate->guix-package): Add optional 'version' argument and honor it. * guix/scripts/import/crate.scm (guix-import-crate): Assume the first argument is a spec and destructure it with 'package-name->name+version'. Pass both to 'crate->guix-package'. * doc/guix.texi (Invoking guix import): Document it. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/scripts/import')
-rw-r--r--guix/scripts/import/crate.scm13
1 files changed, 10 insertions, 3 deletions
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index cab9a4397b..7ae8638911 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -2,6 +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>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -75,6 +76,7 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(alist-cons 'argument arg result))
%default-options))
+
(let* ((opts (parse-options))
(args (filter-map (match-lambda
(('argument . value)
@@ -82,11 +84,16 @@ Import and convert the crate.io package for PACKAGE-NAME.\n"))
(_ #f))
(reverse opts))))
(match args
- ((package-name)
- (let ((sexp (crate->guix-package package-name)))
+ ((spec)
+ (define-values (name version)
+ (package-name->name+version spec))
+
+ (let ((sexp (crate->guix-package name version)))
(unless sexp
(leave (G_ "failed to download meta-data for package '~a'~%")
- package-name))
+ (if version
+ (string-append name "@" version)
+ name)))
sexp))
(()
(leave (G_ "too few arguments~%")))