diff options
| -rw-r--r-- | gnu/installer/newt/network.scm | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/gnu/installer/newt/network.scm b/gnu/installer/newt/network.scm index c78a7c54612..08e22b8e26c 100644 --- a/gnu/installer/newt/network.scm +++ b/gnu/installer/newt/network.scm | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #:use-module (guix i18n) | 27 | #:use-module (guix i18n) |
| 28 | #:use-module (srfi srfi-1) | 28 | #:use-module (srfi srfi-1) |
| 29 | #:use-module (srfi srfi-11) | 29 | #:use-module (srfi srfi-11) |
| 30 | #:use-module (srfi srfi-26) | ||
| 30 | #:use-module (srfi srfi-34) | 31 | #:use-module (srfi srfi-34) |
| 31 | #:use-module (srfi srfi-35) | 32 | #:use-module (srfi srfi-35) |
| 32 | #:use-module (ice-9 match) | 33 | #:use-module (ice-9 match) |
| @@ -112,20 +113,24 @@ network devices were found. Do you want to continue anyway?")) | |||
| 112 | full-value | 113 | full-value |
| 113 | (+ value 1))))))) | 114 | (+ value 1))))))) |
| 114 | 115 | ||
| 115 | (define (url-alive? url) | 116 | (define* (url-alive? url #:key (ensure-ok-status? #f)) |
| 116 | (false-if-exception | 117 | (false-if-exception |
| 117 | (begin | 118 | (let ((response (http-request url))) |
| 118 | (http-request url) | 119 | (or (not ensure-ok-status?) |
| 119 | #t))) | 120 | (= (response-code response) |
| 121 | 200))))) | ||
| 120 | 122 | ||
| 121 | (define (common-urls-alive? urls) | 123 | (define* (common-urls-alive? urls #:key (ensure-ok-status? #f)) |
| 124 | "Return #t if at least some of the given URLS are alive, | ||
| 125 | meaning that they do respond to a HTTP request. If ENSURE-OK-STATUS? is | ||
| 126 | #t, return #t only if the code is 200." | ||
| 122 | (dynamic-wind | 127 | (dynamic-wind |
| 123 | (lambda () | 128 | (lambda () |
| 124 | (sigaction SIGALRM | 129 | (sigaction SIGALRM |
| 125 | (lambda _ #f)) | 130 | (lambda _ #f)) |
| 126 | (alarm 3)) | 131 | (alarm 3)) |
| 127 | (lambda () | 132 | (lambda () |
| 128 | (any url-alive? | 133 | (any (cut url-alive? <> #:ensure-ok-status? ensure-ok-status?) |
| 129 | urls)) | 134 | urls)) |
| 130 | (lambda () | 135 | (lambda () |
| 131 | (alarm 0)))) | 136 | (alarm 0)))) |
| @@ -140,7 +145,9 @@ FULL-VALUE tentatives, spaced by 1 second." | |||
| 140 | "https://bordeaux.guix.gnu.org" | 145 | "https://bordeaux.guix.gnu.org" |
| 141 | "https://ci.guix.gnu.org" | 146 | "https://ci.guix.gnu.org" |
| 142 | "https://guix.gnu.org" | 147 | "https://guix.gnu.org" |
| 143 | "https://gnu.org"))) | 148 | "https://gnu.org") |
| 149 | ;; Any HTTP response means the users is online. | ||
| 150 | #:ensure-ok-status? #f)) | ||
| 144 | (file-exists? "/tmp/installer-assume-online"))) | 151 | (file-exists? "/tmp/installer-assume-online"))) |
| 145 | 152 | ||
| 146 | (let* ((full-value 5)) | 153 | (let* ((full-value 5)) |
| @@ -173,7 +180,8 @@ Do you want to continue anyway?")) | |||
| 173 | (common-urls-alive? | 180 | (common-urls-alive? |
| 174 | (list | 181 | (list |
| 175 | "https://bordeaux.guix.gnu.org/nix-cache-info" | 182 | "https://bordeaux.guix.gnu.org/nix-cache-info" |
| 176 | "https://ci.guix.gnu.org/nix-cache-info")))) | 183 | "https://ci.guix.gnu.org/nix-cache-info") |
| 184 | #:ensure-ok-status? #t))) | ||
| 177 | 185 | ||
| 178 | (let* ((full-value 5)) | 186 | (let* ((full-value 5)) |
| 179 | (run-scale-page | 187 | (run-scale-page |
