gnu-maintenance: Generalize 'latest-ftp-release'.

* guix/gnu-maintenance.scm (latest-release): Rename to...
(latest-ftp-release): ... this.  Add #:server and #:directory
parameters.
(latest-release): New procedure.
This commit is contained in:
Ludovic Courtès 2015-12-07 23:18:06 +01:00
parent fba607b129
commit e946f2ec92
1 changed files with 68 additions and 55 deletions

View File

@ -317,10 +317,14 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
files)
result))))))))
(define* (latest-release project
#:key (ftp-open ftp-open) (ftp-close ftp-close))
"Return (\"FOO-X.Y\" . \"/bar/foo\") or #f. Use FTP-OPEN and FTP-CLOSE to
open (resp. close) FTP connections; this can be useful to reuse connections."
(define* (latest-ftp-release project
#:key
(server "ftp.gnu.org")
(directory (string-append "/gnu/" project))
(ftp-open ftp-open) (ftp-close ftp-close))
"Return an <upstream-source> for the latest release of PROJECT on SERVER
under DIRECTORY, or #f. Use FTP-OPEN and FTP-CLOSE to open (resp. close) FTP
connections; this can be useful to reuse connections."
(define (latest a b)
(if (version>? a b) a b))
@ -335,7 +339,6 @@ open (resp. close) FTP connections; this can be useful to reuse connections."
;; Return #t for patch directory names such as 'bash-4.2-patches'.
(cut string-suffix? "patches" <>))
(let-values (((server directory) (ftp-server/directory project)))
(define conn (ftp-open server))
(define (file->url directory file)
@ -391,7 +394,17 @@ open (resp. close) FTP connections; this can be useful to reuse connections."
result)
(begin
(ftp-close conn)
result)))))))
result))))))
(define (latest-release package . rest)
"Return the <upstream-source> for the latest version of PACKAGE or #f.
PACKAGE is the name of a GNU package. This procedure automatically uses the
right FTP server and directory for PACKAGE."
(let-values (((server directory) (ftp-server/directory package)))
(apply latest-ftp-release package
#:server server
#:directory directory
rest)))
(define (latest-release* package)
"Like 'latest-release', but ignore FTP errors that might occur when PACKAGE