summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-07-12 22:59:33 +0200
committerLudovic Courtès <ludo@gnu.org>2013-07-12 22:59:33 +0200
commite3ccdf9e963c1ec00f8dcf8cc859ab4615b978c4 (patch)
treef149fa15037b8db4b0af8a537161333ec0443cd4
parent1f495e04c16836c825618af815d4b17f93a6193a (diff)
guix package: Reuse FTP connections for subsequent `latest-release' calls.
* guix/gnu-maintenance.scm (latest-release): Add `ftp-close' and `ftp-open' keyword parameters. * guix/scripts/package.scm (ftp-open*): New variable. (check-package-freshness): Call `latest-release' with `ftp-open*' and a no-op procedure.
-rw-r--r--guix/gnu-maintenance.scm6
-rw-r--r--guix/scripts/package.scm11
2 files changed, 14 insertions, 3 deletions
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 178d26ef57b..06baa1e97ba 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -252,8 +252,10 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
252 files) 252 files)
253 result)))))))) 253 result))))))))
254 254
255(define (latest-release project) 255(define* (latest-release project
256 "Return (\"FOO-X.Y\" . \"/bar/foo\") or #f." 256 #:key (ftp-open ftp-open) (ftp-close ftp-close))
257 "Return (\"FOO-X.Y\" . \"/bar/foo\") or #f. Use FTP-OPEN and FTP-CLOSE to
258open (resp. close) FTP connections; this can be useful to reuse connections."
257 (define (latest a b) 259 (define (latest a b)
258 (if (version>? a b) a b)) 260 (if (version>? a b) a b))
259 261
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 11301ccff28..25ff008246a 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -26,6 +26,7 @@
26 #:use-module (guix utils) 26 #:use-module (guix utils)
27 #:use-module (guix config) 27 #:use-module (guix config)
28 #:use-module ((guix build utils) #:select (directory-exists? mkdir-p)) 28 #:use-module ((guix build utils) #:select (directory-exists? mkdir-p))
29 #:use-module ((guix ftp-client) #:select (ftp-open))
29 #:use-module (ice-9 ftw) 30 #:use-module (ice-9 ftw)
30 #:use-module (ice-9 format) 31 #:use-module (ice-9 format)
31 #:use-module (ice-9 match) 32 #:use-module (ice-9 match)
@@ -323,6 +324,12 @@ return its return value."
323 (format (current-error-port) " interrupted by signal ~a~%" SIGINT) 324 (format (current-error-port) " interrupted by signal ~a~%" SIGINT)
324 #f)))) 325 #f))))
325 326
327(define ftp-open*
328 ;; Memoizing version of `ftp-open'. The goal is to avoid initiating a new
329 ;; FTP connection for each package, esp. since most of them are to the same
330 ;; server. This has a noticeable impact when doing "guix upgrade -u".
331 (memoize ftp-open))
332
326(define (check-package-freshness package) 333(define (check-package-freshness package)
327 "Check whether PACKAGE has a newer version available upstream, and report 334 "Check whether PACKAGE has a newer version available upstream, and report
328it." 335it."
@@ -333,7 +340,9 @@ it."
333 (when (false-if-exception (gnu-package? package)) 340 (when (false-if-exception (gnu-package? package))
334 (let ((name (package-name package)) 341 (let ((name (package-name package))
335 (full-name (package-full-name package))) 342 (full-name (package-full-name package)))
336 (match (waiting (latest-release name) 343 (match (waiting (latest-release name
344 #:ftp-open ftp-open*
345 #:ftp-close (const #f))
337 (_ "looking for the latest release of GNU ~a...") name) 346 (_ "looking for the latest release of GNU ~a...") name)
338 ((latest-version . _) 347 ((latest-version . _)
339 (when (version>? latest-version full-name) 348 (when (version>? latest-version full-name)