[PATCH 0/2] Fix return code of "guix import elpa"

  • Done
  • quality assurance status badge
Details
2 participants
  • Josselin Poiret
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal
S
S
Simon Tournier wrote on 15 May 2023 19:44
(address . guix-patches@gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
cover.1684171669.git.zimon.toutoune@gmail.com
Hi,

This fixes issue #58308 [1]:

Toggle snippet (11 lines)
$ ./pre-inst-env guix import elpa syslog
guix import: error: failed to download meta-data for package 'syslog'
$ echo $?
1

$ ./pre-inst-env guix import elpa syslog -r
guix import: error: failed to download meta-data for package 'syslog'
$ echo $?
1

In addition, since Elpa importer does not support the specification of the
version, the first patch warns about that:

Toggle snippet (8 lines)
$ ./pre-inst-env guix import elpa -a melpa magit@12
guix import: warning: this importer does not consider the version
(package
((name "emacs-magit")
(version "20230510.2139")
[...]



Cheers,
simon


Simon Tournier (2):
scripts: import: elpa: Warn when version is specified.
scripts: import: elpa: Return consistent error code.

guix/scripts/import/elpa.scm | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)


base-commit: 6e38ec447f98383e0722ac300734f8d7c8c5c7b0
--
2.38.1
S
S
Simon Tournier wrote on 15 May 2023 19:45
[PATCH 1/2] scripts: import: elpa: Warn when version is specified.
(address . 63522@debbugs.gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
86cc82e9e87b1591de67d4c808c80345df7cbcb8.1684171669.git.zimon.toutoune@gmail.com
* guix/scripts/import/elpa.scm (guix-import-elpa): Warn when version is
specified.
---
guix/scripts/import/elpa.scm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Toggle diff (27 lines)
diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index 052b0cc0e7..a71478d3c8 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 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.
;;;
@@ -91,7 +92,11 @@ (define (guix-import-elpa . args)
(_ #f))
(reverse opts))))
(match args
- ((package-name)
+ ((spec)
+ (define-values (package-name version)
+ (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
--
2.38.1
S
S
Simon Tournier wrote on 15 May 2023 19:45
[PATCH 2/2] scripts: import: elpa: Return consistent error code.
(address . 63522@debbugs.gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
ccbc0c1c2d5901e494d26299b1451ecc0176bc7a.1684171669.git.zimon.toutoune@gmail.com
Reported by Ricardo Wurmus.

* guix/scripts/import/elpa.scm (guix-import-elpa): Return consistent error
code independently of the 'recursive' option.
---
guix/scripts/import/elpa.scm | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)

Toggle diff (41 lines)
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 @@ (define (guix-import-elpa . args)
(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 ...)
--
2.38.1
J
J
Josselin Poiret wrote on 17 May 2023 23:27
Re: [bug#63522] [PATCH 0/2] Fix return code of "guix import elpa"
87bkii1wdo.fsf@jpoiret.xyz
Hi Simon,

Simon Tournier <zimon.toutoune@gmail.com> writes:

Toggle quote (7 lines)
> Simon Tournier (2):
> scripts: import: elpa: Warn when version is specified.
> scripts: import: elpa: Return consistent error code.
>
> guix/scripts/import/elpa.scm | 34 ++++++++++++++++++++--------------
> 1 file changed, 20 insertions(+), 14 deletions(-)

LGTM, applied as d81701a85aa8aa96f4a853f06fe28693fa8bee12.

Thanks!

Best,
--
Josselin Poiret
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmRlRtMQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcaikT3C/0e/YJRVdvwrTLvGtJXaIidPpkR+lZ2P+W8
s3wsg2MF5l1E/1vFf++e9ztPVr/PS8Rkiiu5hSzOdaCe1j5YnsZwGY1HvOHWPdRa
phvlxWRRcrAkJAlet6nqCDsjDo9VC2kKSiP+l3XffGaBQG/HkphyZuCGdgfRlgT2
i7A9WbQNXFw3FlgkUu9t/3qiMoTFzjnZLd8n9gvjIV1QhRs1vlOjtsrTznAU9jIJ
qPiwkgtD5JEd6Z7jOzw/y/PDwZoP09goqWjTy0+9MHItoZvqlCh0fjadJGJky8dy
lSgDuG6GcQwEID+Q9gqDaHmOzMHcaSRdF3Gr22wLaKVTwtSVcHRnlgIfYdSwcisN
Ud1V75UZMS3+/RStw230Y+IaWhHDyXnnb4U5HoX7ZKu/z3joLhlZnWU6t2g4S9q+
7apLRT/WLyjvvPmxWkU2JFxS2qPhwaCmiMowtfzrTFyHBJLKdpnjT5tqR0a4bVGs
9SfqbmerBIoVqEWyVI4Wzylno2rT2NQ=
=5zWs
-----END PGP SIGNATURE-----

J
J
Josselin Poiret wrote on 17 May 2023 23:28
(address . control@debbugs.gnu.org)
878rdm1wc7.fsf@jpoiret.xyz
close 63522
thankyou


--
Josselin Poiret
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmRlRwgQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcaiuTfC/4lMsxN/C/PhbDBZtJru4UAqJ0q3HY+mFdk
a/uolPRbsDab8pyLHvHgYkazGo+j5XqQHIPs/6TT0YJyyMzlQNb47ixPs1Yr5/sq
y81l1EfnuIEFcRjUbzTkaPGOrcF2CshkaH/a5kjwP9lZLUcmdhl6kqm/Me6ZIclS
2ONNmFVFQX9SIflCcN7ysYaxDIOoJxw7fRU5Dj4YihHPOn8IwfTjhhAWU97eqFMs
FoNJnI8i9iYKHsEyQx6dc+BYjAXv00b1UBYckF/pnLL4iD6vlGSi7EqecK1Byl4O
MKfKKS19gFv+XEY1DjNpON7juKMDyoXWl4CiTNGhwrvaBpTRk2TzJ6QVdcfGxPqj
YfgTdqqNFGkn3yJHooHLmd0G7IKgAZ9jPn5YkSDygK2rRaLNik2E3DUyRa+LrmId
lWfWFrrxg918hk2JYXnbNlN0TcdFp8z0J6XRuUJZqfOLPY+iPjJF1tF+yUap8TNI
ODzJWcQimQ2A+dOviv6OIKwKRoZPss4=
=WPyw
-----END PGP SIGNATURE-----

?