2013-01-05 18:47:50 -05:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2021-03-13 06:45:13 -05:00
|
|
|
|
;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
2013-03-28 17:40:41 -04:00
|
|
|
|
;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
2021-01-27 18:46:01 -05:00
|
|
|
|
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
|
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)
|
2018-11-10 10:20:25 -05:00
|
|
|
|
#:use-module (sxml simple)
|
2012-12-04 18:02:22 -05:00
|
|
|
|
#: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)
|
2021-03-13 16:25:12 -05:00
|
|
|
|
#:use-module (srfi srfi-34)
|
2017-09-03 17:31:09 -04:00
|
|
|
|
#:use-module (rnrs io ports)
|
2013-01-08 16:46:12 -05:00
|
|
|
|
#:use-module (system foreign)
|
2021-04-08 03:34:03 -04:00
|
|
|
|
#:use-module ((guix http-client) #:hide (open-socket-for-uri))
|
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)
|
Add (guix memoization).
* guix/combinators.scm (memoize): Remove.
* guix/memoization.scm: New file.
* Makefile.am (MODULES): Add it.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
guix/build-system/gnu.scm, guix/build-system/python.scm,
guix/derivations.scm, guix/gnu-maintenance.scm,
guix/import/cran.scm, guix/import/elpa.scm,
guix/modules.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/store.scm, guix/utils.scm: Adjust imports accordingly.
2017-01-28 10:33:57 -05:00
|
|
|
|
#:use-module (guix memoization)
|
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)
|
2021-03-13 06:41:43 -05:00
|
|
|
|
#:autoload (zlib) (call-with-gzip-input-port)
|
2021-03-13 06:39:34 -05:00
|
|
|
|
#:autoload (htmlprag) (html->sxml) ;from Guile-Lib
|
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
|
2017-09-03 17:31:09 -04:00
|
|
|
|
%gnu-ftp-updater
|
2020-07-20 14:36:53 -04:00
|
|
|
|
%savannah-updater
|
2021-04-04 16:33:44 -04:00
|
|
|
|
%sourceforge-updater
|
2016-11-30 10:29:15 -05:00
|
|
|
|
%xorg-updater
|
2021-03-13 16:25:12 -05:00
|
|
|
|
%kernel.org-updater
|
|
|
|
|
%generic-html-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
|
2019-05-12 17:15:13 -04:00
|
|
|
|
"https://web.cvs.savannah.gnu.org/viewvc/*checkout*/www/www/prep/gnumaint/")
|
2013-10-09 07:00:00 -04:00
|
|
|
|
|
2012-12-04 18:02:22 -05:00
|
|
|
|
(define %package-list-url
|
2013-04-25 16:06:48 -04:00
|
|
|
|
(string->uri
|
2018-07-11 08:28:23 -04:00
|
|
|
|
(string-append %gnumaint-base-url "rec/gnupackages.rec")))
|
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.
|
2018-07-11 08:28:23 -04:00
|
|
|
|
;; See <https://lists.gnu.org/archive/html/guix-devel/2013-10/msg00071.html>
|
|
|
|
|
;; and <https://lists.gnu.org/archive/html/guix-devel/2018-06/msg00362.html>.
|
2013-10-09 07:00:00 -04:00
|
|
|
|
(string->uri
|
2018-07-11 08:28:23 -04:00
|
|
|
|
(string-append %gnumaint-base-url "rec/pkgblurbs.rec")))
|
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)
|
2018-07-11 08:28:23 -04:00
|
|
|
|
|
|
|
|
|
;; Ignore things like "%rec" (info "(recutils) Record
|
|
|
|
|
;; Descriptors").
|
|
|
|
|
(if (assoc-ref alist "package")
|
|
|
|
|
(cons alist result)
|
|
|
|
|
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
|
2018-07-11 08:28:23 -04:00
|
|
|
|
(list "package" "mundane_name" "copyright_holder"
|
2013-07-10 16:33:40 -04:00
|
|
|
|
"savannah" "fsd" "language" "logo"
|
2018-07-11 08:28:23 -04:00
|
|
|
|
"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?
|
2017-01-28 11:09:34 -05:00
|
|
|
|
(let ((official-gnu-packages (memoize official-gnu-packages)))
|
2017-01-28 11:17:13 -05:00
|
|
|
|
(mlambdaq (package)
|
2017-01-28 11:09:34 -05:00
|
|
|
|
"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."
|
2017-01-28 11:09:34 -05:00
|
|
|
|
(define (mirror-type url)
|
|
|
|
|
(let ((uri (string->uri url)))
|
|
|
|
|
(and (eq? (uri-scheme uri) 'mirror)
|
|
|
|
|
(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)))))
|
|
|
|
|
|
|
|
|
|
(define (gnu-home-page? package)
|
|
|
|
|
(letrec-syntax ((>> (syntax-rules ()
|
|
|
|
|
((_ value proc)
|
|
|
|
|
(and=> value proc))
|
|
|
|
|
((_ value proc rest ...)
|
|
|
|
|
(and=> value
|
|
|
|
|
(lambda (next)
|
|
|
|
|
(>> (proc next) rest ...)))))))
|
|
|
|
|
(>> package package-home-page
|
|
|
|
|
string->uri uri-host
|
|
|
|
|
(lambda (host)
|
|
|
|
|
(member host '("www.gnu.org" "gnu.org"))))))
|
|
|
|
|
|
|
|
|
|
(or (gnu-home-page? package)
|
2020-07-03 16:48:04 -04:00
|
|
|
|
(match (package-source package)
|
|
|
|
|
((? origin? origin)
|
|
|
|
|
(let ((url (origin-uri origin))
|
|
|
|
|
(name (package-upstream-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)))))
|
|
|
|
|
(_ #f))))))
|
2013-03-05 14:30:27 -05:00
|
|
|
|
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
|
|
|
|
;;;
|
2018-11-10 10:20:25 -05:00
|
|
|
|
;;; Latest FTP release.
|
2013-01-08 16:46:12 -05:00
|
|
|
|
;;;
|
|
|
|
|
|
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."
|
2017-01-27 18:11:33 -05:00
|
|
|
|
(let ((name (package-upstream-name package)))
|
2017-01-27 17:20:59 -05:00
|
|
|
|
(values (or (assoc-ref (package-properties package) 'ftp-server)
|
|
|
|
|
"ftp.gnu.org")
|
|
|
|
|
(or (assoc-ref (package-properties package) 'ftp-directory)
|
|
|
|
|
(string-append "/gnu/" name)))))
|
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".
|
2021-03-20 16:53:27 -04:00
|
|
|
|
;; Accept underscores as in "PKG_1.2.tar.gz" for some non-GNU packages.
|
2021-05-28 16:43:21 -04:00
|
|
|
|
;; Accept 'v' or 'V' prefix as in 'PKG-v2.3.tgz'.
|
|
|
|
|
(make-regexp "^([^.]+)[-_][vV]?([0-9]|[^-])+(-(src|[sS]ource|gnu[0-9]))?\\.(tar\\.|tgz|zip$)"))
|
2013-04-24 17:37:14 -04:00
|
|
|
|
|
|
|
|
|
(define %alpha-tarball-rx
|
2020-07-20 17:41:22 -04:00
|
|
|
|
(make-regexp "^.*-.*[0-9](-|~)?(alpha|beta|rc|RC|cvs|svn|git)-?[0-9\\.]*\\.tar\\."))
|
2013-04-24 17:37:14 -04:00
|
|
|
|
|
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."
|
2021-03-13 11:51:22 -05:00
|
|
|
|
(and (not (member (file-extension file)
|
|
|
|
|
'("sig" "sign" "asc"
|
|
|
|
|
"md5sum" "sha1sum" "sha256sum")))
|
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))
|
2019-08-27 12:20:16 -04:00
|
|
|
|
(let ((s (tarball-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)
|
2019-08-27 12:20:16 -04:00
|
|
|
|
(gnu-package-name->name+version
|
|
|
|
|
(tarball-sans-extension tarball))))
|
2014-11-11 08:59:38 -05:00
|
|
|
|
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))
|
2021-03-17 06:36:59 -04:00
|
|
|
|
(file->signature (cut string-append <> ".sig")))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
"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.
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
|
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" <>))
|
|
|
|
|
|
2021-03-17 06:43:07 -04:00
|
|
|
|
(define conn (ftp-open server #:timeout 5))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
|
|
|
|
|
(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))
|
2021-01-27 18:46:01 -05:00
|
|
|
|
(let* ((entries (catch 'ftp-error
|
|
|
|
|
(lambda _ (ftp-list conn directory))
|
|
|
|
|
(const '())))
|
2015-12-07 17:18:06 -05:00
|
|
|
|
|
2017-11-24 12:44:08 -05:00
|
|
|
|
;; Filter out things like /gnupg/patches. Filter out "w32"
|
2015-12-07 17:18:06 -05:00
|
|
|
|
;; directories as found on ftp.gnutls.org.
|
|
|
|
|
(subdirs (filter-map (match-lambda
|
|
|
|
|
(((? patch-directory-name? dir)
|
|
|
|
|
'directory . _)
|
|
|
|
|
#f)
|
|
|
|
|
(("w32" 'directory . _)
|
|
|
|
|
#f)
|
2017-12-17 10:52:27 -05:00
|
|
|
|
(("unstable" 'directory . _)
|
|
|
|
|
;; As seen at ftp.gnupg.org/gcrypt/pinentry.
|
|
|
|
|
#f)
|
2017-11-24 12:44:08 -05:00
|
|
|
|
((directory 'directory . _)
|
|
|
|
|
directory)
|
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)
|
|
|
|
|
(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)))
|
2017-01-27 18:11:33 -05:00
|
|
|
|
(false-if-ftp-error (latest-release (package-upstream-name package)
|
|
|
|
|
#:server server
|
|
|
|
|
#:directory directory))))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
|
2018-11-10 10:20:25 -05:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Latest HTTP release.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (html-links sxml)
|
|
|
|
|
"Return the list of links found in SXML, the SXML tree of an HTML page."
|
|
|
|
|
(let loop ((sxml sxml)
|
|
|
|
|
(links '()))
|
|
|
|
|
(match sxml
|
|
|
|
|
(('a ('@ attributes ...) body ...)
|
|
|
|
|
(match (assq 'href attributes)
|
|
|
|
|
(#f (fold loop links body))
|
|
|
|
|
(('href url) (fold loop (cons url links) body))))
|
|
|
|
|
((tag ('@ _ ...) body ...)
|
|
|
|
|
(fold loop links body))
|
|
|
|
|
((tag body ...)
|
|
|
|
|
(fold loop links body))
|
|
|
|
|
(_
|
|
|
|
|
links))))
|
|
|
|
|
|
|
|
|
|
(define* (latest-html-release package
|
|
|
|
|
#:key
|
|
|
|
|
(base-url "https://kernel.org/pub")
|
|
|
|
|
(directory (string-append "/" package))
|
2021-03-13 11:56:26 -05:00
|
|
|
|
file->signature)
|
2018-11-10 10:20:25 -05:00
|
|
|
|
"Return an <upstream-source> for the latest release of PACKAGE (a string) on
|
|
|
|
|
SERVER under DIRECTORY, or #f. BASE-URL should be the URL of an HTML page,
|
|
|
|
|
typically a directory listing as found on 'https://kernel.org/pub'.
|
|
|
|
|
|
2021-03-13 11:56:26 -05:00
|
|
|
|
When FILE->SIGNATURE is omitted or #f, guess the detached signature file name,
|
|
|
|
|
if any. Otherwise, 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."
|
2021-03-18 10:15:44 -04:00
|
|
|
|
(let* ((uri (string->uri (if (string-null? directory)
|
|
|
|
|
base-url
|
|
|
|
|
(string-append base-url directory "/"))))
|
2021-03-13 11:56:26 -05:00
|
|
|
|
(port (http-fetch/cached uri #:ttl 3600))
|
|
|
|
|
(sxml (html->sxml port))
|
|
|
|
|
(links (delete-duplicates (html-links sxml))))
|
|
|
|
|
(define (file->signature/guess url)
|
|
|
|
|
(let ((base (basename url)))
|
|
|
|
|
(any (lambda (link)
|
|
|
|
|
(any (lambda (extension)
|
|
|
|
|
(and (string=? (string-append base extension)
|
|
|
|
|
(basename link))
|
|
|
|
|
(string-append url extension)))
|
|
|
|
|
'(".asc" ".sig" ".sign")))
|
|
|
|
|
links)))
|
|
|
|
|
|
2018-11-10 10:20:25 -05:00
|
|
|
|
(define (url->release url)
|
2021-03-13 06:45:13 -05:00
|
|
|
|
(let* ((base (basename url))
|
2021-05-28 16:56:38 -04:00
|
|
|
|
(base-url (string-append base-url directory))
|
|
|
|
|
(url (cond ((and=> (string->uri url) uri-scheme) ;full URL?
|
|
|
|
|
url)
|
|
|
|
|
((string-prefix? "/" url) ;absolute path?
|
|
|
|
|
(let ((uri (string->uri base-url)))
|
|
|
|
|
(uri->string
|
|
|
|
|
(build-uri (uri-scheme uri)
|
|
|
|
|
#:host (uri-host uri)
|
|
|
|
|
#:port (uri-port uri)
|
|
|
|
|
#:path url))))
|
|
|
|
|
|
2021-06-03 06:58:41 -04:00
|
|
|
|
;; URL is a relative path and BASE-URL may or may not
|
2021-05-28 16:56:38 -04:00
|
|
|
|
;; end in slash.
|
|
|
|
|
((string-suffix? "/" base-url)
|
|
|
|
|
(string-append base-url url))
|
|
|
|
|
(else
|
2021-06-03 06:58:41 -04:00
|
|
|
|
;; If DIRECTORY is non-empty, assume BASE-URL
|
|
|
|
|
;; denotes a directory; otherwise, assume BASE-URL
|
|
|
|
|
;; denotes a file within a directory, and that URL
|
|
|
|
|
;; is relative to that directory.
|
|
|
|
|
(string-append (if (string-null? directory)
|
|
|
|
|
(dirname base-url)
|
|
|
|
|
base-url)
|
|
|
|
|
"/" url)))))
|
2021-03-13 06:45:13 -05:00
|
|
|
|
(and (release-file? package base)
|
2021-03-13 16:35:28 -05:00
|
|
|
|
(let ((version (tarball->version base)))
|
2021-03-13 06:45:13 -05:00
|
|
|
|
(upstream-source
|
2021-03-13 16:35:28 -05:00
|
|
|
|
(package package)
|
2021-03-13 06:45:13 -05:00
|
|
|
|
(version version)
|
|
|
|
|
(urls (list url))
|
|
|
|
|
(signature-urls
|
2021-03-13 11:56:26 -05:00
|
|
|
|
(list ((or file->signature file->signature/guess) url))))))))
|
2018-11-10 10:20:25 -05:00
|
|
|
|
|
|
|
|
|
(define candidates
|
2021-03-13 11:56:26 -05:00
|
|
|
|
(filter-map url->release links))
|
2018-11-10 10:20:25 -05:00
|
|
|
|
|
|
|
|
|
(close-port port)
|
|
|
|
|
(match candidates
|
|
|
|
|
(() #f)
|
|
|
|
|
((first . _)
|
|
|
|
|
;; Select the most recent release and return it.
|
|
|
|
|
(reduce (lambda (r1 r2)
|
|
|
|
|
(if (version>? (upstream-source-version r1)
|
|
|
|
|
(upstream-source-version r2))
|
|
|
|
|
r1 r2))
|
|
|
|
|
first
|
|
|
|
|
(coalesce-sources candidates))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Updaters.
|
|
|
|
|
;;;
|
|
|
|
|
|
2017-09-03 17:31:09 -04:00
|
|
|
|
(define %gnu-file-list-uri
|
|
|
|
|
;; URI of the file list for ftp.gnu.org.
|
|
|
|
|
(string->uri "https://ftp.gnu.org/find.txt.gz"))
|
|
|
|
|
|
|
|
|
|
(define ftp.gnu.org-files
|
|
|
|
|
(mlambda ()
|
|
|
|
|
"Return the list of files available at ftp.gnu.org."
|
|
|
|
|
|
|
|
|
|
;; XXX: Memoize the whole procedure to work around the fact that
|
|
|
|
|
;; 'http-fetch/cached' caches the gzipped version.
|
|
|
|
|
|
|
|
|
|
(define (trim-leading-components str)
|
|
|
|
|
;; Trim the leading ".", if any, in "./gnu/foo".
|
|
|
|
|
(string-trim str (char-set #\.)))
|
|
|
|
|
|
|
|
|
|
(define (string->lines str)
|
|
|
|
|
(string-tokenize str (char-set-complement (char-set #\newline))))
|
|
|
|
|
|
2017-09-19 05:49:29 -04:00
|
|
|
|
;; Since https://ftp.gnu.org honors 'If-Modified-Since', the hard-coded
|
|
|
|
|
;; TTL can be relatively short.
|
|
|
|
|
(let ((port (http-fetch/cached %gnu-file-list-uri #:ttl (* 15 60))))
|
2017-09-03 17:31:09 -04:00
|
|
|
|
(map trim-leading-components
|
|
|
|
|
(call-with-gzip-input-port port
|
|
|
|
|
(compose string->lines get-string-all))))))
|
|
|
|
|
|
|
|
|
|
(define (latest-gnu-release package)
|
|
|
|
|
"Return the latest release of PACKAGE, a GNU package available via
|
|
|
|
|
ftp.gnu.org.
|
|
|
|
|
|
|
|
|
|
This method does not rely on FTP access at all; instead, it browses the file
|
|
|
|
|
list available from %GNU-FILE-LIST-URI over HTTP(S)."
|
|
|
|
|
(let-values (((server directory)
|
|
|
|
|
(ftp-server/directory package))
|
|
|
|
|
((name)
|
|
|
|
|
(package-upstream-name package)))
|
|
|
|
|
(let* ((files (ftp.gnu.org-files))
|
|
|
|
|
(relevant (filter (lambda (file)
|
2017-09-11 05:45:30 -04:00
|
|
|
|
(and (string-prefix? "/gnu" file)
|
|
|
|
|
(string-contains file directory)
|
2017-09-11 05:40:32 -04:00
|
|
|
|
(release-file? name (basename file))))
|
2017-09-03 17:31:09 -04:00
|
|
|
|
files)))
|
|
|
|
|
(match (sort relevant (lambda (file1 file2)
|
2019-08-27 12:20:16 -04:00
|
|
|
|
(version>? (tarball-sans-extension
|
|
|
|
|
(basename file1))
|
|
|
|
|
(tarball-sans-extension
|
|
|
|
|
(basename file2)))))
|
2017-09-11 05:45:30 -04:00
|
|
|
|
((and tarballs (reference _ ...))
|
|
|
|
|
(let* ((version (tarball->version reference))
|
|
|
|
|
(tarballs (filter (lambda (file)
|
2019-08-27 12:20:16 -04:00
|
|
|
|
(string=? (tarball-sans-extension
|
2017-09-11 05:45:30 -04:00
|
|
|
|
(basename file))
|
2019-08-27 12:20:16 -04:00
|
|
|
|
(tarball-sans-extension
|
2017-09-11 05:45:30 -04:00
|
|
|
|
(basename reference))))
|
|
|
|
|
tarballs)))
|
|
|
|
|
(upstream-source
|
|
|
|
|
(package name)
|
|
|
|
|
(version version)
|
|
|
|
|
(urls (map (lambda (file)
|
|
|
|
|
(string-append "mirror://gnu/"
|
|
|
|
|
(string-drop file
|
|
|
|
|
(string-length "/gnu/"))))
|
|
|
|
|
tarballs))
|
|
|
|
|
(signature-urls (map (cut string-append <> ".sig") urls)))))
|
2017-09-03 17:31:09 -04:00
|
|
|
|
(()
|
|
|
|
|
#f)))))
|
|
|
|
|
|
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.
|
2021-05-28 16:43:21 -04:00
|
|
|
|
(make-regexp "^(.*)[-_][vV]?(([0-9]|\\.)+)(-src|\\.src|\\.orig)?"))
|
2013-01-08 16:46:12 -05:00
|
|
|
|
|
|
|
|
|
(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)))))
|
|
|
|
|
|
2017-09-25 17:58:02 -04:00
|
|
|
|
(define gnome-package?
|
|
|
|
|
(url-prefix-predicate "mirror://gnome/"))
|
|
|
|
|
|
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
|
2021-03-21 18:28:13 -04:00
|
|
|
|
elpa.gnu.org, GNU Radio, which has releases at www.gnuradio.org, and all the
|
|
|
|
|
GNOME packages; EMMS is included though, because its releases are on gnu.org."
|
2017-01-27 17:24:21 -05:00
|
|
|
|
(and (or (not (string-prefix? "emacs-" (package-name package)))
|
|
|
|
|
(gnu-hosted? package))
|
2015-12-07 17:23:46 -05:00
|
|
|
|
(not (gnome-package? package))
|
2021-03-21 18:28:13 -04:00
|
|
|
|
(not (string-prefix? "gnuradio" (package-name package)))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(gnu-package? package)))
|
2013-04-24 17:48:36 -04:00
|
|
|
|
|
2017-01-27 17:24:21 -05:00
|
|
|
|
(define gnu-hosted?
|
|
|
|
|
(url-prefix-predicate "mirror://gnu/"))
|
|
|
|
|
|
2020-07-20 15:26:51 -04:00
|
|
|
|
(define (url-prefix-rewrite old new)
|
|
|
|
|
"Return a one-argument procedure that rewrites URL prefix OLD to NEW."
|
|
|
|
|
(lambda (url)
|
2021-03-13 11:56:26 -05:00
|
|
|
|
(if (and url (string-prefix? old url))
|
2020-07-20 15:26:51 -04:00
|
|
|
|
(string-append new (string-drop url (string-length old)))
|
|
|
|
|
url)))
|
|
|
|
|
|
|
|
|
|
(define (adjusted-upstream-source source rewrite-url)
|
|
|
|
|
"Rewrite URLs in SOURCE by apply REWRITE-URL to each of them."
|
|
|
|
|
(upstream-source
|
|
|
|
|
(inherit source)
|
|
|
|
|
(urls (map rewrite-url (upstream-source-urls source)))
|
|
|
|
|
(signature-urls (and=> (upstream-source-signature-urls source)
|
|
|
|
|
(lambda (urls)
|
|
|
|
|
(map rewrite-url urls))))))
|
|
|
|
|
|
2020-07-20 14:36:53 -04:00
|
|
|
|
(define %savannah-base
|
|
|
|
|
;; One of the Savannah mirrors listed at
|
|
|
|
|
;; <http://download0.savannah.gnu.org/mirmon/savannah/> that serves valid
|
|
|
|
|
;; HTML (unlike <https://download.savannah.nongnu.org/releases>.)
|
|
|
|
|
"https://nongnu.freemirror.org/nongnu")
|
|
|
|
|
|
|
|
|
|
(define (latest-savannah-release package)
|
|
|
|
|
"Return the latest release of PACKAGE."
|
2020-07-20 17:36:33 -04:00
|
|
|
|
(let* ((uri (string->uri
|
|
|
|
|
(match (origin-uri (package-source package))
|
|
|
|
|
((? string? uri) uri)
|
|
|
|
|
((uri mirrors ...) uri))))
|
2020-07-20 14:36:53 -04:00
|
|
|
|
(package (package-upstream-name package))
|
2020-07-20 15:26:51 -04:00
|
|
|
|
(directory (dirname (uri-path uri)))
|
|
|
|
|
(rewrite (url-prefix-rewrite %savannah-base
|
|
|
|
|
"mirror://savannah")))
|
2021-03-13 11:56:26 -05:00
|
|
|
|
;; Note: We use the default 'file->signature', which adds ".sig", ".asc",
|
|
|
|
|
;; or whichever detached signature naming scheme PACKAGE uses.
|
2020-07-20 17:31:48 -04:00
|
|
|
|
(and=> (latest-html-release package
|
|
|
|
|
#:base-url %savannah-base
|
|
|
|
|
#:directory directory)
|
|
|
|
|
(cut adjusted-upstream-source <> rewrite))))
|
2020-07-20 14:36:53 -04:00
|
|
|
|
|
2021-04-04 16:33:44 -04:00
|
|
|
|
(define (latest-sourceforge-release package)
|
|
|
|
|
"Return the latest release of PACKAGE."
|
|
|
|
|
(define (uri-append uri extension)
|
|
|
|
|
;; Return URI with EXTENSION appended.
|
|
|
|
|
(build-uri (uri-scheme uri)
|
|
|
|
|
#:host (uri-host uri)
|
|
|
|
|
#:path (string-append (uri-path uri) extension)))
|
|
|
|
|
|
2021-04-08 03:34:03 -04:00
|
|
|
|
(define (valid-uri? uri port)
|
2021-04-04 16:33:44 -04:00
|
|
|
|
;; Return true if URI is reachable.
|
|
|
|
|
(false-if-exception
|
2021-04-08 03:34:03 -04:00
|
|
|
|
(case (response-code (http-head uri #:port port #:keep-alive? #t))
|
2021-04-04 16:33:44 -04:00
|
|
|
|
((200 302) #t)
|
|
|
|
|
(else #f))))
|
|
|
|
|
|
|
|
|
|
(let* ((name (package-upstream-name package))
|
|
|
|
|
(base (string-append "https://sourceforge.net/projects/"
|
|
|
|
|
name "/files"))
|
|
|
|
|
(url (string-append base "/latest/download"))
|
2021-04-08 03:34:03 -04:00
|
|
|
|
(uri (string->uri url))
|
|
|
|
|
(port (false-if-exception (open-socket-for-uri uri)))
|
|
|
|
|
(response (and port
|
|
|
|
|
(http-head uri #:port port #:keep-alive? #t))))
|
|
|
|
|
(dynamic-wind
|
|
|
|
|
(const #t)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(and response
|
|
|
|
|
(= 302 (response-code response))
|
|
|
|
|
(response-location response)
|
|
|
|
|
(match (string-tokenize (uri-path (response-location response))
|
|
|
|
|
(char-set-complement (char-set #\/)))
|
|
|
|
|
((_ components ...)
|
|
|
|
|
(let* ((path (string-join components "/"))
|
|
|
|
|
(url (string-append "mirror://sourceforge/" path)))
|
|
|
|
|
(and (release-file? name (basename path))
|
|
|
|
|
|
|
|
|
|
;; Take the heavy-handed approach of probing 3 additional
|
|
|
|
|
;; URLs. XXX: Would be nicer if this could be avoided.
|
|
|
|
|
(let* ((loc (response-location response))
|
|
|
|
|
(sig (any (lambda (extension)
|
|
|
|
|
(let ((uri (uri-append loc extension)))
|
|
|
|
|
(and (valid-uri? uri port)
|
|
|
|
|
(string-append url extension))))
|
|
|
|
|
'(".asc" ".sig" ".sign"))))
|
|
|
|
|
(upstream-source
|
|
|
|
|
(package name)
|
|
|
|
|
(version (tarball->version (basename path)))
|
|
|
|
|
(urls (list url))
|
|
|
|
|
(signature-urls (and sig (list sig)))))))))))
|
|
|
|
|
(lambda ()
|
|
|
|
|
(when port
|
|
|
|
|
(close-port port))))))
|
2021-04-04 16:33:44 -04:00
|
|
|
|
|
2016-02-18 14:50:02 -05:00
|
|
|
|
(define (latest-xorg-release package)
|
2020-07-20 14:36:53 -04:00
|
|
|
|
"Return the latest release of 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."
|
2018-11-10 10:20:25 -05:00
|
|
|
|
(define %kernel.org-base
|
|
|
|
|
;; This URL and sub-directories thereof are nginx-generated directory
|
|
|
|
|
;; listings suitable for 'latest-html-release'.
|
|
|
|
|
"https://mirrors.edge.kernel.org/pub")
|
|
|
|
|
|
|
|
|
|
(define (file->signature file)
|
|
|
|
|
(string-append (file-sans-extension file) ".sign"))
|
|
|
|
|
|
2020-07-20 17:36:33 -04:00
|
|
|
|
(let* ((uri (string->uri
|
|
|
|
|
(match (origin-uri (package-source package))
|
|
|
|
|
((? string? uri) uri)
|
|
|
|
|
((uri mirrors ...) uri))))
|
2018-11-10 10:20:25 -05:00
|
|
|
|
(package (package-upstream-name package))
|
2020-07-20 15:26:51 -04:00
|
|
|
|
(directory (dirname (uri-path uri)))
|
|
|
|
|
(rewrite (url-prefix-rewrite %kernel.org-base
|
|
|
|
|
"mirror://kernel.org")))
|
2020-07-20 17:31:48 -04:00
|
|
|
|
(and=> (latest-html-release package
|
|
|
|
|
#:base-url %kernel.org-base
|
|
|
|
|
#:directory directory
|
|
|
|
|
#:file->signature file->signature)
|
|
|
|
|
(cut adjusted-upstream-source <> rewrite))))
|
2016-11-30 10:29:15 -05:00
|
|
|
|
|
2021-03-13 16:25:12 -05:00
|
|
|
|
(define html-updatable-package?
|
|
|
|
|
;; Return true if the given package may be handled by the generic HTML
|
|
|
|
|
;; updater.
|
|
|
|
|
(let ((hosting-sites '("github.com" "github.io" "gitlab.com"
|
|
|
|
|
"notabug.org" "sr.ht"
|
|
|
|
|
"gforge.inria.fr" "gitlab.inria.fr"
|
|
|
|
|
"ftp.gnu.org" "download.savannah.gnu.org"
|
|
|
|
|
"pypi.org" "crates.io" "rubygems.org"
|
|
|
|
|
"bioconductor.org")))
|
2021-04-04 09:40:39 -04:00
|
|
|
|
(define http-url?
|
|
|
|
|
(url-predicate (lambda (url)
|
|
|
|
|
(match (string->uri url)
|
|
|
|
|
(#f #f)
|
|
|
|
|
(uri
|
|
|
|
|
(let ((scheme (uri-scheme uri))
|
|
|
|
|
(host (uri-host uri)))
|
|
|
|
|
(and (memq scheme '(http https))
|
|
|
|
|
(not (member host hosting-sites)))))))))
|
|
|
|
|
|
|
|
|
|
(lambda (package)
|
|
|
|
|
(or (assoc-ref (package-properties package) 'release-monitoring-url)
|
|
|
|
|
(http-url? package)))))
|
2021-03-13 16:25:12 -05:00
|
|
|
|
|
|
|
|
|
(define (latest-html-updatable-release package)
|
|
|
|
|
"Return the latest release of PACKAGE. Do that by crawling the HTML page of
|
|
|
|
|
the directory containing its source tarball."
|
|
|
|
|
(let* ((uri (string->uri
|
|
|
|
|
(match (origin-uri (package-source package))
|
|
|
|
|
((? string? url) url)
|
|
|
|
|
((url _ ...) url))))
|
|
|
|
|
(custom (assoc-ref (package-properties package)
|
|
|
|
|
'release-monitoring-url))
|
|
|
|
|
(base (or custom
|
|
|
|
|
(string-append (symbol->string (uri-scheme uri))
|
|
|
|
|
"://" (uri-host uri))))
|
|
|
|
|
(directory (if custom
|
|
|
|
|
""
|
|
|
|
|
(dirname (uri-path uri))))
|
|
|
|
|
(package (package-upstream-name package)))
|
|
|
|
|
(catch #t
|
|
|
|
|
(lambda ()
|
|
|
|
|
(guard (c ((http-get-error? c) #f))
|
|
|
|
|
(latest-html-release package
|
|
|
|
|
#:base-url base
|
|
|
|
|
#:directory directory)))
|
|
|
|
|
(lambda (key . args)
|
|
|
|
|
;; Return false and move on upon connection failures and bogus HTTP
|
|
|
|
|
;; servers.
|
|
|
|
|
(unless (memq key '(gnutls-error tls-certificate-error
|
|
|
|
|
system-error
|
|
|
|
|
bad-header bad-header-component))
|
|
|
|
|
(apply throw key args))
|
|
|
|
|
#f))))
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(define %gnu-updater
|
2017-09-03 17:31:09 -04:00
|
|
|
|
;; This is for everything at ftp.gnu.org.
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'gnu)
|
|
|
|
|
(description "Updater for GNU packages")
|
2017-09-03 17:31:09 -04:00
|
|
|
|
(pred gnu-hosted?)
|
|
|
|
|
(latest latest-gnu-release)))
|
|
|
|
|
|
|
|
|
|
(define %gnu-ftp-updater
|
|
|
|
|
;; This is for GNU packages taken from alternate locations, such as
|
|
|
|
|
;; alpha.gnu.org, ftp.gnupg.org, etc. It is obsolescent.
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'gnu-ftp)
|
|
|
|
|
(description "Updater for GNU packages only available via FTP")
|
|
|
|
|
(pred (lambda (package)
|
|
|
|
|
(and (not (gnu-hosted? package))
|
|
|
|
|
(pure-gnu-package? package))))
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(latest latest-release*)))
|
2013-04-24 17:48:36 -04:00
|
|
|
|
|
2020-07-20 14:36:53 -04:00
|
|
|
|
(define %savannah-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'savannah)
|
|
|
|
|
(description "Updater for packages hosted on savannah.gnu.org")
|
|
|
|
|
(pred (url-prefix-predicate "mirror://savannah/"))
|
|
|
|
|
(latest latest-savannah-release)))
|
|
|
|
|
|
2021-04-04 16:33:44 -04:00
|
|
|
|
(define %sourceforge-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'sourceforge)
|
|
|
|
|
(description "Updater for packages hosted on sourceforge.net")
|
|
|
|
|
(pred (url-prefix-predicate "mirror://sourceforge/"))
|
|
|
|
|
(latest latest-sourceforge-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)))
|
|
|
|
|
|
2021-03-13 16:25:12 -05:00
|
|
|
|
(define %generic-html-updater
|
|
|
|
|
(upstream-updater
|
|
|
|
|
(name 'generic-html)
|
|
|
|
|
(description "Updater that crawls HTML pages.")
|
|
|
|
|
(pred html-updatable-package?)
|
|
|
|
|
(latest latest-html-updatable-release)))
|
|
|
|
|
|
2013-01-08 16:46:12 -05:00
|
|
|
|
;;; gnu-maintenance.scm ends here
|