summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Buddelmeijer <hugo@buddelmeijer.nl>2025-12-18 22:33:28 +0100
committerLudovic Courtès <ludo@gnu.org>2026-03-29 22:15:30 +0200
commit3b90fc5b3cc128c1aaaaccc5ea4100c51522abf4 (patch)
treedefb2d8e12afd5ca43156f115194ad649a747c75
parent785f4c6ed9b3e7a8ff31fe7a719848b7b14ad5dc (diff)
refresh: Make --list-updaters fast if web.cvs.savannah.gnu.org is broken.
--list-updaters loops through all packages and all updaters to see whether they match. The gnu-ftp updater used to use official-gnu-packages to fetch a list of packages from web.cvs.savannah.gnu.org. official-gnu-packages only caches the result if it succeeds; but does not cache upon a timout or 5xx status. official-gnu-packages times out after a minute and is called for all 30k+ packages. refresh --list-updaters could therefore take 30000 minutes. Now --list-updaters uses official-gnu-packages* (from lint.scm) that memoizes the result also on failure, thereby limiting the time to 1 minute. * guix/gnu-maintenance.scm: Add official-gnu-packages* from guix/lint.scm. Call official-gnu-packages* from gnu-package? * guix/lint.scm: Move official-gnu-packages* to guix/gnu-maintenance.scm Change-Id: I5e2e094bfb1042b03db47e119ced0e94b49b417c Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #4949
-rw-r--r--guix/gnu-maintenance.scm95
-rw-r--r--guix/lint.scm7
2 files changed, 51 insertions, 51 deletions
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index a33f941cb80..c37baf19b77 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -61,6 +61,7 @@
61 gnu-package-download-url 61 gnu-package-download-url
62 62
63 official-gnu-packages 63 official-gnu-packages
64 official-gnu-packages*
64 find-package 65 find-package
65 gnu-package? 66 gnu-package?
66 67
@@ -181,6 +182,13 @@ to fetch the list of GNU packages over HTTP."
181 (close-port port) 182 (close-port port)
182 lst))) 183 lst)))
183 184
185(define official-gnu-packages*
186 (mlambda ()
187 "A memoizing version of 'official-gnu-packages' that returns the empty
188list when something goes wrong, such as a networking issue."
189 (let ((gnus (false-if-exception (official-gnu-packages))))
190 (or gnus '()))))
191
184(define (find-package name) 192(define (find-package name)
185 "Find GNU package called NAME and return it. Return #f if it was not 193 "Find GNU package called NAME and return it. Return #f if it was not
186found." 194found."
@@ -189,51 +197,50 @@ found."
189 (official-gnu-packages))) 197 (official-gnu-packages)))
190 198
191(define gnu-package? 199(define gnu-package?
192 (let ((official-gnu-packages (memoize official-gnu-packages))) 200 (mlambdaq (package)
193 (mlambdaq (package) 201 "Return true if PACKAGE is a GNU package. This procedure may access the
194 "Return true if PACKAGE is a GNU package. This procedure may access the
195network to check in GNU's database." 202network to check in GNU's database."
196 (define (mirror-type url) 203 (define (mirror-type url)
197 (let ((uri (string->uri url))) 204 (let ((uri (string->uri url)))
198 (and (eq? (uri-scheme uri) 'mirror) 205 (and (eq? (uri-scheme uri) 'mirror)
199 (cond 206 (cond
200 ((member (uri-host uri) 207 ((member (uri-host uri)
201 '("gnu" "gnupg" "gcc" "gnome")) 208 '("gnu" "gnupg" "gcc" "gnome"))
202 ;; Definitely GNU. 209 ;; Definitely GNU.
203 'gnu) 210 'gnu)
204 ((equal? (uri-host uri) "cran") 211 ((equal? (uri-host uri) "cran")
205 ;; Possibly GNU: mirror://cran could be either GNU R itself 212 ;; Possibly GNU: mirror://cran could be either GNU R itself
206 ;; or a non-GNU package. 213 ;; or a non-GNU package.
207 #f) 214 #f)
208 (else 215 (else
209 ;; Definitely non-GNU. 216 ;; Definitely non-GNU.
210 'non-gnu))))) 217 'non-gnu)))))
211 218
212 (define (gnu-home-page? package) 219 (define (gnu-home-page? package)
213 (letrec-syntax ((>> (syntax-rules () 220 (letrec-syntax ((>> (syntax-rules ()
214 ((_ value proc) 221 ((_ value proc)
215 (and=> value proc)) 222 (and=> value proc))
216 ((_ value proc rest ...) 223 ((_ value proc rest ...)
217 (and=> value 224 (and=> value
218 (lambda (next) 225 (lambda (next)
219 (>> (proc next) rest ...))))))) 226 (>> (proc next) rest ...)))))))
220 (>> package package-home-page 227 (>> package package-home-page
221 string->uri uri-host 228 string->uri uri-host
222 (lambda (host) 229 (lambda (host)
223 (member host '("www.gnu.org" "gnu.org")))))) 230 (member host '("www.gnu.org" "gnu.org"))))))
224 231
225 (or (gnu-home-page? package) 232 (or (gnu-home-page? package)
226 (match (package-source package) 233 (match (package-source package)
227 ((? origin? origin) 234 ((? origin? origin)
228 (let ((url (origin-uri origin)) 235 (let ((url (origin-uri origin))
229 (name (package-upstream-name package))) 236 (name (package-upstream-name package)))
230 (case (and (string? url) (mirror-type url)) 237 (case (and (string? url) (mirror-type url))
231 ((gnu) #t) 238 ((gnu) #t)
232 ((non-gnu) #f) 239 ((non-gnu) #f)
233 (else 240 (else
234 (and (member name (map gnu-package-name (official-gnu-packages))) 241 (and (member name (map gnu-package-name (official-gnu-packages*)))
235 #t))))) 242 #t)))))
236 (_ #f)))))) 243 (_ #f)))))
237 244
238 245
239;;; 246;;;
diff --git a/guix/lint.scm b/guix/lint.scm
index 99920a95d04..cfe97b21a49 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -1237,13 +1237,6 @@ upstream status")
1237 '() 1237 '()
1238 str))) 1238 str)))
1239 1239
1240(define official-gnu-packages*
1241 (mlambda ()
1242 "A memoizing version of 'official-gnu-packages' that returns the empty
1243list when something goes wrong, such as a networking issue."
1244 (let ((gnus (false-if-exception (official-gnu-packages))))
1245 (or gnus '()))))
1246
1247(define (check-gnu-synopsis+description package) 1240(define (check-gnu-synopsis+description package)
1248 "Make sure that, if PACKAGE is a GNU package, it uses the synopsis and 1241 "Make sure that, if PACKAGE is a GNU package, it uses the synopsis and
1249descriptions maintained upstream." 1242descriptions maintained upstream."