X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=lib%2FPackages%2FDoShow.pm;h=3964e7853ed54d30aa7635cc94e96b854383c9de;hb=6c89d8070adba05c8b39f529fba4fef517db4b80;hp=f808f1f7e547b57ea5ac56e1837eafe55c77728f;hpb=1cc237c732b99138c613a79c59db361f75f9dd71;p=deb%2Fpackages.git
diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm
index f808f1f..3964e78 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 @DDTP_LANGUAGES);
-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"};
@@ -120,22 +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 $desc_md5 = $page->get_newest( 'description-md5' );
- my @complete_tags = split(/, /, $page->get_newest( 'tag' ));
+ 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;
@@ -182,6 +181,8 @@ sub do_show {
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) {
@@ -194,13 +195,13 @@ sub do_show {
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
@@ -224,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;
}
@@ -244,16 +245,16 @@ sub do_show {
opts => $opts,
env => \%FTP_SITES,
bugreports => 1, sourcedownload => 1,
- changesandcopy => 1, maintainers => 1,
+ changesandcopy => 0, 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}
@@ -285,7 +286,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} );
}
#
@@ -308,13 +309,12 @@ 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 };
}
@@ -325,7 +325,7 @@ sub do_show {
opts => $opts,
env => \%FTP_SITES,
bugreports => 1,
- changesandcopy => 1, maintainers => 1,
+ changesandcopy => 0, maintainers => 1,
search => 1, is_source => 1 );
} # else (unless $opts->{source})
@@ -363,9 +363,7 @@ sub moreinfo {
foreach( @$files ) {
my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_;
my ($server, $path);
- # non-US hack
- ($server = lc $page->get_newest('archive')) =~ s/-//go;
- $server = $env->{$server}||$env->{us};
+ $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 };
}
@@ -378,7 +376,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" );
@@ -410,6 +407,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 => [] );
@@ -428,7 +426,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;
}
@@ -444,11 +442,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]) {
@@ -466,7 +476,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;
@@ -480,19 +490,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") };
}
}
}