summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix/import/elpa.scm49
1 files changed, 41 insertions, 8 deletions
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index bb7d50dff8b..9f0a8a0adcf 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -10,6 +10,7 @@
10;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com> 10;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
11;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr> 11;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
12;;; Copyright © 2025 jgart <jgart@dismail.de> 12;;; Copyright © 2025 jgart <jgart@dismail.de>
13;;; Copyright © 2026 Yarl Baudig <yarl-baudig@mailoo.org>
13;;; 14;;;
14;;; This file is part of GNU Guix. 15;;; This file is part of GNU Guix.
15;;; 16;;;
@@ -30,6 +31,8 @@
30 #:use-module (ice-9 match) 31 #:use-module (ice-9 match)
31 #:use-module (ice-9 rdelim) 32 #:use-module (ice-9 rdelim)
32 #:use-module (ice-9 regex) 33 #:use-module (ice-9 regex)
34 #:use-module ((sxml simple) #:select (xml->sxml))
35 #:use-module ((sxml xpath) #:select (sxpath))
33 #:use-module (web uri) 36 #:use-module (web uri)
34 #:use-module (srfi srfi-1) 37 #:use-module (srfi srfi-1)
35 #:use-module (srfi srfi-9) 38 #:use-module (srfi srfi-9)
@@ -153,14 +156,44 @@ REPO."
153 (elpa-package-name package) 156 (elpa-package-name package)
154 (elpa-package-version package)))) 157 (elpa-package-version package))))
155 158
156(define (elpa-version->string elpa-version) 159
160(define (version-from-elpa-devel-feed name)
161 (define rgx
162 (make-regexp
163 (string-append "tag:elpa[.]gnu[.]org/?,"
164 "[0-9]{4}-[0-9]{2}-[0-9]{2}:((nongnu-)?(devel|packages))/"
165 (regexp-quote name)
166 "[.]xml#v(.*)")))
167 (define url (string-append (elpa-url 'gnu-devel) "/" name ".xml"))
168 (info (G_ "Trying to figure out version using ~s.~%") url)
169 (match
170 (call-with-downloaded-file
171 url
172 (lambda (port)
173 (false-if-exception
174 (let ((sxml (xml->sxml port
175 #:namespaces '((atom . "http://www.w3.org/2005/Atom"))
176 #:trim-whitespace? #t)))
177 (match:substring
178 (regexp-exec rgx (last ((sxpath '(// atom:entry atom:id *text*)) sxml)))
179 4)))))
180 (#f (leave (G_ "Failed to get version for ~s.~%") name))
181 (v v)))
182
183(define (elpa-version->string elpa-version repo name)
157 "Convert the package version as used in Emacs package files into a string." 184 "Convert the package version as used in Emacs package files into a string."
158 (if (pair? elpa-version) 185 (if (pair? elpa-version)
159 (let-values (((ms rest) (match elpa-version 186 (if (every positive? elpa-version)
160 ((ms . rest) 187 (let-values (((ms rest) (match elpa-version
161 (values ms rest))))) 188 ((ms . rest)
162 (fold (lambda (n s) (string-append s "." (number->string n))) 189 (values ms rest)))))
163 (number->string ms) rest)) 190 (fold (lambda (n s) (string-append s "." (number->string n)))
191 (number->string ms) rest))
192 (begin
193 (info (G_ "Package version for ~s contains non numeric part.~%") name)
194 (if (eq? 'gnu-devel repo)
195 (version-from-elpa-devel-feed name)
196 #f)))
164 #f)) 197 #f))
165 198
166(define (package-home-page alist) 199(define (package-home-page alist)
@@ -201,7 +234,7 @@ include VERSION."
201 (match pkg 234 (match pkg
202 ((name version reqs synopsis kind . rest) 235 ((name version reqs synopsis kind . rest)
203 (let* ((name (symbol->string name)) 236 (let* ((name (symbol->string name))
204 (ver (elpa-version->string version)) 237 (ver (elpa-version->string version repo name))
205 (url (package-source-url kind name ver repo))) 238 (url (package-source-url kind name ver repo)))
206 (make-elpa-package name ver 239 (make-elpa-package name ver
207 (ensure-list reqs) synopsis kind 240 (ensure-list reqs) synopsis kind
@@ -424,7 +457,7 @@ type '<elpa-package>'."
424 (info 457 (info
425 (let* ((version (match info 458 (let* ((version (match info
426 ((name raw-version . _) 459 ((name raw-version . _)
427 (elpa-version->string raw-version)))) 460 (elpa-version->string raw-version repo name))))
428 (url (match info 461 (url (match info
429 ((_ raw-version reqs synopsis kind . rest) 462 ((_ raw-version reqs synopsis kind . rest)
430 (package-source-url kind name version repo)))) 463 (package-source-url kind name version repo))))