X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=Debbugs%2FCGI%2FPkgreport.pm;h=28c1f75b4d6a63fbc7ff7dcac3ed5ef45daa037b;hb=f4cac5c0b345b08f67844df7eecd18f66c156c9e;hp=d047affb1d262827d204552b3fc4c52ece4e9b63;hpb=dfffc9e4190838650697c3758a477e92f49939a3;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index d047aff..28c1f75 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -28,11 +28,16 @@ None known. use warnings; use strict; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); -use base qw(Exporter); +use Exporter qw(import); use IO::Scalar; use Params::Validate qw(validate_with :types); +use Debbugs::Collection::Bug; + +use Carp; +use List::AllUtils qw(apply); + use Debbugs::Config qw(:config :globals); use Debbugs::CGI qw(:url :html :util); use Debbugs::Common qw(:misc :util :date); @@ -41,6 +46,7 @@ use Debbugs::Bugs qw(bug_filter); use Debbugs::Packages qw(:mapping); use Debbugs::Text qw(:templates); +use Encode qw(decode_utf8); use POSIX qw(strftime); @@ -80,6 +86,9 @@ sub generate_package_info{ }, bugs => {type => ARRAYREF, }, + schema => {type => OBJECT, + optional => 1, + }, }, ); @@ -90,26 +99,41 @@ sub generate_package_info{ my %pkgsrc = %{getpkgsrc()}; my $srcforpkg = $package; - if ($param{binary} and exists $pkgsrc{$package} - and defined $pkgsrc{$package}) { - $srcforpkg = $pkgsrc{$package}; + if ($param{binary}) { + $srcforpkg = + binary_to_source(source_only => 1, + scalar_only => 1, + binary => $package, + hash_slice(%param,qw(schema)), + ); } my $showpkg = html_escape($package); - my $maintainers = getmaintainers(); - my $maint = $maintainers->{$srcforpkg}; - if (defined $maint) { + my @maint = package_maintainer($param{binary}?'binary':'source', + $package, + hash_slice(%param,qw(schema)), + ); + if (@maint) { print {$output} '
'; - print {$output} (($maint =~ /,/)? "Maintainer for $showpkg is " + print {$output} (@maint > 1? "Maintainer for $showpkg is " : "Maintainers for $showpkg are ") . - package_links(maint => $maint); + package_links(maintainer => \@maint); print {$output} ".
\n"; } else { print {$output} "There is no maintainer for $showpkg. ". - "Please do not report new bugs against this package.
\n"; + "This means that this package no longer exists (or never existed). ". + "Please do not report new bugs against this package. \n"; } - my @pkgs = getsrcpkgs($srcforpkg); + my @pkgs = source_to_binary(source => $srcforpkg, + hash_slice(%param,qw(schema)), + binary_only => 1, + # if there are distributions, only bother to + # show packages which are currently in a + # distribution. + @{$config{distributions}//[]} ? + (dist => [@{$config{distributions}}]) : (), + ); @pkgs = grep( !/^\Q$package\E$/, @pkgs ); if ( @pkgs ) { @pkgs = sort @pkgs; @@ -126,25 +150,20 @@ sub generate_package_info{ my @references; my $pseudodesc = getpseudodesc(); if ($package and defined($pseudodesc) and exists($pseudodesc->{$package})) { - push @references, "to the ". + push @references, "to the ". "list of other pseudo-packages"; } - elsif (not defined $maint and not @{$param{bugs}}) { - print {$output} "There is no record of the " . html_escape($package) . - ($param{binary} ? " package" : " source package") . - ", and no bugs have been filed against it.
"; - } else { if ($package and defined $config{package_pages} and length $config{package_pages}) { push @references, sprintf "to the %s package page", - html_escape("http://$config{package_pages}/$package"), html_escape("$package"); + html_escape("$config{package_pages}/$package"), html_escape("$package"); } - if (defined $config{subscription_domain} and - length $config{subscription_domain}) { + if (defined $config{package_tracking_domain} and + length $config{package_tracking_domain}) { my $ptslink = $param{binary} ? $srcforpkg : $package; # the pts only wants the source, and doesn't care about src: (#566089) $ptslink =~ s/^src://; - push @references, q(to the Package Tracking System); + push @references, q(to the Package Tracking System); } # Only output this if the source listing is non-trivial. if ($param{binary} and $srcforpkg) { @@ -159,12 +178,12 @@ sub generate_package_info{ $references[$#references] = "or $references[$#references]" if @references > 1; print {$output} "You might like to refer ", join(", ", @references), ".
\n"; } - if (defined $maint) { + if (@maint) { print {$output} "If you find a bug not listed here, please\n"; printf {$output} "report it.
\n", - html_escape("http://$config{web_domain}/Reporting$config{html_suffix}"); + html_escape("$config{web_domain}/Reporting$config{html_suffix}"); } - return $output_scalar; + return decode_utf8($output_scalar); } @@ -196,52 +215,14 @@ display below sub short_bug_status_html { my %param = validate_with(params => \@_, - spec => {status => {type => HASHREF, - }, - options => {type => HASHREF, - default => {}, - }, - bug_options => {type => HASHREF, - default => {}, - }, - snippet => {type => SCALAR, - default => '', - }, + spec => {bug => {type => OBJECT, + isa => 'Debbugs::Bug', + }, }, ); - my %status = %{$param{status}}; - - $status{tags_array} = [sort(split(/\s+/, $status{tags}))]; - $status{date_text} = strftime('%a, %e %b %Y %T UTC', gmtime($status{date})); - $status{mergedwith_array} = [split(/ /,$status{mergedwith})]; - - my @blockedby= split(/ /, $status{blockedby}); - $status{blockedby_array} = []; - if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) { - for my $b (@blockedby) { - my %s = %{get_bug_status($b)}; - next if $s{"pending"} eq 'fixed' || length $s{done}; - push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - - my @blocks= split(/ /, $status{blocks}); - $status{blocks_array} = []; - if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) { - for my $b (@blocks) { - my %s = %{get_bug_status($b)}; - next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); - push @{$status{blocks_array}}, {bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - my $days = bug_archiveable(bug => $status{id}, - status => \%status, - days_until => 1, - ); - $status{archive_days} = $days; return fill_in_template(template => 'cgi/short_bug_status', - variables => {status => \%status, + variables => {bug => $param{bug}, isstrongseverity => \&Debbugs::Status::isstrongseverity, html_escape => \&Debbugs::CGI::html_escape, looks_like_number => \&Scalar::Util::looks_like_number, @@ -259,7 +240,7 @@ sub short_bug_status_html { sub pkg_htmlizebugs { my %param = validate_with(params => \@_, - spec => {bugs => {type => ARRAYREF, + spec => {bugs => {type => OBJECT, }, names => {type => ARRAYREF, }, @@ -297,25 +278,20 @@ sub pkg_htmlizebugs { dist => {type => SCALAR, optional => 1, }, + schema => {type => OBJECT, + optional => 1, + }, } ); - my @bugs = @{$param{bugs}}; - - my @status = (); + my $bugs = $param{bugs}; my %count; my $header = ''; my $footer = "