guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/05: scripts: import: elpa: Return consistent error code.


From: guix-commits
Subject: 02/05: scripts: import: elpa: Return consistent error code.
Date: Wed, 17 May 2023 17:25:52 -0400 (EDT)

jpoiret pushed a commit to branch master
in repository guix.

commit d81701a85aa8aa96f4a853f06fe28693fa8bee12
Author: Simon Tournier <zimon.toutoune@gmail.com>
AuthorDate: Mon May 15 19:45:45 2023 +0200

    scripts: import: elpa: Return consistent error code.
    
    Fixes <https://bug.gnu.org/58308>.
    Reported by Ricardo Wurmus.
    
    * guix/scripts/import/elpa.scm (guix-import-elpa): Return consistent error
    code independently of the 'recursive' option.
    
    Signed-off-by: Josselin Poiret <dev@jpoiret.xyz>
---
 guix/scripts/import/elpa.scm | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index a71478d3c8..f587eeb243 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -97,20 +97,21 @@ Import the latest package named PACKAGE-NAME from an ELPA 
repository.\n"))
          (package-name->name+version spec))
        (when version
          (warning (G_ "this importer does not consider the version~%")))
-       (if (assoc-ref opts 'recursive)
-           (with-error-handling
-             (map (match-lambda
-                    ((and ('package ('name name) . rest) pkg)
-                     `(define-public ,(string->symbol name)
-                        ,pkg))
-                    (_ #f))
+       (match (if (assoc-ref opts 'recursive)
                   (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)))
+                                         (or (assoc-ref opts 'repo) 'gnu))
+                  (elpa->guix-package package-name
+                                      #:repo (assoc-ref opts 'repo)))
+         ((or #f '())
+          (leave (G_ "failed to download meta-data for package '~a'~%") 
package-name))
+         (('package etc ...) `(package ,etc))
+         ((? list? sexps) (map
+                           (match-lambda
+                             ((and ('package ('name name) . rest) pkg)
+                              `(define-public ,(string->symbol name)
+                                 ,pkg))
+                             (_ #f))
+                           sexps))))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]