Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[maemian] / nokia-lintian / frontend / lintian-info
1 #!/usr/bin/perl -w
2 #
3 # lintian-info -- transform lintian tags into descriptive text
4 #
5 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
6 #
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
10 # later version.
11 #
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.
16 #
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,
21 # MA 02110-1301, USA.
22
23 use strict;
24
25 use Getopt::Long;
26
27 # turn file buffering off:
28 $| = 1;
29
30 BEGIN {
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'};
35 }
36
37 # import perl libraries
38 use lib "$ENV{'LINTIAN_ROOT'}/lib";
39 use Read_taginfo;
40
41 my %already_displayed = ();
42
43 my %tag_info = %{read_tag_info()};
44
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");
49
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.)
53 my $unknown;
54 if ($tags) {
55     for my $tag (@ARGV) {
56         print "N: $tag\n";
57         print "N:\n";
58         if (exists $tag_info{$tag}) {
59             print wrap_paragraphs('N:   ', $tag_info{$tag});
60         } else {
61             print "N:   Unknown tag.\n";
62             $unknown = 1;
63         }
64         print "N:\n";
65     }
66     exit ($unknown ? 1 : 0);
67 }
68
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.
72 while (<>) {
73     print;
74     chomp;
75     next if /^\s*$/;
76     s/\e[\[\d;]*m//g;
77     s/<span style=\"[^\"]+\">//g;
78     s,</span>,,g;
79
80     my ($type, $pkg);
81     my @pieces = split(/:\s+/);
82     if ($annotate) {
83         $type = shift @pieces if ($pieces[0] =~ /^\w$/);
84         $pkg = shift @pieces if ($pieces[0] =~ /^\S+( (binary|udeb))?$/);
85     } else {
86         $type = shift @pieces;
87         $pkg = shift @pieces;
88     }
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);
93
94         next if not exists $tag_info{$tag} or $already_displayed{$tag}++;
95         print "N:\n";
96         print wrap_paragraphs('N:   ',$tag_info{$tag});
97         print "N:\n";
98     }
99 }
100
101 exit 0;
102
103 # Local Variables:
104 # indent-tabs-mode: t
105 # cperl-indent-level: 4
106 # End:
107 # vim: syntax=perl sw=4 ts=8