lint: Improve check for synopses starting with package name.
[guix.git] / build-aux / sync-descriptions.scm
blob6ff549c309da54b53a2ad29b02e35a991aa586c9
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
19 ;;;
20 ;;; Report package synopses and descriptions that defer from those found in
21 ;;; the GNU Womb.
22 ;;;
24 (use-modules (guix gnu-maintenance)
25              (guix packages)
26              (guix utils)
27              (guix ui)
28              (gnu packages)
29              (srfi srfi-1)
30              (srfi srfi-26)
31              (ice-9 match))
33 (define official
34   ;; GNU package descriptors from the Womb.
35   (official-gnu-packages))
37 (define gnus
38   ;; GNU packages available in the distro.
39   (let ((lookup (lambda (p)
40                   (find (lambda (descriptor)
41                           (equal? (gnu-package-name descriptor)
42                                   (package-name p)))
43                         official))))
44     (fold-packages (lambda (package result)
45                      (or (and=> (lookup package)
46                                 (cut alist-cons package <> result))
47                          result))
48                    '())))
50 (define (escape-quotes str)
51   "Replace any quote character in STR by an escaped quote character."
52   (list->string
53    (string-fold-right (lambda (chr result)
54                         (match chr
55                           (#\" (cons* #\\ #\"result))
56                           (_   (cons chr result))))
57                       '()
58                       str)))
60 ;; Iterate over GNU packages.  Report those whose synopsis defers from that
61 ;; found upstream.
62 (for-each (match-lambda
63            ((package . descriptor)
64             (let ((upstream   (gnu-package-doc-summary descriptor))
65                   (downstream (package-synopsis package))
66                   (loc        (or (package-field-location package 'synopsis)
67                                   (package-location package))))
68               (unless (and upstream (string=? upstream downstream))
69                 (format (guix-warning-port)
70                         "~a: ~a: proposed synopsis: ~s~%"
71                         (location->string loc) (package-name package)
72                         upstream)))
74             (let ((upstream   (gnu-package-doc-description descriptor))
75                   (downstream (package-description package))
76                   (loc        (or (package-field-location package 'description)
77                                   (package-location package))))
78               (when (and upstream
79                          (not (string=? (fill-paragraph upstream 100)
80                                         (fill-paragraph downstream 100))))
81                 (format (guix-warning-port)
82                         "~a: ~a: proposed description:~%     \"~a\"~%"
83                         (location->string loc) (package-name package)
84                         (fill-paragraph (escape-quotes upstream) 77 7))))))
85           gnus)