Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
c4e8d513 | 2 | ;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> |
f9bbf2a8 | 3 | ;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org> |
22189ed1 | 4 | ;;; |
233e7676 | 5 | ;;; This file is part of GNU Guix. |
22189ed1 | 6 | ;;; |
233e7676 | 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
22189ed1 NK |
8 | ;;; under the terms of the GNU General Public License as published by |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
233e7676 | 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
22189ed1 NK |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
22189ed1 NK |
19 | |
20 | (define-module (guix gnu-maintenance) | |
21 | #:use-module (web uri) | |
22 | #:use-module (web client) | |
23 | #:use-module (web response) | |
24 | #:use-module (ice-9 regex) | |
98fefb21 | 25 | #:use-module (ice-9 match) |
22189ed1 NK |
26 | #:use-module (srfi srfi-1) |
27 | #:use-module (srfi srfi-11) | |
28 | #:use-module (srfi srfi-26) | |
98fefb21 | 29 | #:use-module (system foreign) |
3b8258c5 | 30 | #:use-module (guix http-client) |
98fefb21 | 31 | #:use-module (guix ftp-client) |
0d1e6ce4 | 32 | #:use-module (guix utils) |
c0cd1b3e | 33 | #:use-module (guix records) |
0a7c5a09 | 34 | #:use-module (guix upstream) |
ef010c0f | 35 | #:use-module (guix packages) |
f9bbf2a8 NK |
36 | #:export (gnu-package-name |
37 | gnu-package-mundane-name | |
38 | gnu-package-copyright-holder | |
39 | gnu-package-savannah | |
40 | gnu-package-fsd | |
41 | gnu-package-language | |
42 | gnu-package-logo | |
43 | gnu-package-doc-category | |
44 | gnu-package-doc-summary | |
c4ca9411 | 45 | gnu-package-doc-description |
f9bbf2a8 NK |
46 | gnu-package-doc-urls |
47 | gnu-package-download-url | |
48 | ||
49 | official-gnu-packages | |
50 | find-packages | |
ef010c0f | 51 | gnu-package? |
f9bbf2a8 | 52 | |
202440e0 | 53 | release-file? |
98fefb21 LC |
54 | releases |
55 | latest-release | |
7047133f | 56 | gnu-release-archive-types |
0fdd3bea | 57 | gnu-package-name->name+version |
7047133f | 58 | |
e80c0f85 | 59 | %gnu-updater |
62061d6b AW |
60 | %gnome-updater |
61 | %xorg-updater)) | |
98fefb21 LC |
62 | |
63 | ;;; Commentary: | |
64 | ;;; | |
65 | ;;; Code for dealing with the maintenance of GNU packages, such as | |
66 | ;;; auto-updates. | |
67 | ;;; | |
68 | ;;; Code: | |
69 | ||
70 | \f | |
71 | ;;; | |
72 | ;;; List of GNU packages. | |
73 | ;;; | |
22189ed1 | 74 | |
129f9e11 LC |
75 | (define %gnumaint-base-url |
76 | "http://cvs.savannah.gnu.org/viewvc/*checkout*/gnumaint/") | |
77 | ||
22189ed1 | 78 | (define %package-list-url |
1c9e7d65 | 79 | (string->uri |
129f9e11 | 80 | (string-append %gnumaint-base-url "gnupackages.txt?root=womb"))) |
22189ed1 | 81 | |
129f9e11 LC |
82 | (define %package-description-url |
83 | ;; This file contains package descriptions in recutils format. | |
84 | ;; See <https://lists.gnu.org/archive/html/guix-devel/2013-10/msg00071.html>. | |
85 | (string->uri | |
1a75f8d9 | 86 | (string-append %gnumaint-base-url "pkgblurbs.txt?root=womb"))) |
c4ca9411 | 87 | |
f9bbf2a8 NK |
88 | (define-record-type* <gnu-package-descriptor> |
89 | gnu-package-descriptor | |
90 | make-gnu-package-descriptor | |
91 | ||
92 | gnu-package-descriptor? | |
93 | ||
94 | (name gnu-package-name) | |
95 | (mundane-name gnu-package-mundane-name) | |
96 | (copyright-holder gnu-package-copyright-holder) | |
97 | (savannah gnu-package-savannah) | |
98 | (fsd gnu-package-fsd) | |
b0efe83a | 99 | (language gnu-package-language) ; list of strings |
f9bbf2a8 NK |
100 | (logo gnu-package-logo) |
101 | (doc-category gnu-package-doc-category) | |
102 | (doc-summary gnu-package-doc-summary) | |
129f9e11 | 103 | (doc-description gnu-package-doc-description) ; taken from 'pkgdescr.txt' |
b0efe83a | 104 | (doc-urls gnu-package-doc-urls) ; list of strings |
f9bbf2a8 NK |
105 | (download-url gnu-package-download-url)) |
106 | ||
9aec35d2 LC |
107 | (define* (official-gnu-packages |
108 | #:optional (fetch http-fetch/cached)) | |
109 | "Return a list of records, which are GNU packages. Use FETCH, | |
110 | to fetch the list of GNU packages over HTTP." | |
c4ca9411 | 111 | (define (read-records port) |
f9bbf2a8 NK |
112 | ;; Return a list of alists. Each alist contains fields of a GNU |
113 | ;; package. | |
b0efe83a LC |
114 | (let loop ((alist (recutils->alist port)) |
115 | (result '())) | |
116 | (if (null? alist) | |
c4ca9411 | 117 | (reverse result) |
b0efe83a LC |
118 | (loop (recutils->alist port) |
119 | (cons alist result))))) | |
f9bbf2a8 | 120 | |
129f9e11 | 121 | (define official-description |
9aec35d2 | 122 | (let ((db (read-records (fetch %package-description-url #:text? #t)))) |
c4ca9411 | 123 | (lambda (name) |
129f9e11 | 124 | ;; Return the description found upstream for package NAME, or #f. |
c4ca9411 | 125 | (and=> (find (lambda (alist) |
129f9e11 LC |
126 | (equal? name (assoc-ref alist "package"))) |
127 | db) | |
4d5f0bae LC |
128 | (lambda (record) |
129 | (let ((field (assoc-ref record "blurb"))) | |
130 | ;; The upstream description file uses "redirect PACKAGE" as | |
131 | ;; a blurb in cases where the description of the two | |
132 | ;; packages should be considered the same (e.g., GTK+ has | |
133 | ;; "redirect gnome".) This is usually not acceptable for | |
134 | ;; us because we prefer to have distinct descriptions in | |
135 | ;; such cases. Thus, ignore the 'blurb' field when that | |
136 | ;; happens. | |
137 | (and field | |
138 | (not (string-prefix? "redirect " field)) | |
139 | field))))))) | |
c4ca9411 LC |
140 | |
141 | (map (lambda (alist) | |
142 | (let ((name (assoc-ref alist "package"))) | |
129f9e11 | 143 | (alist->record `(("description" . ,(official-description name)) |
c4ca9411 LC |
144 | ,@alist) |
145 | make-gnu-package-descriptor | |
146 | (list "package" "mundane-name" "copyright-holder" | |
147 | "savannah" "fsd" "language" "logo" | |
148 | "doc-category" "doc-summary" "description" | |
149 | "doc-url" | |
150 | "download-url") | |
151 | '("doc-url" "language")))) | |
2134228a LC |
152 | (let* ((port (fetch %package-list-url #:text? #t)) |
153 | (lst (read-records port))) | |
154 | (close-port port) | |
155 | lst))) | |
22189ed1 | 156 | |
f9bbf2a8 NK |
157 | (define (find-packages regexp) |
158 | "Find GNU packages which satisfy REGEXP." | |
159 | (let ((name-rx (make-regexp regexp))) | |
160 | (filter (lambda (package) | |
161 | (false-if-exception | |
162 | (regexp-exec name-rx (gnu-package-name package)))) | |
163 | (official-gnu-packages)))) | |
ef010c0f LC |
164 | |
165 | (define gnu-package? | |
166 | (memoize | |
65b96a0c LC |
167 | (let ((official-gnu-packages (memoize official-gnu-packages))) |
168 | (lambda (package) | |
169 | "Return true if PACKAGE is a GNU package. This procedure may access the | |
ef010c0f | 170 | network to check in GNU's database." |
187eb5f6 LC |
171 | (define (mirror-type url) |
172 | (let ((uri (string->uri url))) | |
173 | (and (eq? (uri-scheme uri) 'mirror) | |
c4e8d513 LC |
174 | (cond |
175 | ((member (uri-host uri) | |
176 | '("gnu" "gnupg" "gcc" "gnome")) | |
177 | ;; Definitely GNU. | |
178 | 'gnu) | |
179 | ((equal? (uri-host uri) "cran") | |
180 | ;; Possibly GNU: mirror://cran could be either GNU R itself | |
181 | ;; or a non-GNU package. | |
182 | #f) | |
183 | (else | |
184 | ;; Definitely non-GNU. | |
185 | 'non-gnu))))) | |
187eb5f6 | 186 | |
55d1f529 LC |
187 | (define (gnu-home-page? package) |
188 | (and=> (package-home-page package) | |
189 | (lambda (url) | |
190 | (and=> (uri-host (string->uri url)) | |
191 | (lambda (host) | |
192 | (member host '("www.gnu.org" "gnu.org"))))))) | |
193 | ||
194 | (or (gnu-home-page? package) | |
195 | (let ((url (and=> (package-source package) origin-uri)) | |
196 | (name (package-name package))) | |
197 | (case (and (string? url) (mirror-type url)) | |
198 | ((gnu) #t) | |
199 | ((non-gnu) #f) | |
200 | (else | |
201 | (and (member name (map gnu-package-name (official-gnu-packages))) | |
202 | #t))))))))) | |
ef010c0f | 203 | |
98fefb21 LC |
204 | \f |
205 | ;;; | |
206 | ;;; Latest release. | |
207 | ;;; | |
208 | ||
209 | (define (ftp-server/directory project) | |
210 | "Return the FTP server and directory where PROJECT's tarball are | |
211 | stored." | |
212 | (define quirks | |
213 | '(("commoncpp2" "ftp.gnu.org" "/gnu/commoncpp") | |
214 | ("ucommon" "ftp.gnu.org" "/gnu/commoncpp") | |
215 | ("libzrtpcpp" "ftp.gnu.org" "/gnu/ccrtp") | |
216 | ("libosip2" "ftp.gnu.org" "/gnu/osip") | |
217 | ("libgcrypt" "ftp.gnupg.org" "/gcrypt/libgcrypt") | |
218 | ("libgpg-error" "ftp.gnupg.org" "/gcrypt/libgpg-error") | |
219 | ("libassuan" "ftp.gnupg.org" "/gcrypt/libassuan") | |
220 | ("gnupg" "ftp.gnupg.org" "/gcrypt/gnupg") | |
221 | ("freefont-ttf" "ftp.gnu.org" "/gnu/freefont") | |
222 | ("gnu-ghostscript" "ftp.gnu.org" "/gnu/ghostscript") | |
223 | ("mit-scheme" "ftp.gnu.org" "/gnu/mit-scheme/stable.pkg") | |
224 | ("icecat" "ftp.gnu.org" "/gnu/gnuzilla") | |
225 | ("source-highlight" "ftp.gnu.org" "/gnu/src-highlite") | |
a4007c98 | 226 | ("gnutls" "ftp.gnutls.org" "/gcrypt/gnutls") |
fa04a04f LC |
227 | |
228 | ;; FIXME: ftp.texmacs.org is currently outdated; texmacs.org refers to | |
229 | ;; its own http URL instead. | |
98fefb21 LC |
230 | ("TeXmacs" "ftp.texmacs.org" "/TeXmacs/targz"))) |
231 | ||
232 | (match (assoc project quirks) | |
233 | ((_ server directory) | |
234 | (values server directory)) | |
235 | (_ | |
236 | (values "ftp.gnu.org" (string-append "/gnu/" project))))) | |
237 | ||
cac137aa | 238 | (define (sans-extension tarball) |
f5d9604f LC |
239 | "Return TARBALL without its .tar.* or .zip extension." |
240 | (let ((end (or (string-contains tarball ".tar") | |
241 | (string-contains tarball ".zip")))) | |
cac137aa | 242 | (substring tarball 0 end))) |
98fefb21 | 243 | |
d55a99fe | 244 | (define %tarball-rx |
f00dccf4 LC |
245 | ;; The .zip extensions is notably used for freefont-ttf. |
246 | ;; The "-src" pattern is for "TeXmacs-1.0.7.9-src.tar.gz". | |
247 | ;; The "-gnu[0-9]" pattern is for "icecat-38.4.0-gnu1.tar.bz2". | |
248 | (make-regexp "^([^.]+)-([0-9]|[^-])+(-(src|gnu[0-9]))?\\.(tar\\.|zip$)")) | |
d55a99fe LC |
249 | |
250 | (define %alpha-tarball-rx | |
251 | (make-regexp "^.*-.*[0-9](-|~)?(alpha|beta|rc|cvs|svn|git)-?[0-9\\.]*\\.tar\\.")) | |
252 | ||
501d7647 | 253 | (define (release-file? project file) |
cac137aa | 254 | "Return #f if FILE is not a release tarball of PROJECT, otherwise return |
501d7647 | 255 | true." |
cac137aa | 256 | (and (not (string-suffix? ".sig" file)) |
d55a99fe LC |
257 | (and=> (regexp-exec %tarball-rx file) |
258 | (lambda (match) | |
259 | ;; Filter out unrelated files, like `guile-www-1.1.1'. | |
fa04a04f LC |
260 | ;; Case-insensitive for things like "TeXmacs" vs. "texmacs". |
261 | (and=> (match:substring match 1) | |
262 | (lambda (name) | |
263 | (string-ci=? name project))))) | |
cac137aa LC |
264 | (not (regexp-exec %alpha-tarball-rx file)) |
265 | (let ((s (sans-extension file))) | |
501d7647 LC |
266 | (regexp-exec %package-name-rx s)))) |
267 | ||
268 | (define (tarball->version tarball) | |
269 | "Return the version TARBALL corresponds to. TARBALL is a file name like | |
270 | \"coreutils-8.23.tar.xz\"." | |
271 | (let-values (((name version) | |
272 | (gnu-package-name->name+version (sans-extension tarball)))) | |
273 | version)) | |
274 | ||
cac137aa LC |
275 | (define (releases project) |
276 | "Return the list of releases of PROJECT as a list of release name/directory | |
277 | pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\"). " | |
278 | ;; TODO: Parse something like fencepost.gnu.org:/gd/gnuorg/packages-ftp. | |
98fefb21 LC |
279 | (let-values (((server directory) (ftp-server/directory project))) |
280 | (define conn (ftp-open server)) | |
281 | ||
282 | (let loop ((directories (list directory)) | |
283 | (result '())) | |
6a917ef7 LC |
284 | (match directories |
285 | (() | |
286 | (ftp-close conn) | |
0a7c5a09 | 287 | (coalesce-sources result)) |
6a917ef7 LC |
288 | ((directory rest ...) |
289 | (let* ((files (ftp-list conn directory)) | |
290 | (subdirs (filter-map (match-lambda | |
0a7c5a09 LC |
291 | ((name 'directory . _) name) |
292 | (_ #f)) | |
6a917ef7 | 293 | files))) |
0a7c5a09 LC |
294 | (define (file->url file) |
295 | (string-append "ftp://" server directory "/" file)) | |
296 | ||
297 | (define (file->source file) | |
298 | (let ((url (file->url file))) | |
299 | (upstream-source | |
300 | (package project) | |
301 | (version (tarball->version file)) | |
302 | (urls (list url)) | |
303 | (signature-urls (list (string-append url ".sig")))))) | |
304 | ||
6a917ef7 LC |
305 | (loop (append (map (cut string-append directory "/" <>) |
306 | subdirs) | |
307 | rest) | |
308 | (append | |
309 | ;; Filter out signatures, deltas, and files which | |
310 | ;; are potentially not releases of PROJECT--e.g., | |
311 | ;; in /gnu/guile, filter out guile-oops and | |
312 | ;; guile-www; in mit-scheme, filter out binaries. | |
313 | (filter-map (match-lambda | |
0a7c5a09 LC |
314 | ((file 'file . _) |
315 | (and (release-file? project file) | |
316 | (file->source file))) | |
317 | (_ #f)) | |
6a917ef7 LC |
318 | files) |
319 | result)))))))) | |
98fefb21 | 320 | |
e946f2ec LC |
321 | (define* (latest-ftp-release project |
322 | #:key | |
323 | (server "ftp.gnu.org") | |
324 | (directory (string-append "/gnu/" project)) | |
c4991257 | 325 | (keep-file? (const #t)) |
6efa6f76 | 326 | (file->signature (cut string-append <> ".sig")) |
e946f2ec LC |
327 | (ftp-open ftp-open) (ftp-close ftp-close)) |
328 | "Return an <upstream-source> for the latest release of PROJECT on SERVER | |
329 | under DIRECTORY, or #f. Use FTP-OPEN and FTP-CLOSE to open (resp. close) FTP | |
c4991257 LC |
330 | connections; this can be useful to reuse connections. |
331 | ||
873d0ff2 LC |
332 | KEEP-FILE? is a predicate to decide whether to enter a directory and to |
333 | consider a given file (source tarball) as a valid candidate based on its name. | |
c4991257 LC |
334 | |
335 | FILE->SIGNATURE must be a procedure; it is passed a source file URL and must | |
336 | return the corresponding signature URL, or #f it signatures are unavailable." | |
cac137aa LC |
337 | (define (latest a b) |
338 | (if (version>? a b) a b)) | |
339 | ||
501d7647 | 340 | (define (latest-release a b) |
0a7c5a09 | 341 | (if (version>? (upstream-source-version a) (upstream-source-version b)) |
501d7647 LC |
342 | a b)) |
343 | ||
cac137aa LC |
344 | (define contains-digit? |
345 | (cut string-any char-set:digit <>)) | |
346 | ||
a74da6b0 LC |
347 | (define patch-directory-name? |
348 | ;; Return #t for patch directory names such as 'bash-4.2-patches'. | |
349 | (cut string-suffix? "patches" <>)) | |
350 | ||
e946f2ec LC |
351 | (define conn (ftp-open server)) |
352 | ||
353 | (define (file->url directory file) | |
354 | (string-append "ftp://" server directory "/" file)) | |
355 | ||
356 | (define (file->source directory file) | |
357 | (let ((url (file->url directory file))) | |
358 | (upstream-source | |
359 | (package project) | |
360 | (version (tarball->version file)) | |
361 | (urls (list url)) | |
6efa6f76 LC |
362 | (signature-urls (match (file->signature url) |
363 | (#f #f) | |
364 | (sig (list sig))))))) | |
e946f2ec LC |
365 | |
366 | (let loop ((directory directory) | |
367 | (result #f)) | |
368 | (let* ((entries (ftp-list conn directory)) | |
369 | ||
370 | ;; Filter out sub-directories that do not contain digits---e.g., | |
371 | ;; /gnuzilla/lang and /gnupg/patches. Filter out "w32" | |
372 | ;; directories as found on ftp.gnutls.org. | |
373 | (subdirs (filter-map (match-lambda | |
374 | (((? patch-directory-name? dir) | |
375 | 'directory . _) | |
376 | #f) | |
377 | (("w32" 'directory . _) | |
378 | #f) | |
379 | (((? contains-digit? dir) 'directory . _) | |
873d0ff2 | 380 | (and (keep-file? dir) dir)) |
e946f2ec LC |
381 | (_ #f)) |
382 | entries)) | |
383 | ||
384 | ;; Whether or not SUBDIRS is empty, compute the latest releases | |
385 | ;; for the current directory. This is necessary for packages | |
386 | ;; such as 'sharutils' that have a sub-directory that contains | |
387 | ;; only an older release. | |
388 | (releases (filter-map (match-lambda | |
389 | ((file 'file . _) | |
390 | (and (release-file? project file) | |
c4991257 | 391 | (keep-file? file) |
e946f2ec LC |
392 | (file->source directory file))) |
393 | (_ #f)) | |
394 | entries))) | |
395 | ||
396 | ;; Assume that SUBDIRS correspond to versions, and jump into the | |
397 | ;; one with the highest version number. | |
398 | (let* ((release (reduce latest-release #f | |
399 | (coalesce-sources releases))) | |
400 | (result (if (and result release) | |
401 | (latest-release release result) | |
402 | (or release result))) | |
403 | (target (reduce latest #f subdirs))) | |
404 | (if target | |
405 | (loop (string-append directory "/" target) | |
406 | result) | |
407 | (begin | |
408 | (ftp-close conn) | |
409 | result)))))) | |
410 | ||
411 | (define (latest-release package . rest) | |
412 | "Return the <upstream-source> for the latest version of PACKAGE or #f. | |
413 | PACKAGE is the name of a GNU package. This procedure automatically uses the | |
414 | right FTP server and directory for PACKAGE." | |
415 | (let-values (((server directory) (ftp-server/directory package))) | |
416 | (apply latest-ftp-release package | |
417 | #:server server | |
418 | #:directory directory | |
419 | rest))) | |
98fefb21 | 420 | |
e80c0f85 LC |
421 | (define-syntax-rule (false-if-ftp-error exp) |
422 | "Return #f if an FTP error is raise while evaluating EXP; return the result | |
423 | of EXP otherwise." | |
0a7c5a09 LC |
424 | (catch 'ftp-error |
425 | (lambda () | |
e80c0f85 | 426 | exp) |
0a7c5a09 LC |
427 | (lambda (key port . rest) |
428 | (if (ftp-connection? port) | |
429 | (ftp-close port) | |
430 | (close-port port)) | |
431 | #f))) | |
7047133f | 432 | |
e80c0f85 LC |
433 | (define (latest-release* package) |
434 | "Like 'latest-release', but ignore FTP errors that might occur when PACKAGE | |
435 | is not actually a GNU package, or not hosted on ftp.gnu.org, or not under that | |
436 | name (this is the case for \"emacs-auctex\", for instance.)" | |
7d27a025 | 437 | (false-if-ftp-error (latest-release (package-name package)))) |
e80c0f85 | 438 | |
98fefb21 LC |
439 | (define %package-name-rx |
440 | ;; Regexp for a package name, e.g., "foo-X.Y". Since TeXmacs uses | |
441 | ;; "TeXmacs-X.Y-src", the `-src' suffix is allowed. | |
442 | (make-regexp "^(.*)-(([0-9]|\\.)+)(-src)?")) | |
443 | ||
444 | (define (gnu-package-name->name+version name+version) | |
445 | "Return the package name and version number extracted from NAME+VERSION." | |
446 | (let ((match (regexp-exec %package-name-rx name+version))) | |
447 | (if (not match) | |
448 | (values name+version #f) | |
449 | (values (match:substring match 1) (match:substring match 2))))) | |
450 | ||
e80c0f85 LC |
451 | (define (pure-gnu-package? package) |
452 | "Return true if PACKAGE is a non-Emacs and non-GNOME GNU package. This | |
453 | excludes AucTeX, for instance, whose releases are now uploaded to | |
454 | elpa.gnu.org, and all the GNOME packages." | |
0a7c5a09 | 455 | (and (not (string-prefix? "emacs-" (package-name package))) |
e80c0f85 | 456 | (not (gnome-package? package)) |
0a7c5a09 | 457 | (gnu-package? package))) |
0fdd3bea | 458 | |
e80c0f85 LC |
459 | (define (gnome-package? package) |
460 | "Return true if PACKAGE is a GNOME package, hosted on gnome.org." | |
461 | (define gnome-uri? | |
462 | (match-lambda | |
463 | ((? string? uri) | |
464 | (string-prefix? "mirror://gnome/" uri)) | |
465 | (_ | |
466 | #f))) | |
467 | ||
468 | (match (package-source package) | |
469 | ((? origin? origin) | |
470 | (match (origin-uri origin) | |
471 | ((? gnome-uri?) #t) | |
472 | (_ #f))) | |
473 | (_ #f))) | |
474 | ||
475 | (define (latest-gnome-release package) | |
476 | "Return the latest release of PACKAGE, the name of a GNOME package." | |
c4991257 LC |
477 | (define %not-dot |
478 | (char-set-complement (char-set #\.))) | |
479 | ||
480 | (define (even-minor-version? version) | |
873d0ff2 LC |
481 | (match (string-tokenize version %not-dot) |
482 | (((= string->number major) (= string->number minor) . rest) | |
483 | (and minor (even? minor))) | |
c4991257 LC |
484 | (_ |
485 | #t))) ;cross fingers | |
486 | ||
873d0ff2 LC |
487 | (define (even-numbered? file) |
488 | ;; Return true if FILE somehow denotes an even-numbered file name. The | |
489 | ;; trick here is that we want this to match both directories such as | |
490 | ;; "3.18.6" and actual file names such as "gtk+-3.18.6.tar.bz2". | |
491 | (let-values (((name version) (package-name->name+version file))) | |
492 | (even-minor-version? (or version name)))) | |
c4991257 | 493 | |
e80c0f85 | 494 | (false-if-ftp-error |
7d27a025 | 495 | (latest-ftp-release (package-name package) |
e80c0f85 LC |
496 | #:server "ftp.gnome.org" |
497 | #:directory (string-append "/pub/gnome/sources/" | |
7d27a025 | 498 | (match (package-name package) |
e80c0f85 | 499 | ("gconf" "GConf") |
6efa6f76 LC |
500 | (x x))) |
501 | ||
c4991257 LC |
502 | |
503 | ;; <https://www.gnome.org/gnome-3/source/> explains | |
504 | ;; that odd minor version numbers represent development | |
505 | ;; releases, which we are usually not interested in. | |
873d0ff2 | 506 | #:keep-file? even-numbered? |
c4991257 | 507 | |
6efa6f76 LC |
508 | ;; ftp.gnome.org provides no signatures, only |
509 | ;; checksums. | |
510 | #:file->signature (const #f)))) | |
e80c0f85 | 511 | |
62061d6b AW |
512 | (define (xorg-package? package) |
513 | "Return true if PACKAGE is an X.org package, developed by X.org." | |
514 | (define xorg-uri? | |
515 | (match-lambda | |
516 | ((? string? uri) | |
517 | (string-prefix? "mirror://xorg/" uri)) | |
518 | (_ | |
519 | #f))) | |
520 | ||
521 | (match (package-source package) | |
522 | ((? origin? origin) | |
523 | (match (origin-uri origin) | |
524 | ((? xorg-uri?) #t) | |
525 | (_ #f))) | |
526 | (_ #f))) | |
527 | ||
528 | (define (latest-xorg-release package) | |
529 | "Return the latest release of PACKAGE, the name of an X.org package." | |
7d27a025 | 530 | (let ((uri (string->uri (origin-uri (package-source package))))) |
62061d6b AW |
531 | (false-if-ftp-error |
532 | (latest-ftp-release | |
7d27a025 | 533 | (package-name package) |
62061d6b AW |
534 | #:server "ftp.freedesktop.org" |
535 | #:directory | |
536 | (string-append "/pub/xorg/" (dirname (uri-path uri))))))) | |
537 | ||
0a7c5a09 | 538 | (define %gnu-updater |
7e6b490d AK |
539 | (upstream-updater |
540 | (name 'gnu) | |
541 | (description "Updater for GNU packages") | |
e80c0f85 | 542 | (pred pure-gnu-package?) |
7e6b490d | 543 | (latest latest-release*))) |
0fdd3bea | 544 | |
e80c0f85 LC |
545 | (define %gnome-updater |
546 | (upstream-updater | |
547 | (name 'gnome) | |
548 | (description "Updater for GNOME packages") | |
549 | (pred gnome-package?) | |
550 | (latest latest-gnome-release))) | |
551 | ||
62061d6b AW |
552 | (define %xorg-updater |
553 | (upstream-updater | |
554 | (name 'xorg) | |
555 | (description "Updater for X.org packages") | |
556 | (pred xorg-package?) | |
557 | (latest latest-xorg-release))) | |
558 | ||
98fefb21 | 559 | ;;; gnu-maintenance.scm ends here |