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
|
# description -- lintian check script -*- perl -*-
# Copyright (C) 1998 Christian Schwarz
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
package Lintian::description;
use strict;
use Tags;
use Util;
sub run {
my $pkg = shift;
my $type = shift;
my $ppkg = quotemeta($pkg);
my $cf = "fields/description";
my $tabs = 0;
my $lines = 0;
my $template = 0;
my $unindented_list = 0;
my $synopsis;
# description?
unless (-f $cf) {
tag "package-has-no-description", "";
return 0;
}
open(IN,$cf) or fail("cannot open $cf for reading: $!");
# 1st line contains synopsis
chop($synopsis = <IN>);
if ($synopsis =~ m/^\s*$/) {
tag "description-synopsis-is-empty", "";
} else {
if ($synopsis =~ m/^\s/) {
tag "description-synopsis-has-leading-spaces", "";
}
if ($synopsis =~ m/^\s*$ppkg\b/i) {
tag "description-starts-with-package-name", "";
}
if ($synopsis =~ m/\.\s*$/) {
tag "description-synopsis-might-not-be-phrased-properly", "";
}
if ($synopsis =~ m/\t/) {
tag "description-contains-tabs", "" unless $tabs++;
}
if (length($synopsis) >= 80) {
tag "description-too-long", "";
}
if ($synopsis =~ m/^\s*missing\s*$/i) {
tag "description-is-debmake-template", "" unless $template++;
} elsif ($synopsis =~ m/<insert up to 60 chars description>/) {
tag "description-is-dh_make-template", "" unless $template++;
}
}
while (<IN>) {
chop;
next if m/^\s*$/o;
next if m/^\.\s*$/o;
if ($lines == 0) {
my $firstline = lc $_;
my $lsyn = lc $synopsis;
if ($firstline =~ /^\Q$lsyn\E$/) {
tag "description-synopsis-is-duplicated", "";
} else {
$firstline =~ s/[^a-zA-Z0-9]+//g;
$lsyn =~ s/[^a-zA-Z0-9]+//g;
if ($firstline eq $lsyn) {
tag "description-synopsis-is-duplicated", "";
}
}
}
$lines++;
if (m/^\.\s*\S/o) {
tag "description-contains-invalid-control-statement", "";
} elsif (m/^[\-\*]/o) {
# Print it only the second time. Just one is not enough to be sure that
# it's a list, and after the second there's no need to repeat it.
tag "possible-unindented-list-in-extended-description", "" if $unindented_list++ == 2;
}
if (m/\t/o) {
tag "description-contains-tabs", "" unless $tabs++;
}
if ($lines == 1) {
# checks for the first line of the extended description:
if (m/^\s/o) {
tag "description-starts-with-leading-spaces", "";
}
if (m/^\s*missing\s*$/oi) {
tag "description-is-debmake-template", "" unless $template++;
} elsif (m/<insert long description, indented with spaces>/) {
tag "description-is-dh_make-template", "" unless $template++;
}
}
if (length($_) >= 80) {
tag "extended-description-line-too-long", "";
}
}
close(IN);
if ($lines == 0) {
tag "extended-description-is-empty", "" unless $type eq 'udeb';
}
}
1;
|