Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[maemian] / nokia-lintian / debian / patches / 801-implement-check-tag.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 801-implement-check-tag.dpatch by Eero Häkkinen <eero.hakkinen@nokia.com>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Implement --{,dont-}check-tag tag1,tag2,...
6
7 @DPATCH@
8 diff -urNad lintian-1.23.8~/frontend/lintian lintian-1.23.8/frontend/lintian
9 --- lintian-1.23.8~/frontend/lintian    2006-09-13 14:55:10.000000000 +0300
10 +++ lintian-1.23.8/frontend/lintian     2006-09-13 14:55:11.000000000 +0300
11 @@ -76,6 +76,8 @@
12  my $action;
13  my $checks;
14  my $dont_check;
15 +my $check_tags;
16 +my $dont_check_tags;
17  my $unpack_info;
18  my $cwd;
19  my $cleanup_filename;
20 @@ -128,6 +130,8 @@
21      -c, --check               check packages (default action)
22      -C X, --check-part X      check only certain aspects
23      -X X, --dont-check-part X don\'t check certain aspects
24 +    -T X, --check-tag X       report only certain properties
25 +    -Y X, --dont-check-tag X  don\'t report certain properties
26      -u, --unpack              only unpack packages in the lab
27      -r, --remove              remove package from the lab
28  General options:
29 @@ -183,7 +187,7 @@
30  # Record action requested
31  # Options: -S, -R, -c, -u, -r
32  sub record_action {
33 -    if ($action) {
34 +    if ($action && $action ne $_[0]) {
35         die("too many actions specified: $_[0]");
36      }
37      $action = "$_[0]";
38 @@ -192,35 +196,54 @@
39  # Record Parts requested for checking
40  # Options: -C|--check-part
41  sub record_check_part {
42 -    if (defined $action and $action eq 'check' and $checks) {
43 -       die("multiple -C or --check-part options not allowed");
44 -    }
45      if ($dont_check) {
46         die("both -C or --check-part and -X or --dont-check-part options not allowed");
47      }
48 -    if ($action) {
49 +    if ($action && $action ne 'check') {
50         die("too many actions specified: $_[0]");
51      }
52      $action = 'check';
53 -    $checks = "$_[1]";
54 +    $checks .= "$_[1],";
55  }
56  
57  # Record Parts requested not to check
58  # Options: -X|--dont-check-part X
59  sub record_dont_check_part {
60 -    if (defined $action and $action eq 'check' and $dont_check) {
61 -       die("multiple -x or --dont-check-part options not allowed");
62 -    }
63      if ($checks) {
64         die("both -C or --check-part and -X or --dont-check-part options not allowed");
65      }
66 -    if ($action) {
67 +    if ($action && $action ne 'check') {
68         die("too many actions specified: $_[0]");
69      }
70      $action = 'check';
71 -    $dont_check = "$_[1]";
72 +    $dont_check .= "$_[1],";
73  }
74  
75 +# Record tags requested for checking
76 +# Options: -T|--check-tag
77 +sub record_check_tag {
78 +    if ($dont_check_tags) {
79 +       die("both -T or --check-tag and -Y or --dont-check-tag options not allowed");
80 +    }
81 +    if ($action && $action ne 'check') {
82 +       die("too many actions specified: $_[0]");
83 +    }
84 +    $action = 'check';
85 +    $check_tags .= "$_[1],";
86 +}
87 +
88 +# Record Parts requested not to check
89 +# Options: -Y|--dont-check-tag X
90 +sub record_dont_check_tag {
91 +    if ($check_tags) {
92 +       die("both -T or --check-tag and -Y or --dont-check-tag options not allowed");
93 +    }    
94 +    if ($action && $action ne 'check') {
95 +       die("too many actions specified: $_[0]");
96 +    }
97 +    $action = 'check';
98 +    $dont_check_tags .= "$_[1],";
99 +}
100  
101  # Process for -U|--unpack-info flag
102  sub record_unpack_info {
103 @@ -245,6 +268,8 @@
104                "check|c" => \&record_action,
105                "check-part|C=s" => \&record_check_part,
106                "dont-check-part|X=s" => \&record_dont_check_part,
107 +              "check-tag|T=s" => \&record_check_tag,
108 +              "dont-check-tag|Y=s" => \&record_dont_check_tag,
109                "unpack|u" => \&record_action,
110                "remove|r" => \&record_action,
111  
112 @@ -516,6 +541,15 @@
113  require Tags;
114  import Tags;
115  
116 +if ($check_tags) {
117 +    my $re = pattern_list_to_re($check_tags);
118 +    Tags::add_tag_override({ tag => qr/^(?!$re$).*/os, significance => -1 });
119 +}
120 +elsif ($dont_check_tags) {
121 +    my $re = pattern_list_to_re($dont_check_tags);
122 +    Tags::add_tag_override({ tag => qr/^$re$/os, significance => -1 });
123 +}
124 +
125  my @l_secs = read_dpkg_control("$LINTIAN_ROOT/checks/lintian.desc");
126  shift(@l_secs);
127  map Tags::add_tag($_), @l_secs;
128 @@ -1691,6 +1725,25 @@
129  sub by_collection_order {
130      $collection_info{$a}->{'order'} <=> $collection_info{$b}->{'order'};
131  }
132 +
133 +sub pattern_list_to_re {
134 +    my $re =
135 +       join '|',
136 +       map {
137 +           s@([*]+)|([?])|([[]([!^]?)([]]?(?:[[]([=:.]).*?\6[]]|[^]])*)[]])|[\\]?(.)@
138 +               if    ( defined $1 ) { '.*' }
139 +               elsif ( defined $2 ) { '.'  }
140 +               elsif ( defined $3 ) {
141 +                   my $cl = '[' . ( $4 ? '^' : '' ) . $5 . ']';
142 +                   eval { qr/$cl/ } ? $cl : quotemeta $3
143 +               }
144 +               else { quotemeta $7 }
145 +               @gex;
146 +           $_;
147 +       }
148 +       split /,/, shift;
149 +    return qr/$re/o;
150 +}
151  # }}}
152  
153  # {{{ Exit handler.
154 diff -urNad lintian-1.23.8~/man/lintian.1 lintian-1.23.8/man/lintian.1
155 --- lintian-1.23.8~/man/lintian.1       2004-08-18 11:00:40.000000000 +0300
156 +++ lintian-1.23.8/man/lintian.1        2006-09-13 14:55:43.000000000 +0300
157 @@ -82,6 +82,21 @@
158  This is the default action.
159  
160  .TP
161 +.BR \-u ", " \-\-unpack
162 +Unpack the specified packages up to the current unpack level.
163 +The default unpack level is 1 for this option.  See the UNPACK
164 +LEVELS section below.
165 +
166 +.TP
167 +.BR \-r ", " \-\-remove
168 +Clean up the lintian directory of the specified packages up to
169 +the current unpack level.  The default unpack level is 0 for
170 +this option.
171 +
172 +.PP
173 +Check options (these options imply \fB\-\-check\fP):
174 +
175 +.TP
176  .BR \-C " chk1,chk2,..., " \-\-check\-part " chk1,chk2,..."
177  Run only the specified checks.  You can either specify the
178  name of the check script or the abbreviation.
179 @@ -94,16 +109,14 @@
180  For details, see the CHECKS section below.
181  
182  .TP
183 -.BR \-u ", " \-\-unpack
184 -Unpack the specified packages up to the current unpack level.
185 -The default unpack level is 1 for this option.  See the UNPACK
186 -LEVELS section below.
187 +.BR \-T " tag1,tag2,..., " \-\-check\-tag " tag1,tag2,..."
188 +Report only the specified check tags.
189 +You can either specify the tag name or give a glob pattern.
190  
191  .TP
192 -.BR \-r ", " \-\-remove
193 -Clean up the lintian directory of the specified packages up to
194 -the current unpack level.  The default unpack level is 0 for
195 -this option.
196 +.BR \-Y " tag1,tag2,..., " \-\-dont\-check\-part " tag1,tag2,..."
197 +Report all but the specified check tags.
198 +You can either specify the tag name or give a glob pattern.
199  
200  .PP
201  General options: