2013-01-05 18:47:50 -05:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
utils: Move combinators to (guix combinators).
* guix/utils.scm (compile-time-value, memoize, fold2)
(fold-tree, fold-tree-leaves): Move to...
* guix/combinators: ... here. New file.
* tests/utils.scm ("fold2, 1 list", "fold2, 2 lists")
(fold-tree tests): Move to...
* tests/combinators.scm: ... here. New file.
* Makefile.am (MODULES, SCM_TESTS): Add them.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
gnu/services/herd.scm, guix/build-system/gnu.scm,
guix/build-system/python.scm, guix/derivations.scm,
guix/gnu-maintenance.scm, guix/import/elpa.scm,
guix/scripts/archive.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/size.scm, guix/scripts/substitute.scm,
guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports
accordingly.
2016-05-04 11:35:47 -04:00
|
|
|
|
;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
2013-03-28 17:40:41 -04:00
|
|
|
|
;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
2012-12-04 18:02:22 -05:00
|
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
|
;;; This file is part of GNU Guix.
|
2012-12-04 18:02:22 -05:00
|
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
2012-12-04 18:02:22 -05:00
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
2012-12-04 18:02:22 -05:00
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
2013-01-05 18:47:50 -05:00
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-12-04 18:02:22 -05:00
|
|
|
|
|
|
|
|
|
(define-module (guix gnu-maintenance)
|
|
|
|
|
#:use-module (web uri)
|
|
|
|
|
#:use-module (web client)
|
|
|
|
|
#:use-module (web response)
|
|
|
|
|
#:use-module (ice-9 regex)
|
2013-01-08 16:46:12 -05:00
|
|
|
|
#:use-module (ice-9 match)
|
2012-12-04 18:02:22 -05:00
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-11)
|
|
|
|
|
#:use-module (srfi srfi-26)
|
2013-01-08 16:46:12 -05:00
|
|
|
|
#:use-module (system foreign)
|
2013-07-14 10:35:37 -04:00
|
|
|
|
#:use-module (guix http-client)
|
2013-01-08 16:46:12 -05:00
|
|
|
|
#:use-module (guix ftp-client)
|
2013-02-12 12:02:15 -05:00
|
|
|
|
#:use-module (guix utils)
|
utils: Move combinators to (guix combinators).
* guix/utils.scm (compile-time-value, memoize, fold2)
(fold-tree, fold-tree-leaves): Move to...
* guix/combinators: ... here. New file.
* tests/utils.scm ("fold2, 1 list", "fold2, 2 lists")
(fold-tree tests): Move to...
* tests/combinators.scm: ... here. New file.
* Makefile.am (MODULES, SCM_TESTS): Add them.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
gnu/services/herd.scm, guix/build-system/gnu.scm,
guix/build-system/python.scm, guix/derivations.scm,
guix/gnu-maintenance.scm, guix/import/elpa.scm,
guix/scripts/archive.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/size.scm, guix/scripts/substitute.scm,
guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports
accordingly.
2016-05-04 11:35:47 -04:00
|
|
|
|
#:use-module (guix combinators)
|
2013-05-12 09:46:16 -04:00
|
|
|
|
#:use-module (guix records)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module (guix upstream)
|
2013-03-05 14:30:27 -05:00
|
|
|
|
#:use-module (guix packages)
|
2013-03-28 17:40:41 -04:00
|
|
|
|
#:export (gnu-package-name
|
|
|
|
|
gnu-package-mundane-name
|
|
|
|
|
gnu-package-copyright-holder
|
|
|
|
|
gnu-package-savannah
|
|
|
|
|
gnu-package-fsd
|
|
|
|
|
gnu-package-language
|
|
|
|
|
gnu-package-logo
|
|
|
|
|
gnu-package-doc-category
|
|
|
|
|
gnu-package-doc-summary
|
2013-07-10 16:33:40 -04:00
|
|
|
|
gnu-package-doc-description
|
2013-03-28 17:40:41 -04:00
|
|
|
|
gnu-package-doc-urls
|
|
|
|
|
gnu-package-download-url
|
|
|
|
|
|
|
|
|
|
official-gnu-packages
|
2016-06-08 11:59:45 -04:00
|
|
|
|
find-package
|
2013-03-05 14:30:27 -05:00
|
|
|
|
gnu-package?
|
2013-03-28 17:40:41 -04:00
|
|
|
|
|
2015-12-07 16:45:00 -05:00
|
|
|
|
release-file?
|
2013-01-08 16:46:12 -05:00
|
|
|
|
releases
|
|
|
|
|
latest-release
|
2014-11-11 09:30:58 -05:00
|
|
|
|
gnu-release-archive-types
|
2013-04-24 17:48:36 -04:00
|
|
|
|
gnu-package-name->name+version
|
2014-11-11 09:30:58 -05:00
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
%gnu-updater
|
2016-02-18 14:50:02 -05:00
|
|
|
|
%gnome-updater
|
2016-08-01 05:05:28 -04:00
|
|
|
|
%kde-updater
|
2016-11-30 10:29:15 -05:00
|
|
|
|
%xorg-updater
|
|
|
|
|
%kernel.org-updater))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code for dealing with the maintenance of GNU packages, such as
|
|
|
|
|
;;; auto-updates.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; List of GNU packages.
|
|
|
|
|
;;;
|
2012-12-04 18:02:22 -05:00
|
|
|
|
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(define %gnumaint-base-url
|
|
|
|
|
"http://cvs.savannah.gnu.org/viewvc/*checkout*/gnumaint/")
|
|
|
|
|
|
2012-12-04 18:02:22 -05:00
|
|
|
|
(define %package-list-url
|
2013-04-25 16:06:48 -04:00
|
|
|
|
(string->uri
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(string-append %gnumaint-base-url "gnupackages.txt?root=womb")))
|
2012-12-04 18:02:22 -05:00
|
|
|
|
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(define %package-description-url
|
|
|
|
|
;; This file contains package descriptions in recutils format.
|
|
|
|
|
;; See <https://lists.gnu.org/archive/html/guix-devel/2013-10/msg00071.html>.
|
|
|
|
|
(string->uri
|
2013-10-11 16:02:33 -04:00
|
|
|
|
(string-append %gnumaint-base-url "pkgblurbs.txt?root=womb")))
|
2013-07-10 16:33:40 -04:00
|
|
|
|
|
2013-03-28 17:40:41 -04:00
|
|
|
|
(define-record-type* <gnu-package-descriptor>
|
|
|
|
|
gnu-package-descriptor
|
|
|
|
|
make-gnu-package-descriptor
|
|
|
|
|
|
|
|
|
|
gnu-package-descriptor?
|
|
|
|
|
|
|
|
|
|
(name gnu-package-name)
|
|
|
|
|
(mundane-name gnu-package-mundane-name)
|
|
|
|
|
(copyright-holder gnu-package-copyright-holder)
|
|
|
|
|
(savannah gnu-package-savannah)
|
|
|
|
|
(fsd gnu-package-fsd)
|
2013-07-10 12:08:09 -04:00
|
|
|
|
(language gnu-package-language) ; list of strings
|
2013-03-28 17:40:41 -04:00
|
|
|
|
(logo gnu-package-logo)
|
|
|
|
|
(doc-category gnu-package-doc-category)
|
|
|
|
|
(doc-summary gnu-package-doc-summary)
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(doc-description gnu-package-doc-description) ; taken from 'pkgdescr.txt'
|
2013-07-10 12:08:09 -04:00
|
|
|
|
(doc-urls gnu-package-doc-urls) ; list of strings
|
2013-03-28 17:40:41 -04:00
|
|
|
|
(download-url gnu-package-download-url))
|
|
|
|
|
|
2015-10-17 07:04:12 -04:00
|
|
|
|
(define* (official-gnu-packages
|
|
|
|
|
#:optional (fetch http-fetch/cached))
|
|
|
|
|
"Return a list of records, which are GNU packages. Use FETCH,
|
|
|
|
|
to fetch the list of GNU packages over HTTP."
|
2013-07-10 16:33:40 -04:00
|
|
|
|
(define (read-records port)
|
2013-03-28 17:40:41 -04:00
|
|
|
|
;; Return a list of alists. Each alist contains fields of a GNU
|
|
|
|
|
;; package.
|
2013-07-10 12:08:09 -04:00
|
|
|
|
(let loop ((alist (recutils->alist port))
|
|
|
|
|
(result '()))
|
|
|
|
|
(if (null? alist)
|
2013-07-10 16:33:40 -04:00
|
|
|
|
(reverse result)
|
2013-07-10 12:08:09 -04:00
|
|
|
|
(loop (recutils->alist port)
|
|
|
|
|
(cons alist result)))))
|
2013-03-28 17:40:41 -04:00
|
|
|
|
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(define official-description
|
2015-10-17 07:04:12 -04:00
|
|
|
|
(let ((db (read-records (fetch %package-description-url #:text? #t))))
|
2013-07-10 16:33:40 -04:00
|
|
|
|
(lambda (name)
|
2013-10-09 07:00:00 -04:00
|
|
|
|
;; Return the description found upstream for package NAME, or #f.
|
2013-07-10 16:33:40 -04:00
|
|
|
|
(and=> (find (lambda (alist)
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(equal? name (assoc-ref alist "package")))
|
|
|
|
|
db)
|
2013-12-03 15:33:55 -05:00
|
|
|
|
(lambda (record)
|
|
|
|
|
(let ((field (assoc-ref record "blurb")))
|
|
|
|
|
;; The upstream description file uses "redirect PACKAGE" as
|
|
|
|
|
;; a blurb in cases where the description of the two
|
|
|
|
|
;; packages should be considered the same (e.g., GTK+ has
|
|
|
|
|
;; "redirect gnome".) This is usually not acceptable for
|
|
|
|
|
;; us because we prefer to have distinct descriptions in
|
|
|
|
|
;; such cases. Thus, ignore the 'blurb' field when that
|
|
|
|
|
;; happens.
|
|
|
|
|
(and field
|
|
|
|
|
(not (string-prefix? "redirect " field))
|
|
|
|
|
field)))))))
|
2013-07-10 16:33:40 -04:00
|
|
|
|
|
|
|
|
|
(map (lambda (alist)
|
|
|
|
|
(let ((name (assoc-ref alist "package")))
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(alist->record `(("description" . ,(official-description name))
|
2013-07-10 16:33:40 -04:00
|
|
|
|
,@alist)
|
|
|
|
|
make-gnu-package-descriptor
|
|
|
|
|
(list "package" "mundane-name" "copyright-holder"
|
|
|
|
|
"savannah" "fsd" "language" "logo"
|
|
|
|
|
"doc-category" "doc-summary" "description"
|
|
|
|
|
"doc-url"
|
|
|
|
|
"download-url")
|
|
|
|
|
'("doc-url" "language"))))
|
2015-10-17 08:37:50 -04:00
|
|
|
|
(let* ((port (fetch %package-list-url #:text? #t))
|
|
|
|
|
(lst (read-records port)))
|
|
|
|
|
(close-port port)
|
|
|
|
|
lst)))
|
2012-12-04 18:02:22 -05:00
|
|
|
|
|
2016-06-08 11:59:45 -04:00
|
|
|
|
(define (find-package name)
|
|
|
|
|
"Find GNU package called NAME and return it. Return #f if it was not
|
|
|
|
|
found."
|
|
|
|
|
(find (lambda (package)
|
|
|
|
|
(string=? name (gnu-package-name package)))
|
|
|
|
|
(official-gnu-packages)))
|
2013-03-05 14:30:27 -05:00
|
|
|
|
|
|
|
|
|
(define gnu-package?
|
|
|
|
|
(memoize
|
2013-04-24 17:49:05 -04:00
|
|
|
|
(let ((official-gnu-packages (memoize official-gnu-packages)))
|
|
|
|
|
(lambda (package)
|
|
|
|
|
"Return true if PACKAGE is a GNU package. This procedure may access the
|
2013-03-05 14:30:27 -05:00
|
|
|
|
network to check in GNU's database."
|
2014-04-29 12:02:16 -04:00
|
|
|
|
(define (mirror-type url)
|
|
|
|
|
(let ((uri (string->uri url)))
|
|
|
|
|
(and (eq? (uri-scheme uri) 'mirror)
|
2015-05-05 07:46:20 -04:00
|
|
|
|
(cond
|
|
|
|
|
((member (uri-host uri)
|
|
|
|
|
'("gnu" "gnupg" "gcc" "gnome"))
|
|
|
|
|
;; Definitely GNU.
|
|
|
|
|
'gnu)
|
|
|
|
|
((equal? (uri-host uri) "cran")
|
|
|
|
|
;; Possibly GNU: mirror://cran could be either GNU R itself
|
|
|
|
|
;; or a non-GNU package.
|
|
|
|
|
#f)
|
|
|
|
|
(else
|
|
|
|
|
;; Definitely non-GNU.
|
|
|
|
|
'non-gnu)))))
|
2014-04-29 12:02:16 -04:00
|
|
|
|
|
2015-06-16 04:28:19 -04:00
|
|
|
|
(define (gnu-home-page? package)
|
|
|
|
|
(and=> (package-home-page package)
|
|
|
|
|
(lambda (url)
|
|
|
|
|
(and=> (uri-host (string->uri url))
|
|
|
|
|
(lambda (host)
|
|
|
|
|
(member host '("www.gnu.org" "gnu.org")))))))
|
|
|
|
|
|
|
|
|
|
(or (gnu-home-page? package)
|
|
|
|
|
(let ((url (and=> (package-source package) origin-uri))
|
|
|
|
|
(name (package-name package)))
|
|
|
|
|
(case (and (string? url) (mirror-type url))
|
|
|
|
|
((gnu) #t)
|
|
|
|
|
((non-gnu) #f)
|
|
|
|
|
(else
|
|
|
|
|
(and (member name (map gnu-package-name (official-gnu-packages)))
|
|
|
|
|
#t)))))))))
|
2013-03-05 14:30:27 -05:00
|
|
|
|
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Latest release.
|
|
|
|
|
;;;
|
|
|
|
|
|
2016-04-14 16:18:56 -04:00
|
|
|
|
(define (ftp-server/directory package)
|
|
|
|
|
"Return the FTP server and directory where PACKAGE's tarball are stored."
|
|
|
|
|
(values (or (assoc-ref (package-properties package) 'ftp-server)
|
|
|
|
|
"ftp.gnu.org")
|
|
|
|
|
(or (assoc-ref (package-properties package) 'ftp-directory)
|
|
|
|
|
(string-append "/gnu/" (package-name package)))))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(define (sans-extension tarball)
|
2014-11-29 16:14:34 -05:00
|
|
|
|
"Return TARBALL without its .tar.* or .zip extension."
|
|
|
|
|
(let ((end (or (string-contains tarball ".tar")
|
|
|
|
|
(string-contains tarball ".zip"))))
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(substring tarball 0 end)))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
2013-04-24 17:37:14 -04:00
|
|
|
|
(define %tarball-rx
|
2015-12-07 16:17:43 -05:00
|
|
|
|
;; The .zip extensions is notably used for freefont-ttf.
|
|
|
|
|
;; The "-src" pattern is for "TeXmacs-1.0.7.9-src.tar.gz".
|
|
|
|
|
;; The "-gnu[0-9]" pattern is for "icecat-38.4.0-gnu1.tar.bz2".
|
|
|
|
|
(make-regexp "^([^.]+)-([0-9]|[^-])+(-(src|gnu[0-9]))?\\.(tar\\.|zip$)"))
|
2013-04-24 17:37:14 -04:00
|
|
|
|
|
|
|
|
|
(define %alpha-tarball-rx
|
|
|
|
|
(make-regexp "^.*-.*[0-9](-|~)?(alpha|beta|rc|cvs|svn|git)-?[0-9\\.]*\\.tar\\."))
|
|
|
|
|
|
2014-11-11 08:59:38 -05:00
|
|
|
|
(define (release-file? project file)
|
2013-04-24 17:17:31 -04:00
|
|
|
|
"Return #f if FILE is not a release tarball of PROJECT, otherwise return
|
2014-11-11 08:59:38 -05:00
|
|
|
|
true."
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(and (not (string-suffix? ".sig" file))
|
2013-04-24 17:37:14 -04:00
|
|
|
|
(and=> (regexp-exec %tarball-rx file)
|
|
|
|
|
(lambda (match)
|
|
|
|
|
;; Filter out unrelated files, like `guile-www-1.1.1'.
|
2015-12-07 16:18:31 -05:00
|
|
|
|
;; Case-insensitive for things like "TeXmacs" vs. "texmacs".
|
2016-04-14 15:48:05 -04:00
|
|
|
|
;; The "-src" suffix is for "freefont-src-20120503.tar.gz".
|
2015-12-07 16:18:31 -05:00
|
|
|
|
(and=> (match:substring match 1)
|
|
|
|
|
(lambda (name)
|
2016-04-14 15:48:05 -04:00
|
|
|
|
(or (string-ci=? name project)
|
|
|
|
|
(string-ci=? name
|
|
|
|
|
(string-append project
|
|
|
|
|
"-src")))))))
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(not (regexp-exec %alpha-tarball-rx file))
|
|
|
|
|
(let ((s (sans-extension file)))
|
2014-11-11 08:59:38 -05:00
|
|
|
|
(regexp-exec %package-name-rx s))))
|
|
|
|
|
|
|
|
|
|
(define (tarball->version tarball)
|
|
|
|
|
"Return the version TARBALL corresponds to. TARBALL is a file name like
|
|
|
|
|
\"coreutils-8.23.tar.xz\"."
|
|
|
|
|
(let-values (((name version)
|
|
|
|
|
(gnu-package-name->name+version (sans-extension tarball))))
|
|
|
|
|
version))
|
|
|
|
|
|
2016-04-14 16:18:56 -04:00
|
|
|
|
(define* (releases project
|
|
|
|
|
#:key
|
|
|
|
|
(server "ftp.gnu.org")
|
|
|
|
|
(directory (string-append "/gnu/" project)))
|
|
|
|
|
"Return the list of <upstream-release> of PROJECT as a list of release
|
|
|
|
|
name/directory pairs."
|
2013-04-24 17:17:31 -04:00
|
|
|
|
;; TODO: Parse something like fencepost.gnu.org:/gd/gnuorg/packages-ftp.
|
2016-04-14 16:18:56 -04:00
|
|
|
|
(define conn (ftp-open server))
|
|
|
|
|
|
|
|
|
|
(let loop ((directories (list directory))
|
|
|
|
|
(result '()))
|
|
|
|
|
(match directories
|
|
|
|
|
(()
|
|
|
|
|
(ftp-close conn)
|
|
|
|
|
(coalesce-sources result))
|
|
|
|
|
((directory rest ...)
|
|
|
|
|
(let* ((files (ftp-list conn directory))
|
|
|
|
|
(subdirs (filter-map (match-lambda
|
|
|
|
|
((name 'directory . _) name)
|
|
|
|
|
(_ #f))
|
|
|
|
|
files)))
|
|
|
|
|
(define (file->url file)
|
|
|
|
|
(string-append "ftp://" server directory "/" file))
|
|
|
|
|
|
|
|
|
|
(define (file->source file)
|
|
|
|
|
(let ((url (file->url file)))
|
|
|
|
|
(upstream-source
|
|
|
|
|
(package project)
|
|
|
|
|
(version (tarball->version file))
|
|
|
|
|
(urls (list url))
|
|
|
|
|
(signature-urls (list (string-append url ".sig"))))))
|
|
|
|
|
|
|
|
|
|
(loop (append (map (cut string-append directory "/" <>)
|
|
|
|
|
subdirs)
|
|
|
|
|
rest)
|
|
|
|
|
(append
|
|
|
|
|
;; Filter out signatures, deltas, and files which
|
|
|
|
|
;; are potentially not releases of PROJECT--e.g.,
|
|
|
|
|
;; in /gnu/guile, filter out guile-oops and
|
|
|
|
|
;; guile-www; in mit-scheme, filter out binaries.
|
|
|
|
|
(filter-map (match-lambda
|
|
|
|
|
((file 'file . _)
|
|
|
|
|
(and (release-file? project file)
|
|
|
|
|
(file->source file)))
|
|
|
|
|
(_ #f))
|
|
|
|
|
files)
|
|
|
|
|
result)))))))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
2015-12-07 17:18:06 -05:00
|
|
|
|
(define* (latest-ftp-release project
|
|
|
|
|
#:key
|
|
|
|
|
(server "ftp.gnu.org")
|
|
|
|
|
(directory (string-append "/gnu/" project))
|
2015-12-08 10:05:55 -05:00
|
|
|
|
(keep-file? (const #t))
|
2015-12-07 17:54:35 -05:00
|
|
|
|
(file->signature (cut string-append <> ".sig"))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
(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
|
2015-12-08 10:05:55 -05:00
|
|
|
|
connections; this can be useful to reuse connections.
|
|
|
|
|
|
2015-12-09 15:59:32 -05:00
|
|
|
|
KEEP-FILE? is a predicate to decide whether to enter a directory and to
|
|
|
|
|
consider a given file (source tarball) as a valid candidate based on its name.
|
2015-12-08 10:05:55 -05:00
|
|
|
|
|
|
|
|
|
FILE->SIGNATURE must be a procedure; it is passed a source file URL and must
|
|
|
|
|
return the corresponding signature URL, or #f it signatures are unavailable."
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(define (latest a b)
|
|
|
|
|
(if (version>? a b) a b))
|
|
|
|
|
|
2014-11-11 08:59:38 -05:00
|
|
|
|
(define (latest-release a b)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(if (version>? (upstream-source-version a) (upstream-source-version b))
|
2014-11-11 08:59:38 -05:00
|
|
|
|
a b))
|
|
|
|
|
|
2013-04-24 17:17:31 -04:00
|
|
|
|
(define contains-digit?
|
|
|
|
|
(cut string-any char-set:digit <>))
|
|
|
|
|
|
2014-02-27 18:01:53 -05:00
|
|
|
|
(define patch-directory-name?
|
|
|
|
|
;; Return #t for patch directory names such as 'bash-4.2-patches'.
|
|
|
|
|
(cut string-suffix? "patches" <>))
|
|
|
|
|
|
2015-12-07 17:18:06 -05:00
|
|
|
|
(define conn (ftp-open server))
|
|
|
|
|
|
|
|
|
|
(define (file->url directory file)
|
|
|
|
|
(string-append "ftp://" server directory "/" file))
|
|
|
|
|
|
|
|
|
|
(define (file->source directory file)
|
|
|
|
|
(let ((url (file->url directory file)))
|
|
|
|
|
(upstream-source
|
|
|
|
|
(package project)
|
|
|
|
|
(version (tarball->version file))
|
|
|
|
|
(urls (list url))
|
2015-12-07 17:54:35 -05:00
|
|
|
|
(signature-urls (match (file->signature url)
|
|
|
|
|
(#f #f)
|
|
|
|
|
(sig (list sig)))))))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
|
|
|
|
|
(let loop ((directory directory)
|
|
|
|
|
(result #f))
|
|
|
|
|
(let* ((entries (ftp-list conn directory))
|
|
|
|
|
|
|
|
|
|
;; Filter out sub-directories that do not contain digits---e.g.,
|
|
|
|
|
;; /gnuzilla/lang and /gnupg/patches. Filter out "w32"
|
|
|
|
|
;; directories as found on ftp.gnutls.org.
|
|
|
|
|
(subdirs (filter-map (match-lambda
|
|
|
|
|
(((? patch-directory-name? dir)
|
|
|
|
|
'directory . _)
|
|
|
|
|
#f)
|
|
|
|
|
(("w32" 'directory . _)
|
|
|
|
|
#f)
|
|
|
|
|
(((? contains-digit? dir) 'directory . _)
|
2015-12-09 15:59:32 -05:00
|
|
|
|
(and (keep-file? dir) dir))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
(_ #f))
|
|
|
|
|
entries))
|
|
|
|
|
|
|
|
|
|
;; Whether or not SUBDIRS is empty, compute the latest releases
|
|
|
|
|
;; for the current directory. This is necessary for packages
|
|
|
|
|
;; such as 'sharutils' that have a sub-directory that contains
|
|
|
|
|
;; only an older release.
|
|
|
|
|
(releases (filter-map (match-lambda
|
|
|
|
|
((file 'file . _)
|
|
|
|
|
(and (release-file? project file)
|
2015-12-08 10:05:55 -05:00
|
|
|
|
(keep-file? file)
|
2015-12-07 17:18:06 -05:00
|
|
|
|
(file->source directory file)))
|
|
|
|
|
(_ #f))
|
|
|
|
|
entries)))
|
|
|
|
|
|
|
|
|
|
;; Assume that SUBDIRS correspond to versions, and jump into the
|
|
|
|
|
;; one with the highest version number.
|
|
|
|
|
(let* ((release (reduce latest-release #f
|
|
|
|
|
(coalesce-sources releases)))
|
|
|
|
|
(result (if (and result release)
|
|
|
|
|
(latest-release release result)
|
|
|
|
|
(or release result)))
|
|
|
|
|
(target (reduce latest #f subdirs)))
|
|
|
|
|
(if target
|
|
|
|
|
(loop (string-append directory "/" target)
|
|
|
|
|
result)
|
|
|
|
|
(begin
|
|
|
|
|
(ftp-close conn)
|
|
|
|
|
result))))))
|
|
|
|
|
|
2016-04-14 16:18:56 -04:00
|
|
|
|
(define* (latest-release package
|
|
|
|
|
#:key
|
|
|
|
|
(server "ftp.gnu.org")
|
|
|
|
|
(directory (string-append "/gnu/" package)))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
"Return the <upstream-source> for the latest version of PACKAGE or #f.
|
2016-04-14 16:18:56 -04:00
|
|
|
|
PACKAGE must be the canonical name of a GNU package."
|
|
|
|
|
(latest-ftp-release package
|
|
|
|
|
#:server server
|
|
|
|
|
#:directory directory))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(define-syntax-rule (false-if-ftp-error exp)
|
|
|
|
|
"Return #f if an FTP error is raise while evaluating EXP; return the result
|
|
|
|
|
of EXP otherwise."
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(catch 'ftp-error
|
|
|
|
|
(lambda ()
|
2015-12-07 17:23:46 -05:00
|
|
|
|
exp)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(lambda (key port . rest)
|
|
|
|
|
(if (ftp-connection? port)
|
|
|
|
|
(ftp-close port)
|
|
|
|
|
(close-port port))
|
|
|
|
|
#f)))
|
2014-11-11 09:30:58 -05:00
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(define (latest-release* package)
|
2016-04-14 16:18:56 -04:00
|
|
|
|
"Like 'latest-release', but (1) take a <package> object, and (2) ignore FTP
|
|
|
|
|
errors that might occur when PACKAGE is not actually a GNU package, or not
|
|
|
|
|
hosted on ftp.gnu.org, or not under that name (this is the case for
|
|
|
|
|
\"emacs-auctex\", for instance.)"
|
|
|
|
|
(let-values (((server directory)
|
|
|
|
|
(ftp-server/directory package)))
|
|
|
|
|
(let ((name (or (assoc-ref (package-properties package) 'upstream-name)
|
|
|
|
|
(package-name package))))
|
|
|
|
|
(false-if-ftp-error (latest-release name
|
|
|
|
|
#:server server
|
|
|
|
|
#:directory directory)))))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
|
2013-01-08 16:46:12 -05:00
|
|
|
|
(define %package-name-rx
|
|
|
|
|
;; Regexp for a package name, e.g., "foo-X.Y". Since TeXmacs uses
|
|
|
|
|
;; "TeXmacs-X.Y-src", the `-src' suffix is allowed.
|
|
|
|
|
(make-regexp "^(.*)-(([0-9]|\\.)+)(-src)?"))
|
|
|
|
|
|
|
|
|
|
(define (gnu-package-name->name+version name+version)
|
|
|
|
|
"Return the package name and version number extracted from NAME+VERSION."
|
|
|
|
|
(let ((match (regexp-exec %package-name-rx name+version)))
|
|
|
|
|
(if (not match)
|
|
|
|
|
(values name+version #f)
|
|
|
|
|
(values (match:substring match 1) (match:substring match 2)))))
|
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(define (pure-gnu-package? package)
|
|
|
|
|
"Return true if PACKAGE is a non-Emacs and non-GNOME GNU package. This
|
|
|
|
|
excludes AucTeX, for instance, whose releases are now uploaded to
|
|
|
|
|
elpa.gnu.org, and all the GNOME packages."
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(and (not (string-prefix? "emacs-" (package-name package)))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(not (gnome-package? package))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(gnu-package? package)))
|
2013-04-24 17:48:36 -04:00
|
|
|
|
|
2016-11-30 09:56:55 -05:00
|
|
|
|
(define (url-prefix-predicate prefix)
|
|
|
|
|
"Return a predicate that returns true when passed a package where one of its
|
|
|
|
|
source URLs starts with PREFIX."
|
|
|
|
|
(lambda (package)
|
|
|
|
|
(define matching-uri?
|
|
|
|
|
(match-lambda
|
|
|
|
|
((? string? uri)
|
|
|
|
|
(string-prefix? prefix uri))
|
|
|
|
|
(_
|
|
|
|
|
#f)))
|
|
|
|
|
|
|
|
|
|
(match (package-source package)
|
|
|
|
|
((? origin? origin)
|
|
|
|
|
(match (origin-uri origin)
|
|
|
|
|
((? matching-uri?) #t)
|
|
|
|
|
(_ #f)))
|
|
|
|
|
(_ #f))))
|
|
|
|
|
|
|
|
|
|
(define gnome-package?
|
|
|
|
|
(url-prefix-predicate "mirror://gnome/"))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
|
|
|
|
|
(define (latest-gnome-release package)
|
|
|
|
|
"Return the latest release of PACKAGE, the name of a GNOME package."
|
2015-12-08 10:05:55 -05:00
|
|
|
|
(define %not-dot
|
|
|
|
|
(char-set-complement (char-set #\.)))
|
|
|
|
|
|
|
|
|
|
(define (even-minor-version? version)
|
2015-12-09 15:59:32 -05:00
|
|
|
|
(match (string-tokenize version %not-dot)
|
|
|
|
|
(((= string->number major) (= string->number minor) . rest)
|
|
|
|
|
(and minor (even? minor)))
|
2015-12-08 10:05:55 -05:00
|
|
|
|
(_
|
|
|
|
|
#t))) ;cross fingers
|
|
|
|
|
|
2015-12-09 15:59:32 -05:00
|
|
|
|
(define (even-numbered? file)
|
|
|
|
|
;; Return true if FILE somehow denotes an even-numbered file name. The
|
|
|
|
|
;; trick here is that we want this to match both directories such as
|
|
|
|
|
;; "3.18.6" and actual file names such as "gtk+-3.18.6.tar.bz2".
|
|
|
|
|
(let-values (((name version) (package-name->name+version file)))
|
|
|
|
|
(even-minor-version? (or version name))))
|
2015-12-08 10:05:55 -05:00
|
|
|
|
|
2016-10-20 16:17:07 -04:00
|
|
|
|
(define upstream-name
|
|
|
|
|
;; Some packages like "NetworkManager" have camel-case names.
|
|
|
|
|
(or (assoc-ref (package-properties package) 'upstream-name)
|
|
|
|
|
(package-name package)))
|
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(false-if-ftp-error
|
2016-10-20 16:17:07 -04:00
|
|
|
|
(latest-ftp-release upstream-name
|
2015-12-07 17:23:46 -05:00
|
|
|
|
#:server "ftp.gnome.org"
|
|
|
|
|
#:directory (string-append "/pub/gnome/sources/"
|
2016-10-20 16:17:07 -04:00
|
|
|
|
upstream-name)
|
2015-12-07 17:54:35 -05:00
|
|
|
|
|
2015-12-08 10:05:55 -05:00
|
|
|
|
|
|
|
|
|
;; <https://www.gnome.org/gnome-3/source/> explains
|
|
|
|
|
;; that odd minor version numbers represent development
|
|
|
|
|
;; releases, which we are usually not interested in.
|
2015-12-09 15:59:32 -05:00
|
|
|
|
#:keep-file? even-numbered?
|
2015-12-08 10:05:55 -05:00
|
|
|
|
|
2015-12-07 17:54:35 -05:00
|
|
|
|
;; ftp.gnome.org provides no signatures, only
|
|
|
|
|
;; checksums.
|
|
|
|
|
#:file->signature (const #f))))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
|
2016-08-01 05:05:28 -04:00
|
|
|
|
|
|
|
|
|
(define (latest-kde-release package)
|
|
|
|
|
"Return the latest release of PACKAGE, the name of an KDE.org package."
|
|
|
|
|
(let ((uri (string->uri (origin-uri (package-source package)))))
|
|
|
|
|
(false-if-ftp-error
|
|
|
|
|
(latest-ftp-release
|
2016-11-29 10:10:10 -05:00
|
|
|
|
(or (assoc-ref (package-properties package) 'upstream-name)
|
|
|
|
|
(package-name package))
|
2016-08-01 05:05:28 -04:00
|
|
|
|
#:server "mirrors.mit.edu"
|
|
|
|
|
#:directory
|
|
|
|
|
(string-append "/kde" (dirname (dirname (uri-path uri))))
|
|
|
|
|
#:file->signature (const #f)))))
|
|
|
|
|
|
2016-02-18 14:50:02 -05:00
|
|
|
|
(define (latest-xorg-release package)
|
|
|
|
|
"Return the latest release of PACKAGE, the name of an X.org package."
|
2016-04-14 15:40:20 -04:00
|
|
|
|
(let ((uri (string->uri (origin-uri (package-source package)))))
|
2016-02-18 14:50:02 -05:00
|
|
|
|
(false-if-ftp-error
|
|
|
|
|
(latest-ftp-release
|
2016-04-14 15:40:20 -04:00
|
|
|
|
(package-name package)
|
2016-02-18 14:50:02 -05:00
|
|
|
|
#:server "ftp.freedesktop.org"
|
|
|
|
|
#:directory
|
|
|
|
|
(string-append "/pub/xorg/" (dirname (uri-path uri)))))))
|
|
|
|
|
|
2016-11-30 10:29:15 -05:00
|
|
|
|
(define (latest-kernel.org-release package)
|
|
|
|
|
"Return the latest release of PACKAGE, the name of a kernel.org package."
|
|
|
|
|
(let ((uri (string->uri (origin-uri (package-source package)))))
|
|
|
|
|
(false-if-ftp-error
|
|
|
|
|
(latest-ftp-release
|
|
|
|
|
(package-name package)
|
|
|
|
|
#:server "ftp.free.fr" ;a mirror reachable over FTP
|
|
|
|
|
#:directory (string-append "/mirrors/ftp.kernel.org"
|
|
|
|
|
(dirname (uri-path uri)))
|
|
|
|
|
|
|
|
|
|
;; kernel.org provides "foo-x.y.tar.sign" files, which are signatures of
|
|
|
|
|
;; the uncompressed tarball.
|
|
|
|
|
#:file->signature (lambda (tarball)
|
|
|
|
|
(string-append (file-sans-extension tarball)
|
|
|
|
|
".sign"))))))
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(define %gnu-updater
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'gnu)
|
|
|
|
|
(description "Updater for GNU packages")
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(pred pure-gnu-package?)
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(latest latest-release*)))
|
2013-04-24 17:48:36 -04:00
|
|
|
|
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(define %gnome-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'gnome)
|
|
|
|
|
(description "Updater for GNOME packages")
|
|
|
|
|
(pred gnome-package?)
|
|
|
|
|
(latest latest-gnome-release)))
|
|
|
|
|
|
2016-08-01 05:05:28 -04:00
|
|
|
|
(define %kde-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'kde)
|
|
|
|
|
(description "Updater for KDE packages")
|
2016-11-30 09:56:55 -05:00
|
|
|
|
(pred (url-prefix-predicate "mirror://kde/"))
|
2016-08-01 05:05:28 -04:00
|
|
|
|
(latest latest-kde-release)))
|
|
|
|
|
|
2016-02-18 14:50:02 -05:00
|
|
|
|
(define %xorg-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'xorg)
|
|
|
|
|
(description "Updater for X.org packages")
|
2016-11-30 09:56:55 -05:00
|
|
|
|
(pred (url-prefix-predicate "mirror://xorg/"))
|
2016-02-18 14:50:02 -05:00
|
|
|
|
(latest latest-xorg-release)))
|
|
|
|
|
|
2016-11-30 10:29:15 -05:00
|
|
|
|
(define %kernel.org-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'kernel.org)
|
|
|
|
|
(description "Updater for packages hosted on kernel.org")
|
|
|
|
|
(pred (url-prefix-predicate "mirror://kernel.org/"))
|
|
|
|
|
(latest latest-kernel.org-release)))
|
|
|
|
|
|
2013-01-08 16:46:12 -05:00
|
|
|
|
;;; gnu-maintenance.scm ends here
|