2 # This script is part of debbugs, and is released
3 # under the terms of the GPL version 2, or any later
4 # version at your option.
5 # See the file README and COPYING for more information.
7 # [Other people have contributed to this file; their copyrights should
9 # Copyright 2004-2006 by Anthony Towns <ajt@debian.org>
10 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
16 use POSIX qw(strftime nice);
18 use Debbugs::Config qw(:globals :text :config);
22 use Debbugs::Common qw(getparsedaddrs make_list getmaintainers getpseudodesc);
24 use Debbugs::Bugs qw(get_bugs bug_filter newest_bug);
25 use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions);
27 use Debbugs::Status qw(splitpackages);
29 use Debbugs::CGI qw(:all);
31 use Debbugs::CGI::Pkgreport qw(:all);
33 use Debbugs::Text qw(:templates);
36 my $q = new CGI::Simple;
38 if ($q->request_method() eq 'HEAD') {
39 print $q->header(-type => "text/html",
45 my $default_params = {ordering => 'normal',
52 our %param = cgi_parameters(query => $q,
53 single => [qw(ordering archive repeatmerged),
54 qw(bug-rev pend-rev sev-rev),
55 qw(maxdays mindays version),
56 qw(data which dist newest),
58 default => $default_params,
61 my ($form_options,$param) = ({},undef);
62 ($form_options,$param)= form_options_and_normal_param(\%param)
63 if $param{form_options};
65 %param = %{$param} if defined $param;
67 if (exists $param{form_options} and defined $param{form_options}) {
68 delete $param{form_options};
69 delete $param{submit} if exists $param{submit};
70 for my $default (keys %{$default_params}) {
71 if (exists $param{$default} and
72 not ref($default_params->{$default}) and
73 $default_params->{$default} eq $param{$default}
75 delete $param{$default};
78 for my $incexc (qw(include exclude)) {
79 next unless exists $param{$incexc};
80 # normalize tag to tags
81 $param{$incexc} = [map {s/^tag:/tags:/} grep /\S\:\S/, make_list($param{$incexc})];
83 for my $key (keys %package_search_keys) {
84 next unless exists $param{key};
85 $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})];
87 # kill off keys for which empty values are meaningless
88 for my $key (qw(package src submitter affects severity status dist)) {
89 next unless exists $param{$key};
90 $param{$key} = [grep {defined $_ and length $_}
91 make_list($param{$key})];
93 print $q->redirect(munge_url('pkgreport.cgi?',%param));
97 # normalize innclude/exclude keys; currently this is in two locations,
98 # which is suboptimal. Closes: #567407
99 for my $incexc (qw(include exclude)) {
100 next unless exists $param{$incexc};
101 # normalize tag to tags
102 $param{$incexc} = [map {s/^tag:/tags:/} make_list($param{$incexc})];
107 # map from yes|no to 1|0
108 for my $key (qw(repeatmerged bug-rev pend-rev sev-rev)) {
109 if (exists $param{$key}){
110 if ($param{$key} =~ /^no$/i) {
113 elsif ($param{$key}) {
119 if (lc($param{archive}) eq 'no') {
122 elsif (lc($param{archive}) eq 'yes') {
127 if (exists $param{dist} and $param{dist} eq '') {
131 my $include = $param{'&include'} || $param{'include'} || "";
132 my $exclude = $param{'&exclude'} || $param{'exclude'} || "";
134 my $users = $param{'users'} || "";
136 my $ordering = $param{'ordering'};
137 my $raw_sort = ($param{'raw'} || "no") eq "yes";
138 my $old_view = ($param{'oldview'} || "no") eq "yes";
139 my $age_sort = ($param{'age'} || "no") eq "yes";
140 unless (defined $ordering) {
141 $ordering = "normal";
142 $ordering = "oldview" if $old_view;
143 $ordering = "raw" if $raw_sort;
144 $ordering = 'age' if $age_sort;
146 $param{ordering} = $ordering;
148 our ($bug_order) = $ordering =~ /(age(?:rev)?)/;
149 $bug_order = '' if not defined $bug_order;
151 my $bug_rev = ($param{'bug-rev'} || "no") eq "yes";
152 my $pend_rev = ($param{'pend-rev'} || "no") eq "yes";
153 my $sev_rev = ($param{'sev-rev'} || "no") eq "yes";
155 my @inc_exc_mapping = ({name => 'pending',
173 key => 'includesubj',
177 key => 'excludesubj',
180 for my $incexcmap (@inc_exc_mapping) {
181 push @{$param{$incexcmap->{incexc}}}, map {"$incexcmap->{name}:$_"}
182 map{split /\s*,\s*/} make_list($param{$incexcmap->{key}})
183 if exists $param{$incexcmap->{key}};
184 delete $param{$incexcmap->{key}};
188 my $maxdays = ($param{'maxdays'} || -1);
189 my $mindays = ($param{'mindays'} || 0);
190 my $version = $param{'version'} || undef;
193 our %hidden = map { $_, 1 } qw(status severity classification);
197 "pri" => [map { "pending=$_" }
198 qw(pending forwarded pending-fixed fixed done absent)],
199 "ttl" => ["Outstanding","Forwarded","Pending Upload",
200 "Fixed in NMU","Resolved","From other Branch"],
201 "def" => "Unknown Pending Status",
202 "ord" => [0,1,2,3,4,5,6],
206 "pri" => [map { "severity=$_" } @gSeverityList],
207 "ttl" => [map { $gSeverityDisplay{$_} } @gSeverityList],
208 "def" => "Unknown Severity",
209 "ord" => [0..@gSeverityList],
211 "classification" => [ {
212 "nam" => "Classification",
213 "pri" => [qw(pending=pending+tag=wontfix
214 pending=pending+tag=moreinfo
215 pending=pending+tag=patch
216 pending=pending+tag=confirmed
218 "ttl" => ["Will Not Fix","More information needed",
219 "Patch Available","Confirmed"],
220 "def" => "Unclassified",
221 "ord" => [2,3,4,1,0,5],
223 "oldview" => [ qw(status severity) ],
224 "normal" => [ qw(status severity classification) ],
227 if (exists $param{which} and exists $param{data}) {
228 $param{$param{which}} = [exists $param{$param{which}}?(make_list($param{$param{which}})):(),
229 make_list($param{data}),
231 delete $param{which};
235 if (defined $param{maintenc}) {
236 $param{maint} = maint_decode($param{maintenc});
237 delete $param{maintenc}
240 if (exists $param{pkg}) {
241 $param{package} = $param{pkg};
245 if (not grep {exists $param{$_}} keys %package_search_keys and exists $param{users}) {
246 $param{usertag} = [make_list($param{users})];
253 for my $user (map {split /[\s*,\s*]+/} make_list($param{users}||[])) {
254 next unless length($user);
255 add_user($user,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
258 if (defined $param{usertag}) {
259 for my $usertag (make_list($param{usertag})) {
261 my ($u, $t) = split /:/, $usertag, 2;
262 Debbugs::User::read_usertags(\%select_ut, $u);
263 unless (defined $t && $t ne "") {
264 $t = join(",", keys(%select_ut));
266 add_user($u,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
267 push @{$param{tag}}, split /,/, $t;
271 quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys;
274 my $Archived = $param{archive} ? " Archived" : "";
276 my $this = munge_url('pkgreport.cgi?',
285 # addusers for source and binary packages being searched for
286 my $pkgsrc = getpkgsrc();
287 my $srcpkg = getsrcpkgs();
288 for my $package (# For binary packages, add the binary package
289 # and corresponding source package
290 make_list($param{package}||[]),
291 (map {defined $pkgsrc->{$_}?($pkgsrc->{$_}):()}
292 make_list($param{package}||[]),
294 # For source packages, add the source package
295 # and corresponding binary packages
296 make_list($param{src}||[]),
297 (map {defined $srcpkg->{$_}?($srcpkg->{$_}):()}
298 make_list($param{src}||[]),
301 next unless defined $package;
302 add_user($package.'@'.$config{usertag_package_domain},
303 \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden)
304 if defined $config{usertag_package_domain};
308 # walk through the keys and make the right get_bugs query.
310 my $form_option_variables = {};
311 $form_option_variables->{search_key_order} = [@package_search_key_order];
313 # Set the title sanely and clean up parameters
315 my @temp = @package_search_key_order;
316 while (my ($key,$value) = splice @temp, 0, 2) {
317 next unless exists $param{$key};
319 for my $entry (make_list($param{$key})) {
320 # we'll handle newest below
321 next if $key eq 'newest';
323 if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) {
324 my %versions = get_versions(package => $entry,
325 (exists $param{dist}?(dist => $param{dist}):()),
326 (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
327 ($key eq 'src'?(arch => q(source)):()),
332 if (keys %versions > 1) {
333 $verdesc = 'versions '. join(', ',
334 map { $_ .' ['.join(', ',
335 sort @{$versions{$_}}
340 $verdesc = 'version '.join(', ',
344 $extra= " ($verdesc)" if keys %versions;
346 if ($key eq 'maint' and $entry eq '') {
347 push @entries, "no one (packages without maintainers)"
350 push @entries, $entry.$extra;
353 push @title,$value.' '.join(' or ', @entries) if @entries;
355 if (defined $param{newest}) {
356 my $newest_bug = newest_bug();
357 @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug;
358 push @title, 'in '.@bugs.' newest reports';
359 $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(),
364 my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
368 @bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()}
369 grep {$_ ne 'newest'}
370 keys %package_search_keys, 'archive'),
374 # shove in bugs which affect this package if there is a package or a
375 # source given (by default), but no affects options given
376 if (not exists $param{affects} and not exists $param{noaffects} and
377 (exists $param{src} or
378 exists $param{package})) {
379 push @bugs, get_bugs((map {my $key = $_;
380 exists $param{$key}?($key =~ /^(?:package|src)$/?'affects':$key,
381 ($key eq 'src'?[map {"src:$_"}make_list($param{$key})]:$param{$_})):()}
382 grep {$_ ne 'newest'}
383 keys %package_search_keys, 'archive'),
388 # filter out included or excluded bugs
391 if (defined $param{version}) {
392 $title .= " at version $param{version}";
394 elsif (defined $param{dist}) {
395 $title .= " in $param{dist}";
398 $title = html_escape($title);
400 my @names; my @prior; my @order;
401 determine_ordering(cats => \%cats,
403 ordering => \$ordering,
410 # strip out duplicate bugs
412 @bugs{@bugs} = @bugs;
415 my $result = pkg_htmlizebugs(bugs => \@bugs,
420 ordering => $ordering,
421 bugusertags => \%bugusertags,
423 bug_order => $bug_order,
424 repeatmerged => $param{repeatmerged},
429 (exists $param{dist})?(dist => $param{dist}):(),
432 print "Content-Type: text/html; charset=utf-8\n\n";
434 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
435 print "<HTML><HEAD>\n" .
436 "<TITLE>$title -- $gProject$Archived $gBug report logs</TITLE>\n" .
437 qq(<link rel="stylesheet" href="$gWebHostBugDir/css/bugs.css" type="text/css">) .
439 '<BODY onload="pagemain();">' .
441 print qq(<DIV id="status_mask"></DIV>\n);
442 print "<H1>" . "$gProject$Archived $gBug report logs: $title" .
447 my $pkg = $param{package} if defined $param{package};
448 my $src = $param{src} if defined $param{src};
450 my $pseudodesc = getpseudodesc();
451 if (defined $pseudodesc and defined $pkg and exists $pseudodesc->{$pkg}) {
455 # output information about the packages
457 for my $package (make_list($param{package}||[])) {
458 print generate_package_info(binary => 1,
464 for my $package (make_list($param{src}||[])) {
465 print generate_package_info(binary => 0,
472 if (exists $param{maint} or exists $param{maintenc}) {
473 print "<p>Note that maintainers may use different Maintainer fields for\n";
474 print "different packages, so there may be other reports filed under\n";
475 print "different addresses.\n";
477 if (exists $param{submitter}) {
478 print "<p>Note that people may use different email accounts for\n";
479 print "different bugs, so there may be other reports filed under\n";
480 print "different addresses.\n";
485 print fill_in_template(template=>'cgi/pkgreport_javascript');
487 print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);
489 print option_form(template => 'cgi/pkgreport_options',
491 form_options => $form_options,
492 variables => $form_option_variables,
496 print fill_in_template(template=>'html/html_tail',
497 hole_var => {'&strftime' => \&POSIX::strftime,
500 print "</body></html>\n";