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>
This commit is contained in:
Simon Tournier 2023-04-24 17:51:18 +02:00 committed by Ludovic Courtès
parent 7f917fefab
commit 03856dce4e
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -4,6 +4,7 @@
;;; Copyright © 2016 David Craven <david@craven.ch> ;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; 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) (define-values (name version)
(package-name->name+version spec)) (package-name->name+version spec))
(if (assoc-ref opts 'recursive) (match (if (assoc-ref opts 'recursive)
(crate-recursive-import name #:version version) (crate-recursive-import name #:version version)
(let ((sexp (crate->guix-package name #:version version #:include-dev-deps? #t))) (crate->guix-package name #:version version #:include-dev-deps? #t))
(unless sexp ((or #f '())
(leave (G_ "failed to download meta-data for package '~a'~%") (leave (G_ "failed to download meta-data for package '~a'~%")
(if version (if version
(string-append name "@" version) (string-append name "@" version)
name))) name)))
(list sexp)))) ((? list? sexps) sexps)
(sexp (list sexp))))
(() (()
(leave (G_ "too few arguments~%"))) (leave (G_ "too few arguments~%")))
((many ...) ((many ...)