From 5278cab3dc001b371e1ed2f920b7f0c5678938e3 Mon Sep 17 00:00:00 2001 From: zimoun Date: Tue, 19 Jan 2021 16:47:21 +0100 Subject: scripts: import: gem: Fix recursive error handling. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partly fixes . * guix/scripts/import/gem.scm (guix-import-gem): Handle error. Signed-off-by: Ludovic Courtès --- guix/scripts/import/gem.scm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm index 328d20b946..82deac16ad 100644 --- a/guix/scripts/import/gem.scm +++ b/guix/scripts/import/gem.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2018 Oleg Pykhalov ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,24 +81,26 @@ Import and convert the RubyGems package for PACKAGE-NAME.\n")) (let* ((opts (parse-options)) (args (filter-map (match-lambda - (('argument . value) - value) - (_ #f)) + (('argument . value) + value) + (_ #f)) (reverse opts)))) (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)) - (gem-recursive-import package-name 'rubygems)) - (let ((sexp (gem->guix-package package-name))) - (unless sexp - (leave (G_ "failed to download meta-data for package '~a'~%") - package-name)) - sexp))) + (let ((code (if (assoc-ref opts 'recursive) + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (gem-recursive-import package-name 'rubygems)) + (let ((sexp (gem->guix-package package-name))) + (if sexp sexp #f))))) + (match code + ((or #f '(#f)) + (leave (G_ "failed to download meta-data for package '~a'~%") + package-name)) + (_ code)))) (() (leave (G_ "too few arguments~%"))) ((many ...) -- cgit v1.2.3