Add `guix-gc'.
[jackhill/guix/guix.git] / guix / gnu-maintenance.scm
CommitLineData
22189ed1
NK
1;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
2;;; Copyright (C) 2012 Nikita Karetnikov <nikita@karetnikov.org>
3;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
4;;;
5;;; This file is part of Guix.
6;;;
7;;; Guix is free software; you can redistribute it and/or modify it
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;;;
12;;; Guix is distributed in the hope that it will be useful, but
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
18;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
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)
25 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-11)
27 #:use-module (srfi srfi-26)
28 #:export (official-gnu-packages))
29
30(define (http-fetch uri)
31 "Return a string containing the textual data at URI, a string."
32 (let*-values (((resp data)
33 (http-get (string->uri uri)))
34 ((code)
35 (response-code resp)))
36 (case code
37 ((200)
38 data)
39 (else
40 (error "download failed:" uri code
41 (response-reason-phrase resp))))))
42
43(define %package-list-url
44 (string-append "http://cvs.savannah.gnu.org/"
45 "viewvc/*checkout*/gnumaint/"
46 "gnupackages.txt?root=womb"))
47
48(define (official-gnu-packages)
49 "Return a list of GNU packages."
50 (define %package-line-rx
51 (make-regexp "^package: (.+)$"))
52
53 (let ((lst (string-split (http-fetch %package-list-url) #\nl)))
54 (filter-map (lambda (line)
55 (and=> (regexp-exec %package-line-rx line)
56 (cut match:substring <> 1)))
57 lst)))