aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tournier <zimon.toutoune@gmail.com>2023-04-24 17:51:18 +0200
committerLudovic Courtès <ludo@gnu.org>2023-04-30 23:08:06 +0200
commit03856dce4ed1d3f76978f7e88bbf2012a4539d1b (patch)
tree2970a99e022104b68c934f284fc1ad8efe4f3b50
parent7f917fefab3098914bb41518edc0d6968205b66b (diff)
downloadguix-03856dce4ed1d3f76978f7e88bbf2012a4539d1b.tar
guix-03856dce4ed1d3f76978f7e88bbf2012a4539d1b.tar.gz
scripts: import: crate: Handle non-existent package.
Fixes <https://bugs/gnu.org/63020>. * guix/scripts/import/crate.scm (guix-import-crate): Handle non-existent package input. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/scripts/import/crate.scm20
1 files changed, 11 insertions, 9 deletions
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 97152904ac..038faa87db 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -90,15 +91,16 @@ Import and convert the crates.io package for PACKAGE-NAME.\n"))
(define-values (name version)
(package-name->name+version spec))
- (if (assoc-ref opts 'recursive)
- (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)))
- (list sexp))))
+ (match (if (assoc-ref opts 'recursive)
+ (crate-recursive-import name #:version version)
+ (crate->guix-package name #:version version #:include-dev-deps? #t))
+ ((or #f '())
+ (leave (G_ "failed to download meta-data for package '~a'~%")
+ (if version
+ (string-append name "@" version)
+ name)))
+ ((? list? sexps) sexps)
+ (sexp (list sexp))))
(()
(leave (G_ "too few arguments~%")))
((many ...)