unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
blob 42f43833a90fde266277eb0d94162d5c74589219 8166 bytes (raw)
name: guix/gnu-maintenance.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2010, 2011, 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; 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.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; 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
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix gnu-maintenance)
  #:use-module (web uri)
  #:use-module (web client)
  #:use-module (web response)
  #:use-module (ice-9 regex)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-11)
  #:use-module (srfi srfi-26)
  #:use-module (system foreign)
  #:use-module (guix ftp-client)
  #:use-module (guix utils)
  #:export (official-gnu-packages
            find-package-with-attrs
            releases
            latest-release
            gnu-package-name->name+version))

;;; Commentary:
;;;
;;; Code for dealing with the maintenance of GNU packages, such as
;;; auto-updates.
;;;
;;; Code:

\f
;;;
;;; List of GNU packages.
;;;

(define (http-fetch uri)
  "Return a string containing the textual data at URI, a string."
  (let*-values (((resp data)
                (http-get (string->uri uri)))
               ((code)
                (response-code resp)))
    (case code
      ((200)
       data)
      (else
       (error "download failed:" uri code
              (response-reason-phrase resp))))))

(define %package-list-url
  (string-append "http://cvs.savannah.gnu.org/"
                 "viewvc/*checkout*/gnumaint/"
                 "gnupackages.txt?root=womb"))

(define (official-gnu-packages)
  "Return a list of GNU packages."
  (define %package-line-rx
    (make-regexp "^package: (.+)$"))

  (let ((lst (string-split (http-fetch %package-list-url) #\nl)))
    (filter-map (lambda (line)
                  (and=> (regexp-exec %package-line-rx line)
                         (cut match:substring <> 1)))
                lst)))

(define %package-list
  (string-split (http-fetch %package-list-url) #\nl))

(define (find-package-with-attrs package)
  "Return a list that contains PACKAGE and its attributes."
  (define (split-womb-packages xs ys)
    ;; Return a list of lists; each inner list represents a package.
    (define (tail lst)
      (if (null-list? lst)
          lst
          (cdr lst)))

    (cond ((null-list? ys) (filter (lambda (lst)
                                     (not (null-list? lst)))
                                   xs))
          (else (let-values (((xs' ys') (span (lambda (str)
                                                (not (string-null? str)))
                                              ys)))
                  (split-womb-packages (append xs (list xs'))
                                       (tail ys'))))))

  (let ((package-rx (make-regexp (format #f "^package: ~a$" package)
                                 regexp/icase))
        (split-lst (split-womb-packages (list '()) %package-list)))
    (fold append '()
          (filter (lambda (x)
                    (regexp-exec package-rx (car x)))
                  split-lst))))

\f
;;;
;;; Latest release.
;;;

(define (ftp-server/directory project)
  "Return the FTP server and directory where PROJECT's tarball are
stored."
  (define quirks
    '(("commoncpp2"   "ftp.gnu.org"   "/gnu/commoncpp")
      ("ucommon"      "ftp.gnu.org"   "/gnu/commoncpp")
      ("libzrtpcpp"   "ftp.gnu.org"   "/gnu/ccrtp")
      ("libosip2"     "ftp.gnu.org"   "/gnu/osip")
      ("libgcrypt"    "ftp.gnupg.org" "/gcrypt/libgcrypt")
      ("libgpg-error" "ftp.gnupg.org" "/gcrypt/libgpg-error")
      ("libassuan"    "ftp.gnupg.org" "/gcrypt/libassuan")
      ("gnupg"        "ftp.gnupg.org" "/gcrypt/gnupg")
      ("freefont-ttf" "ftp.gnu.org"   "/gnu/freefont")
      ("gnu-ghostscript" "ftp.gnu.org"  "/gnu/ghostscript")
      ("mit-scheme"   "ftp.gnu.org" "/gnu/mit-scheme/stable.pkg")
      ("icecat"       "ftp.gnu.org" "/gnu/gnuzilla")
      ("source-highlight" "ftp.gnu.org" "/gnu/src-highlite")
      ("TeXmacs"      "ftp.texmacs.org" "/TeXmacs/targz")))

  (match (assoc project quirks)
    ((_ server directory)
     (values server directory))
    (_
     (values "ftp.gnu.org" (string-append "/gnu/" project)))))

(define (releases project)
  "Return the list of releases of PROJECT as a list of release name/directory
pairs.  Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\"). "
  ;; TODO: Parse something like fencepost.gnu.org:/gd/gnuorg/packages-ftp.
  (define release-rx
    (make-regexp (string-append "^" project
                                "-([0-9]|[^-])*(-src)?\\.tar\\.")))

  (define alpha-rx
    (make-regexp "^.*-.*[0-9](-|~)?(alpha|beta|rc|cvs|svn|git)-?[0-9\\.]*\\.tar\\."))

  (define (sans-extension tarball)
    (let ((end (string-contains tarball ".tar")))
      (substring tarball 0 end)))

  (let-values (((server directory) (ftp-server/directory project)))
    (define conn (ftp-open server))

    (let loop ((directories (list directory))
               (result      '()))
      (if (null? directories)
          (begin
            (ftp-close conn)
            result)
          (let* ((directory (car directories))
                 (files     (ftp-list conn directory))
                 (subdirs   (filter-map (lambda (file)
                                          (match file
                                            ((name 'directory . _) name)
                                            (_ #f)))
                                        files)))
            (loop (append (map (cut string-append directory "/" <>)
                               subdirs)
                          (cdr directories))
                  (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 (lambda (file)
                                 (match file
                                   ((file 'file . _)
                                    (and (not (string-suffix? ".sig" file))
                                         (regexp-exec release-rx file)
                                         (not (regexp-exec alpha-rx file))
                                         (let ((s (sans-extension file)))
                                           (and (regexp-exec
                                                 %package-name-rx s)
                                                (cons s directory)))))
                                   (_ #f)))
                               files)
                   result)))))))

(define (latest-release project)
  "Return (\"FOO-X.Y\" . \"/bar/foo\") or #f."
  (let ((releases (releases project)))
    (and (not (null? releases))
         (fold (lambda (release latest)
                 (if (version>? (car release) (car latest))
                     release
                     latest))
               '("" . "")
               releases))))

(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)))))

;;; gnu-maintenance.scm ends here

debug log:

solving 42f4383 ...
found 42f4383 in https://yhetil.org/guix-bugs/87obfchq38.fsf@karetnikov.org/
found 6475c38 in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 6475c386d39fa7a78ac5915ca20be560160a3b53	guix/gnu-maintenance.scm

applying [1/1] https://yhetil.org/guix-bugs/87obfchq38.fsf@karetnikov.org/
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 6475c38..42f4383 100644

Checking patch guix/gnu-maintenance.scm...
Applied patch guix/gnu-maintenance.scm cleanly.

index at:
100644 42f43833a90fde266277eb0d94162d5c74589219	guix/gnu-maintenance.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).