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

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
This commit is contained in:
Hugo Buddelmeijer
2025-12-18 22:33:28 +01:00
committed by Ludovic Courtès
parent 785f4c6ed9
commit 3b90fc5b3c
2 changed files with 49 additions and 49 deletions

View File

@@ -61,6 +61,7 @@
gnu-package-download-url
official-gnu-packages
official-gnu-packages*
find-package
gnu-package?
@@ -181,6 +182,13 @@ to fetch the list of GNU packages over HTTP."
(close-port port)
lst)))
(define official-gnu-packages*
(mlambda ()
"A memoizing version of 'official-gnu-packages' that returns the empty
list when something goes wrong, such as a networking issue."
(let ((gnus (false-if-exception (official-gnu-packages))))
(or gnus '()))))
(define (find-package name)
"Find GNU package called NAME and return it. Return #f if it was not
found."
@@ -189,51 +197,50 @@ found."
(official-gnu-packages)))
(define gnu-package?
(let ((official-gnu-packages (memoize official-gnu-packages)))
(mlambdaq (package)
"Return true if PACKAGE is a GNU package. This procedure may access the
(mlambdaq (package)
"Return true if PACKAGE is a GNU package. This procedure may access the
network to check in GNU's database."
(define (mirror-type url)
(let ((uri (string->uri url)))
(and (eq? (uri-scheme uri) 'mirror)
(cond
((member (uri-host uri)
'("gnu" "gnupg" "gcc" "gnome"))
;; Definitely GNU.
'gnu)
((equal? (uri-host uri) "cran")
;; Possibly GNU: mirror://cran could be either GNU R itself
;; or a non-GNU package.
#f)
(else
;; Definitely non-GNU.
'non-gnu)))))
(define (mirror-type url)
(let ((uri (string->uri url)))
(and (eq? (uri-scheme uri) 'mirror)
(cond
((member (uri-host uri)
'("gnu" "gnupg" "gcc" "gnome"))
;; Definitely GNU.
'gnu)
((equal? (uri-host uri) "cran")
;; Possibly GNU: mirror://cran could be either GNU R itself
;; or a non-GNU package.
#f)
(else
;; Definitely non-GNU.
'non-gnu)))))
(define (gnu-home-page? package)
(letrec-syntax ((>> (syntax-rules ()
((_ value proc)
(and=> value proc))
((_ value proc rest ...)
(and=> value
(lambda (next)
(>> (proc next) rest ...)))))))
(>> package package-home-page
string->uri uri-host
(lambda (host)
(member host '("www.gnu.org" "gnu.org"))))))
(define (gnu-home-page? package)
(letrec-syntax ((>> (syntax-rules ()
((_ value proc)
(and=> value proc))
((_ value proc rest ...)
(and=> value
(lambda (next)
(>> (proc next) rest ...)))))))
(>> package package-home-page
string->uri uri-host
(lambda (host)
(member host '("www.gnu.org" "gnu.org"))))))
(or (gnu-home-page? package)
(match (package-source package)
((? origin? origin)
(let ((url (origin-uri origin))
(name (package-upstream-name package)))
(case (and (string? url) (mirror-type url))
((gnu) #t)
((non-gnu) #f)
(else
(and (member name (map gnu-package-name (official-gnu-packages)))
#t)))))
(_ #f))))))
(or (gnu-home-page? package)
(match (package-source package)
((? origin? origin)
(let ((url (origin-uri origin))
(name (package-upstream-name package)))
(case (and (string? url) (mirror-type url))
((gnu) #t)
((non-gnu) #f)
(else
(and (member name (map gnu-package-name (official-gnu-packages*)))
#t)))))
(_ #f)))))
;;;

View File

@@ -1237,13 +1237,6 @@ upstream status")
'()
str)))
(define official-gnu-packages*
(mlambda ()
"A memoizing version of 'official-gnu-packages' that returns the empty
list when something goes wrong, such as a networking issue."
(let ((gnus (false-if-exception (official-gnu-packages))))
(or gnus '()))))
(define (check-gnu-synopsis+description package)
"Make sure that, if PACKAGE is a GNU package, it uses the synopsis and
descriptions maintained upstream."