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 $param{$incexc} = [grep /\S\:\S/, make_list($param{$incexc})];
82 for my $key (keys %package_search_keys) {
83 next unless exists $param{key};
84 $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})];
86 # kill off keys for which empty values are meaningless
87 for my $key (qw(package src submitter affects severity status dist)) {
88 next unless exists $param{$key};
89 $param{$key} = [grep {defined $_ and length $_}
90 make_list($param{$key})];
92 print $q->redirect(munge_url('pkgreport.cgi?',%param));
96 # map from yes|no to 1|0
97 for my $key (qw(repeatmerged bug-rev pend-rev sev-rev)) {
98 if (exists $param{$key}){
99 if ($param{$key} =~ /^no$/i) {
102 elsif ($param{$key}) {
108 if (lc($param{archive}) eq 'no') {
111 elsif (lc($param{archive}) eq 'yes') {
116 if (exists $param{dist} and $param{dist} eq '') {
120 my $include = $param{'&include'} || $param{'include'} || "";
121 my $exclude = $param{'&exclude'} || $param{'exclude'} || "";
123 my $users = $param{'users'} || "";
125 my $ordering = $param{'ordering'};
126 my $raw_sort = ($param{'raw'} || "no") eq "yes";
127 my $old_view = ($param{'oldview'} || "no") eq "yes";
128 my $age_sort = ($param{'age'} || "no") eq "yes";
129 unless (defined $ordering) {
130 $ordering = "normal";
131 $ordering = "oldview" if $old_view;
132 $ordering = "raw" if $raw_sort;
133 $ordering = 'age' if $age_sort;
135 $param{ordering} = $ordering;
137 our ($bug_order) = $ordering =~ /(age(?:rev)?)/;
138 $bug_order = '' if not defined $bug_order;
140 my $bug_rev = ($param{'bug-rev'} || "no") eq "yes";
141 my $pend_rev = ($param{'pend-rev'} || "no") eq "yes";
142 my $sev_rev = ($param{'sev-rev'} || "no") eq "yes";
144 my @inc_exc_mapping = ({name => 'pending',
162 key => 'includesubj',
166 key => 'excludesubj',
169 for my $incexcmap (@inc_exc_mapping) {
170 push @{$param{$incexcmap->{incexc}}}, map {"$incexcmap->{name}:$_"}
171 map{split /\s*,\s*/} make_list($param{$incexcmap->{key}})
172 if exists $param{$incexcmap->{key}};
173 delete $param{$incexcmap->{key}};
177 my $maxdays = ($param{'maxdays'} || -1);
178 my $mindays = ($param{'mindays'} || 0);
179 my $version = $param{'version'} || undef;
182 our %hidden = map { $_, 1 } qw(status severity classification);
186 "pri" => [map { "pending=$_" }
187 qw(pending forwarded pending-fixed fixed done absent)],
188 "ttl" => ["Outstanding","Forwarded","Pending Upload",
189 "Fixed in NMU","Resolved","From other Branch"],
190 "def" => "Unknown Pending Status",
191 "ord" => [0,1,2,3,4,5,6],
195 "pri" => [map { "severity=$_" } @gSeverityList],
196 "ttl" => [map { $gSeverityDisplay{$_} } @gSeverityList],
197 "def" => "Unknown Severity",
198 "ord" => [0..@gSeverityList],
200 "classification" => [ {
201 "nam" => "Classification",
202 "pri" => [qw(pending=pending+tag=wontfix
203 pending=pending+tag=moreinfo
204 pending=pending+tag=patch
205 pending=pending+tag=confirmed
207 "ttl" => ["Will Not Fix","More information needed",
208 "Patch Available","Confirmed"],
209 "def" => "Unclassified",
210 "ord" => [2,3,4,1,0,5],
212 "oldview" => [ qw(status severity) ],
213 "normal" => [ qw(status severity classification) ],
216 if (exists $param{which} and exists $param{data}) {
217 $param{$param{which}} = [exists $param{$param{which}}?(make_list($param{$param{which}})):(),
218 make_list($param{data}),
220 delete $param{which};
224 if (defined $param{maintenc}) {
225 $param{maint} = maint_decode($param{maintenc});
226 delete $param{maintenc}
230 if (not grep {exists $param{$_}} keys %package_search_keys and exists $param{users}) {
231 $param{usertag} = [make_list($param{users})];
234 if (exists $param{pkg}) {
235 $param{package} = $param{pkg};
243 for my $user (map {split /[\s*,\s*]+/} make_list($param{users}||[])) {
244 next unless length($user);
245 add_user($user,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
248 if (defined $param{usertag}) {
249 for my $usertag (make_list($param{usertag})) {
251 my ($u, $t) = split /:/, $usertag, 2;
252 Debbugs::User::read_usertags(\%select_ut, $u);
253 unless (defined $t && $t ne "") {
254 $t = join(",", keys(%select_ut));
256 add_user($u,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
257 push @{$param{tag}}, split /,/, $t;
261 quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys;
264 my $Archived = $param{archive} ? " Archived" : "";
266 my $this = munge_url('pkgreport.cgi?',
275 # addusers for source and binary packages being searched for
276 my $pkgsrc = getpkgsrc();
277 my $srcpkg = getsrcpkgs();
278 for my $package (# For binary packages, add the binary package
279 # and corresponding source package
280 make_list($param{package}||[]),
281 (map {defined $pkgsrc->{$_}?($pkgsrc->{$_}):()}
282 make_list($param{package}||[]),
284 # For source packages, add the source package
285 # and corresponding binary packages
286 make_list($param{src}||[]),
287 (map {defined $srcpkg->{$_}?($srcpkg->{$_}):()}
288 make_list($param{src}||[]),
291 next unless defined $package;
292 add_user($package.'@'.$config{usertag_package_domain},
293 \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden)
294 if defined $config{usertag_package_domain};
298 # walk through the keys and make the right get_bugs query.
300 my $form_option_variables = {};
301 $form_option_variables->{search_key_order} = [@package_search_key_order];
303 # Set the title sanely and clean up parameters
305 my @temp = @package_search_key_order;
306 while (my ($key,$value) = splice @temp, 0, 2) {
307 next unless exists $param{$key};
309 for my $entry (make_list($param{$key})) {
310 # we'll handle newest below
311 next if $key eq 'newest';
313 if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) {
314 my %versions = get_versions(package => $entry,
315 (exists $param{dist}?(dist => $param{dist}):()),
316 (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
317 ($key eq 'src'?(arch => q(source)):()),
322 if (keys %versions > 1) {
323 $verdesc = 'versions '. join(', ',
324 map { $_ .' ['.join(', ',
325 sort @{$versions{$_}}
330 $verdesc = 'version '.join(', ',
334 $extra= " ($verdesc)" if keys %versions;
336 if ($key eq 'maint' and $entry eq '') {
337 push @entries, "no one (packages without maintainers)"
340 push @entries, $entry.$extra;
343 push @title,$value.' '.join(' or ', @entries) if @entries;
345 if (defined $param{newest}) {
346 my $newest_bug = newest_bug();
347 @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug;
348 push @title, 'in '.@bugs.' newest reports';
349 $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(),
354 my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
358 @bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()}
359 grep {$_ ne 'newest'}
360 keys %package_search_keys, 'archive'),
364 if (defined $param{version}) {
365 $title .= " at version $param{version}";
367 elsif (defined $param{dist}) {
368 $title .= " in $param{dist}";
371 $title = html_escape($title);
373 my @names; my @prior; my @order;
374 determine_ordering(cats => \%cats,
376 ordering => \$ordering,
383 # strip out duplicate bugs
385 @bugs{@bugs} = @bugs;
388 my $result = pkg_htmlizebugs(bugs => \@bugs,
393 ordering => $ordering,
394 bugusertags => \%bugusertags,
396 bug_order => $bug_order,
397 repeatmerged => $param{repeatmerged},
402 (exists $param{dist})?(dist => $param{dist}):(),
405 print "Content-Type: text/html; charset=utf-8\n\n";
407 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
408 print "<HTML><HEAD>\n" .
409 "<TITLE>$title -- $gProject$Archived $gBug report logs</TITLE>\n" .
410 qq(<link rel="stylesheet" href="$gWebHostBugDir/css/bugs.css" type="text/css">) .
412 '<BODY onload="pagemain();">' .
414 print qq(<DIV id="status_mask"></DIV>\n);
415 print "<H1>" . "$gProject$Archived $gBug report logs: $title" .
420 my $pkg = $param{package} if defined $param{package};
421 my $src = $param{src} if defined $param{src};
423 my $pseudodesc = getpseudodesc();
424 if (defined $pseudodesc and defined $pkg and exists $pseudodesc->{$pkg}) {
428 # output infomration about the packages
430 for my $package (make_list($param{package}||[])) {
431 print generate_package_info(binary => 1,
437 for my $package (make_list($param{src}||[])) {
438 print generate_package_info(binary => 0,
445 if (exists $param{maint} or exists $param{maintenc}) {
446 print "<p>Note that maintainers may use different Maintainer fields for\n";
447 print "different packages, so there may be other reports filed under\n";
448 print "different addresses.\n";
450 if (exists $param{submitter}) {
451 print "<p>Note that people may use different email accounts for\n";
452 print "different bugs, so there may be other reports filed under\n";
453 print "different addresses.\n";
458 # my %archive_values = (both => 'archived and unarchived',
459 # 0 => 'not archived',
462 # while (my ($key,$value) = each %archive_values) {
463 # next if $key eq lc($param{archive});
464 # push @archive_links, qq(<a href=").
465 # html_escape(pkg_url((
467 # $_ eq 'archive'?():($_,$param{$_})
470 # )).qq(">$value reports </a>);
472 # print '<p>See the '.join (' or ',@archive_links)."</p>\n";
476 print pkg_javascript() . "\n";
478 print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);
480 print option_form(template => 'cgi/pkgreport_options',
482 form_options => $form_options,
483 variables => $form_option_variables,
486 # print "<h2 class=\"outstanding\"><a class=\"options\" href=\"javascript:toggle(1)\">Options</a></h2>\n";
487 # print "<div id=\"a_1\">\n";
488 # printf "<form action=\"%s\" method=POST>\n", myurl();
490 # print "<table class=\"forms\">\n";
492 # my ($checked_any, $checked_sui, $checked_ver) = ("", "", "");
493 # if (defined $dist) {
494 # $checked_sui = "CHECKED";
495 # } elsif (defined $version) {
496 # $checked_ver = "CHECKED";
498 # $checked_any = "CHECKED";
501 # print "<tr><td>Show bugs applicable to</td>\n";
502 # print " <td><input id=\"b_1_1\" name=vt value=none type=radio onchange=\"enable(1);\" $checked_any>anything</td></tr>\n";
503 # print "<tr><td></td>";
504 # print " <td><input id=\"b_1_2\" name=vt value=bysuite type=radio onchange=\"enable(1);\" $checked_sui>" . pkg_htmlselectsuite(1,2,1) . " for " . pkg_htmlselectarch(1,2,2) . "</td></tr>\n";
506 # if (defined $pkg) {
507 # my $v = html_escape($version) || "";
508 # my $pkgsane = html_escape($pkg->[0]);
509 # print "<tr><td></td>";
510 # print " <td><input id=\"b_1_3\" name=vt value=bypkg type=radio onchange=\"enable(1);\" $checked_ver>$pkgsane version <input id=\"b_1_3_1\" name=version value=\"$v\"></td></tr>\n";
511 # } elsif (defined $src) {
512 # my $v = html_escape($version) || "";
513 # my $srcsane = html_escape($src->[0]);
514 # print "<tr><td></td>";
515 # print " <td><input name=vt value=bysrc type=radio onchange=\"enable(1);\" $checked_ver>$srcsane version <input id=\"b_1_3_1\" name=version value=\"$v\"></td></tr>\n";
517 # print "<tr><td> </td></tr>\n";
519 # my $includetags = html_escape(join(" ", grep { !m/^subj:/i } map {split /[\s,]+/} ref($include)?@{$include}:$include));
520 # my $excludetags = html_escape(join(" ", grep { !m/^subj:/i } map {split /[\s,]+/} ref($exclude)?@{$exclude}:$exclude));
521 # my $includesubj = html_escape(join(" ", map { s/^subj://i; $_ } grep { m/^subj:/i } map {split /[\s,]+/} ref($include)?@{$include}:$include));
522 # my $excludesubj = html_escape(join(" ", map { s/^subj://i; $_ } grep { m/^subj:/i } map {split /[\s,]+/} ref($exclude)?@{$exclude}:$exclude));
523 # my $vismindays = ($mindays == 0 ? "" : $mindays);
524 # my $vismaxdays = ($maxdays == -1 ? "" : $maxdays);
526 # my $sel_rmy = ($param{repeatmerged} ? " selected" : "");
527 # my $sel_rmn = ($param{repeatmerged} ? "" : " selected");
528 # my $sel_ordraw = ($ordering eq "raw" ? " selected" : "");
529 # my $sel_ordold = ($ordering eq "oldview" ? " selected" : "");
530 # my $sel_ordnor = ($ordering eq "normal" ? " selected" : "");
531 # my $sel_ordage = ($ordering eq "age" ? " selected" : "");
533 # my $chk_bugrev = ($bug_rev ? " checked" : "");
534 # my $chk_pendrev = ($pend_rev ? " checked" : "");
535 # my $chk_sevrev = ($sev_rev ? " checked" : "");
538 # <tr><td>Only include bugs tagged with </td><td><input name=include value="$includetags"> or that have <input name=includesubj value="$includesubj"> in their subject</td></tr>
539 # <tr><td>Exclude bugs tagged with </td><td><input name=exclude value="$excludetags"> or that have <input name=excludesubj value="$excludesubj"> in their subject</td></tr>
540 # <tr><td>Only show bugs older than</td><td><input name=mindays value="$vismindays" size=5> days, and younger than <input name=maxdays value="$vismaxdays" size=5> days</td></tr>
542 # <tr><td> </td></tr>
544 # <tr><td>Merged bugs should be</td><td>
545 # <select name=repeatmerged>
546 # <option value=yes$sel_rmy>displayed separately</option>
547 # <option value=no$sel_rmn>combined</option>
549 # <tr><td>Categorise bugs by</td><td>
550 # <select name=ordering>
551 # <option value=raw$sel_ordraw>bug number only</option>
552 # <option value=old$sel_ordold>status and severity</option>
553 # <option value=normal$sel_ordnor>status, severity and classification</option>
554 # <option value=age$sel_ordage>status, severity, classification, and age</option>
559 # my $o = $param{"ordering"} || "";
560 # for my $n (keys %cats) {
561 # next if ($n eq "normal" || $n eq "oldview");
562 # next if defined $hidden{$n};
565 # print "<option disabled>------</option>\n";
567 # my @names = map { ref($_) eq "HASH" ? $_->{"nam"} : $_ } @{$cats{$n}};
569 # if (@names == 1) { $name = $names[0]; }
570 # else { $name = " and " . pop(@names); $name = join(", ", @names) . $name; }
572 # printf "<option value=\"%s\"%s>%s</option>\n",
573 # $n, ($o eq $n ? " selected" : ""), $name;
577 # print "</select></td></tr>\n";
579 # printf "<tr><td>Order bugs by</td><td>%s</td></tr>\n",
580 # pkg_htmlselectyesno("pend-rev", "outstanding bugs first", "done bugs first", $pend_rev);
581 # printf "<tr><td></td><td>%s</td></tr>\n",
582 # pkg_htmlselectyesno("sev-rev", "highest severity first", "lowest severity first", $sev_rev);
583 # printf "<tr><td></td><td>%s</td></tr>\n",
584 # pkg_htmlselectyesno("bug-rev", "oldest bugs first", "newest bugs first", $bug_rev);
587 # <tr><td> </td></tr>
588 # <tr><td colspan=2><input value="Reload page" type="submit"> with new settings</td></tr>
591 # print "</table></form></div>\n";
594 print fill_in_template(template=>'html/html_tail',
595 hole_var => {'&strftime' => \&POSIX::strftime,
598 print "</body></html>\n";