installer: Factorize url-alive? in internet check.

* gnu/installer/newt/network.scm (wait-service-online): Factorize url-alive?
in internet check.
This commit is contained in:
Andrew Tropin 2022-10-17 16:26:19 +04:00
parent 3ab14386cd
commit 883fb8f41b
No known key found for this signature in database
GPG key ID: 2208D20958C1DEB0

View file

@ -115,6 +115,11 @@ (define (wait-technology-powered technology)
(define (wait-service-online)
"Display a newt scale until connman detects an Internet access. Do
FULL-VALUE tentatives, spaced by 1 second."
(define (url-alive? url)
(false-if-exception
(= (response-code (http-request url))
200)))
(define (ci-available?)
(dynamic-wind
(lambda ()
@ -122,15 +127,8 @@ (define (ci-available?)
(lambda _ #f))
(alarm 3))
(lambda ()
(or
(false-if-exception
(= (response-code
(http-request "https://ci.guix.gnu.org"))
200))
(false-if-exception
(= (response-code
(http-request "https://bordeaux.guix.gnu.org"))
200))))
(or (url-alive? "https://ci.guix.gnu.org")
(url-alive? "https://bordeaux.guix.gnu.org")))
(lambda ()
(alarm 0))))