3 # lintian-info -- transform lintian tags into descriptive text
5 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
7 # This program is free software. It is distributed under the terms of
8 # the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any
12 # This program is distributed in the hope that it will be useful,
13 # but 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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, you can find it on the World Wide
19 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
20 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
27 # turn file buffering off:
31 # determine LINTIAN_ROOT
32 my $LINTIAN_ROOT = $ENV{'LINTIAN_ROOT'} || '/usr/share/lintian';
33 $ENV{'LINTIAN_ROOT'} = $LINTIAN_ROOT
34 unless exists $ENV{'LINTIAN_ROOT'};
37 # import perl libraries
38 use lib "$ENV{'LINTIAN_ROOT'}/lib";
41 my %already_displayed = ();
43 my %tag_info = %{read_tag_info()};
45 my ($annotate, $tags);
46 Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
47 GetOptions('annotate|a' => \$annotate, 'tags|t' => \$tags)
48 or die("error parsing options\n");
50 # If tag mode was specified, read the arguments as tags and display the
51 # descriptions for each one. (We don't currently display the severity,
52 # although that would be nice.)
58 if (exists $tag_info{$tag}) {
59 print wrap_paragraphs('N: ', $tag_info{$tag});
61 print "N: Unknown tag.\n";
66 exit ($unknown ? 1 : 0);
69 # Otherwise, read input files or STDIN, watch for tags, and add descriptions
70 # whenever we see one, can, and haven't already explained that tag. Strip off
71 # color and HTML sequences.
77 s/<span style=\"[^\"]+\">//g;
81 my @pieces = split(/:\s+/);
83 $type = shift @pieces if ($pieces[0] =~ /^\w$/);
84 $pkg = shift @pieces if ($pieces[0] =~ /^\S+( (binary|udeb))?$/);
86 $type = shift @pieces;
89 if ($annotate or (defined $type and $type =~ m/^[OEWIX]$/)) {
90 my $tag = shift @pieces;
91 next if not defined $tag;
92 ($tag) = split(/\s+/, $tag, 2);
94 next if not exists $tag_info{$tag} or $already_displayed{$tag}++;
96 print wrap_paragraphs('N: ',$tag_info{$tag});
104 # indent-tabs-mode: t
105 # cperl-indent-level: 4
107 # vim: syntax=perl sw=4 ts=8