1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

import: elpa: Gracefully handle invalid ELPA version lists.

Previously version lists containing zeroes would be rejected; furthermore, #f
would be returned even though callers expect a string:

  $ guix refresh emacs-counsel
  guix refresh: Package version for counsel contains non numeric part.
  Backtrace:
  […]
  In guix/utils.scm:
     925:32  5 (_ #f "0.15.1")
  In unknown file:
	     4 (string->pointer #f #<undefined>)
  […]
  guix/ui.scm:920:18: In procedure string->pointer: Wrong type argument in position 1 (expecting string): #f

* guix/import/elpa.scm (elpa-version->string): Accept zeroes in
‘elpa-version’.  Raise an error instead of returning #f on failure.  Clarify
error messages.

Change-Id: I1ab1d6892b434747d91e9090bb5f2f3c93f1ee92
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #7484
This commit is contained in:
Ludovic Courtès
2026-03-26 09:18:05 +01:00
parent 0a8acc0059
commit 365dbc5b1c

View File

@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2015-2018, 2020-2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015-2018, 2020-2021, 2023, 2026 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
@@ -183,18 +183,21 @@ REPO."
(define (elpa-version->string elpa-version repo name)
"Convert the package version as used in Emacs package files into a string."
(if (pair? elpa-version)
(if (every positive? elpa-version)
(if (every (cut >= <> 0) elpa-version)
(let-values (((ms rest) (match elpa-version
((ms . rest)
(values ms rest)))))
(fold (lambda (n s) (string-append s "." (number->string n)))
(number->string ms) rest))
(begin
(info (G_ "Package version for ~s contains non numeric part.~%") name)
(if (eq? 'gnu-devel repo)
(version-from-elpa-devel-feed name)
#f)))
#f))
(if (eq? 'gnu-devel repo)
(version-from-elpa-devel-feed name)
(raise
(formatted-message
(G_ "invalid ELPA package version ~s for '~a'")
elpa-version name))))
(raise (formatted-message
(G_ "invalid ELPA package version ~s for '~a' in repository '~a'")
elpa-version repo name))))
(define (package-home-page alist)
"Extract the package home-page from ALIST."