X-Git-Url: https://git.deb.at/?a=blobdiff_plain;ds=sidebyside;f=lib%2FPackages%2FDoShow.pm;h=9f59690589d59ec1745a27dc937fd24ee2bda1b3;hb=447df2e0fb5d84ebe7fab28bc786a6ab86d15f44;hp=05baeff8ea08463ed9624692ff7b5d604f26e39b;hpb=b688b16487ef2ca8ad7861d7c20da16a9f3f4448;p=deb%2Fpackages.git
diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm
index 05baeff..9f59690 100644
--- a/lib/Packages/DoShow.pm
+++ b/lib/Packages/DoShow.pm
@@ -12,9 +12,9 @@ use Exporter;
use Deb::Versions;
use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @SECTIONS
- @ARCHITECTURES %FTP_SITES );
-use Packages::I18N::Locale;
-use Packages::CGI qw( :DEFAULT make_url make_search_url note );
+ @ARCHITECTURES %FTP_SITES
+ @LANGUAGES @DDTP_LANGUAGES);
+use Packages::CGI qw( :DEFAULT make_url make_search_url );
use Packages::DB;
use Packages::Search qw( :all );
use Packages::Page ();
@@ -24,16 +24,18 @@ our @ISA = qw( Exporter );
our @EXPORT = qw( do_show );
sub do_show {
- my ($params, $opts, $html_header, $page_contents) = @_;
+ my ($params, $opts, $page_contents) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{package}) {
- fatal_error( _g( "package not valid or not specified" ) );
+ fatal_error( $cat->g( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( _g( "suite not valid or not specified" ) );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( sprintf( _g( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) );
+ fatal_error( $cat->g( "more than one suite specified for show (%s)",
+ "@{$opts->{suite}}" ) );
}
my %contents;
@@ -68,8 +70,8 @@ sub do_show {
}
unless (@results || @non_results ) {
- fatal_error( _g( "No such package." )."
".
- sprintf( _g( 'Search for the package' ), make_search_url('','keywords='.uri_escape($pkg)) ) );
+ fatal_error( $cat->g( "No such package.") );
+ #sprintf( _g( 'Search for the package' ), make_search_url('','keywords='.uri_escape($pkg)) ) );
} else {
my %all_suites;
foreach (@results, @non_results) {
@@ -80,7 +82,7 @@ sub do_show {
$contents{suites} = [ suites_sort(keys %all_suites) ];
unless (@results) {
- fatal_error( _g( "Package not available in this suite." ) );
+ fatal_error( $cat->g( "Package not available in this suite." ) );
} else {
$contents{page} = $page;
unless ($opts->{source}) {
@@ -88,7 +90,7 @@ sub do_show {
for my $entry (@results) {
debug( join(":", @$entry), 1 ) if DEBUG;
my (undef, $archive, undef, $arch, $section, $subsection,
- $priority, $version, $provided_by) = @$entry;
+ $priority, $version, undef, $provided_by) = @$entry;
if ($arch ne 'virtual') {
my %data = split /\000/, $packages_all{"$pkg $arch $version"};
@@ -111,6 +113,8 @@ sub do_show {
debug( "find source package: source=$source", 1) if DEBUG;
my $src_data = $sources_all{"$archive $suite $source"};
+ #FIXME: should be $main_archive or similar, not hardcoded "us"
+ $src_data = $sources_all{"us $suite $source"} unless $src_data;
$page->add_src_data( $source, $src_data )
if $src_data;
@@ -118,21 +122,19 @@ sub do_show {
my $std = timediff($st1, $st0);
debug( "Data search and merging took ".timestr($std) ) if DEBUG;
+ my @similar = find_similar( $pkg, "$DBDIR/xapian/",
+ \%did2pkg );
+ $contents{similar} = \@similar;
+
my $did = $page->get_newest( 'description' );
- my @complete_tags = split(/, /, $page->get_newest( 'tag' ));
+ my $desc_md5 = $page->get_newest( 'description-md5' );
+ my @complete_tags = split(/, /, $page->get_newest( 'tag' )||'' );
my @tags;
foreach (@complete_tags) {
my ($facet, $tag) = split( /::/, $_, 2);
- # handle tags like devel::{lang:c,lang:c++}
- if ($tag =~ s/^\{(.+)\}$/$1/) {
- foreach (split( /,/, $tag )) {
- next if $tag =~ /^special:/;
- push @tags, [ $facet, $_ ];
- }
- } else {
- next if $tag =~ /^special:/;
- push @tags, [ $facet, $tag ];
- }
+ next if $facet =~ /^special/;
+ next if $tag =~ /^special:/;
+ push @tags, [ $facet, $tag ];
}
$contents{tags} = \@tags;
@@ -151,29 +153,55 @@ sub do_show {
# process description
#
- my $desc = $descriptions{$did};
- $short_desc = encode_entities( $1, "<>&\"" )
- if $desc =~ s/^(.*)$//m;
- my $long_desc = encode_entities( $desc, "<>&\"" );
+ sub process_description {
+ my ($desc) = @_;
+
+ my $short_desc = encode_entities( $1, "<>&\"" )
+ if $desc =~ s/^(.*)$//m;
+ my $long_desc = encode_entities( $desc, "<>&\"" );
- $long_desc =~ s,((ftp|http|https)://[\S~-]+?/?)((\>\;)?[)]?[']?[:.\,]?(\s|$)),$1$3,go; # syntax highlighting -> '];
- $long_desc =~ s/\A //o;
- $long_desc =~ s/\n /\n/sgo;
- $long_desc =~ s/\n.\n/\n
\n/go; - $long_desc =~ s/(((\n|\A) [^\n]*)+)/\n
$1\n<\/pre>/sgo; + $long_desc =~ s,((ftp|http|https)://[\S~-]+?/?)((\>\;)?[)]?[']?[:.\,]?(\s|$)),$1$3,go; # syntax highlighting -> ']; + $long_desc =~ s/\A //o; + $long_desc =~ s/\n /\n/sgo; + $long_desc =~ s/\n.\n/\n\n/go; + $long_desc =~ s/(((\n|\A) [^\n]*)+)/\n
$1\n<\/pre>/sgo; - $contents{desc} = { short => $short_desc, - long => $long_desc, }; + return ($short_desc, $long_desc); + } + + my $desc = $descriptions{$did}; + my $long_desc; + ($short_desc, $long_desc) = process_description($desc); + + $contents{desc}{en} = { short => $short_desc, + long => $long_desc, }; + + debug( "desc_md5=$desc_md5", 2) + if DEBUG; + my $trans_desc = $desctrans{$desc_md5}; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + my %all_langs = map { $_ => 1 } (@LANGUAGES, keys %trans_desc); + $contents{used_langs} = [ keys %all_langs ]; + debug( "TRANSLATIONS: ".join(" ",keys %trans_desc), 2) + if DEBUG; + while (my ($l, $d) = each %trans_desc) { + my ($short_t, $long_t) = process_description($d); + + $contents{desc}{$l} = { short => $short_t, + long => $long_t, }; + } + } my $v_str = $version; my $multiple_versions = grep { $_ ne $version } values %$versions; - $v_str .= _g(" and others") if $multiple_versions; + $v_str .= $cat->g(" and others") if $multiple_versions; $contents{versions} = { short => $v_str, multiple => $multiple_versions }; my $provided_by = $page->{provided_by}; $contents{providers} = []; - pkg_list( \%packages, $opts, $provided_by, 'en', $contents{providers} ) if $provided_by; + pkg_list( \%packages, $opts, $provided_by, $contents{providers} ) if $provided_by; # # display dependencies @@ -197,12 +225,12 @@ sub do_show { my @downloads; foreach my $a ( @archs ) { my %d = ( arch => $a, - pkgsize => sprintf( '%.1f', floor(($sizes_deb->{$a}/102.4)+0.5)/10 ), + pkgsize => floor(($sizes_deb->{$a}/102.4)+0.5)/10, instsize => $sizes_inst->{$a}, ); $d{version} = $versions->{$a} if $multiple_versions; $d{archive} = $archives->{$a}; - if ( ($suite ne "experimental") + if ( ($suite ne "woody") && ($suite ne "bo") && ($subsection ne 'debian-installer')) { $d{contents_avail} = 1; } @@ -213,20 +241,22 @@ sub do_show { # # more information # + my $changesandcopy = 0; + $changesandcopy = 1 if suites_cmp($suite, "woody") >= 0; moreinfo( name => $pkg, data => $page, vars => \%contents, opts => $opts, env => \%FTP_SITES, bugreports => 1, sourcedownload => 1, - changesandcopy => 1, maintainers => 1, + changesandcopy => $changesandcopy, maintainers => 1, search => 1 ); } else { # unless $page->is_virtual $contents{is_virtual} = 1; - $contents{desc}{short} = _g( "virtual package" ); + $contents{desc}{short} = $cat->g( "virtual package" ); $contents{subsection} = 'virtual'; my $provided_by = $page->{provided_by}; $contents{providers} = []; - pkg_list( \%packages, $opts, $provided_by, 'en', $contents{providers} ); + pkg_list( \%packages, $opts, $provided_by, $contents{providers} ); } # else (unless $page->is_virtual) } else { # unless $opts->{source} @@ -258,7 +288,7 @@ sub do_show { my $binaries = find_binaries( $pkg, $archive, $suite, \%src2bin ); if ($binaries && @$binaries) { $contents{binaries} = []; - pkg_list( \%packages, $opts, $binaries, 'en', $contents{binaries} ); + pkg_list( \%packages, $opts, $binaries, $contents{binaries} ); } # @@ -281,24 +311,25 @@ sub do_show { foreach( @$source_files ) { my ($src_file_md5, $src_file_size, $src_file_name) = split /\s+/, $_; - (my $server = lc $archive) =~ s/-//go; # non-US hack - $server = $FTP_SITES{$server} + my $server = $FTP_SITES{lc $archive} || $FTP_SITES{us}; my $path = "/$source_dir/$src_file_name"; push @{$contents{srcfiles}}, { server => $server, path => $path, filename => $src_file_name, - size => sprintf("%.1f", (floor(($src_file_size/102.4)+0.5)/10)), + size => floor(($src_file_size/102.4)+0.5)/10, md5sum => $src_file_md5 }; } # # more information # + my $changesandcopy = 0; + $changesandcopy = 1 if suites_cmp($suite, "woody") >= 0; moreinfo( name => $pkg, data => $page, vars => \%contents, opts => $opts, env => \%FTP_SITES, bugreports => 1, - changesandcopy => 1, maintainers => 1, + changesandcopy => $changesandcopy, maintainers => 1, search => 1, is_source => 1 ); } # else (unless $opts->{source}) @@ -329,23 +360,17 @@ sub moreinfo { if ($info{sourcedownload}) { $contents->{src}{url} = make_url($source,'',{source=>'source'}); $contents->{src}{pkg} = $source; + $contents->{src}{version} = $source_version; my @downloads; my $files = $page->get_src( 'files' ); if (defined($files) and @$files) { foreach( @$files ) { my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_; - my ($name, $server, $path); - # non-US hack - ($server = lc $page->get_newest('archive')) =~ s/-//go; - $server = $env->{$server}||$env->{us}; - $path = "$src_dir/$src_file_name"; - if ($src_file_name =~ /dsc$/) { - $name = 'dsc' - } else { - $name = $src_file_name; - } - push @downloads, { name => $name, server => $server, path => $path }; + my ($server, $path); + $server = $env->{lc $page->get_newest('archive')}||$env->{us}; + $path = "/$src_dir/$src_file_name"; + push @downloads, { name => $src_file_name, server => $server, path => $path }; } } $contents->{src}{downloads} = \@downloads; @@ -356,7 +381,6 @@ sub moreinfo { (my $src_basename = $source_version) =~ s,^\d+:,,; # strip epoche $src_basename = "${source}_$src_basename"; $src_dir =~ s,pool/updates,pool,o; - $src_dir =~ s,pool/non-US,pool,o; $contents->{files}{changelog}{path} = "$src_dir/$src_basename/changelog"; $contents->{files}{copyright}{path} = "$src_dir/$src_basename/".( $is_source ? 'copyright' : "$name.copyright" ); @@ -388,6 +412,7 @@ sub build_deps { 'suggests' => 'sug', 'build-depends' => 'adep', 'build-depends-indep' => 'idep' ); my $suite = $opts->{suite}[0]; + my $cat = $opts->{cat}; my %out = ( id => $dep_type{$type}, terms => [] ); @@ -406,7 +431,7 @@ sub build_deps { if ($arch_str ||= '') { if ($arch_neg) { - $arch_str = _g("not")." $arch_str"; + $arch_str = $cat->g("not %s", "$arch_str" ); } else { $arch_str = $arch_str; } @@ -422,11 +447,23 @@ sub build_deps { my $entry = $entries{$p_name} || read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite); my $short_desc = $entry->[-1]; + my $desc_md5 = $entry->[-2] || ''; my $arch = $entry->[3]; my $archive = $entry->[1]; my $p_suite = $entry->[2]; if ( $short_desc ) { $rel_alt_out{desc} = $short_desc; + my $trans_desc = $desctrans{$desc_md5}; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + my %sdescs; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + $rel_alt_out{trans_desc} = \%sdescs; + } $rel_alt_out{suite} = $p_suite; if ( $rel_out{is_old_pkgs} ) { } elsif (defined $entry->[1]) { @@ -444,7 +481,7 @@ sub build_deps { } } elsif ( $rel_out{is_old_pkgs} ) { } else { - $rel_alt_out{desc} = _g( "Package not available" ); + $rel_alt_out{desc} = $cat->g( "Package not available" ); $rel_alt_out{suite} = ''; } push @{$rel_out{alternatives}}, \%rel_alt_out; @@ -458,19 +495,32 @@ sub build_deps { } # end print_deps sub pkg_list { - my ( $packages, $opts, $pkgs, $lang, $list ) = @_; + my ( $packages, $opts, $pkgs, $list ) = @_; my $suite = $opts->{suite}[0]; foreach my $p ( sort @$pkgs ) { # we don't deal with virtual packages here because for the # current uses of this function this isn't needed - my $short_desc = (read_entry_simple( $packages, $p, $opts->{h_archives}, $suite))->[-1]; + my $data = read_entry_simple( $packages, $p, $opts->{h_archives}, $suite); + my ($desc_md5, $short_desc) = ($data->[-2],$data->[-1]); if ( $short_desc ) { - push @$list, { name => $p, desc => $short_desc, available => 1 }; + my $trans_desc = $desctrans{$desc_md5}; + my %sdescs; + if ($trans_desc) { + my %trans_desc = split /\000|\001/, $trans_desc; + while (my ($l, $d) = each %trans_desc) { + $d =~ s/\n.*//os; + + $sdescs{$l} = $d; + } + } + push @$list, { name => $p, desc => $short_desc, + trans_desc => \%sdescs, available => 1 }; } else { - push @$list, { name => $p, desc => _g("Not available") }; + push @$list, { name => $p, + desc => $opts->{cat}->g("Not available") }; } } }