X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=lib%2FPackages%2FDoDownload.pm;h=bb7d073795861a4f1e95d10298b0caca76d1ce67;hb=a6b39cb5eec2cf7d8a0d756f0090a9d8644443c9;hp=bc7dbab0e6d57a78783f81ede244f65e76cc6876;hpb=10253a9c867f3036137ef5ed5379da930ef04c20;p=deb%2Fpackages.git diff --git a/lib/Packages/DoDownload.pm b/lib/Packages/DoDownload.pm index bc7dbab..bb7d073 100644 --- a/lib/Packages/DoDownload.pm +++ b/lib/Packages/DoDownload.pm @@ -10,7 +10,6 @@ use Benchmark ':hireswallclock'; use Exporter; use Deb::Versions; -use Packages::I18N::Locale; use Packages::Search qw( :all ); use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES ); use Packages::CGI; @@ -22,21 +21,24 @@ our @EXPORT = qw( do_download ); sub do_download { my ($params, $opts, $page_content) = @_; + 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 ($params->{errors}{arch}) { - fatal_error( _g( "architecture not valid or not specified" ) ); + fatal_error( $cat->g( "architecture not valid or not specified" ) ); } if (@{$opts->{suite}} > 1) { - fatal_error( sprintf( _g( "more than one suite specified for download (%s)" ), "@{$opts->{suite}}" ) ); + fatal_error( $cat->g( "more than one suite specified for download (%s)", + "@{$opts->{suite}}" ) ); } if (@{$opts->{arch}} > 1) { - fatal_error( sprintf( _g( "more than one architecture specified for download (%s)" ), "@{$opts->{arch}}" ) ); + fatal_error( $cat->g( "more than one architecture specified for download (%s)", + "@{$opts->{arch}}" ) ); } $opts->{h_sections} = { map { $_ => 1 } @SECTIONS }; @@ -70,11 +72,11 @@ sub do_download { debug( "final_result=@$final_result", 1 ); $archive = $final_result->[1]; - my %data = split /\000/, $packages_all{"$pkg $arch $final_result->[7]"}; + my %data = split(/\000/, $packages_all{"$pkg $arch $final_result->[7]"}||''); if (!%data && $arch ne 'all' && $final_result->[3] eq 'all') { %data = split /\000/, $packages_all{"$pkg all $final_result->[7]"}; - $arch = 'all'; debug( "choosing arch 'all' instead of requested arch $arch", 1 ); + $arch = 'all'; # fatal_error( _g( "No such package." )."
". # sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ) unless %data; } @@ -87,11 +89,11 @@ sub do_download { $page_content->{pkg} = $pkg; my $pkgsize = floor(($data{size}/102.4)+0.5)/10; if ($pkgsize < 1024) { - $page_content->{pkgsize} = sprintf( '%.1f', $pkgsize ); - $page_content->{pkgsize_unit} = _g( 'kByte' ); + $page_content->{pkgsize} = $pkgsize; + $page_content->{pkgsize_unit} = $cat->g( 'kByte' ); } else { - $page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/(102.4*102.4))+0.5)/100 ); - $page_content->{pkgsize_unit} = _g( 'MByte' ); + $page_content->{pkgsize} = floor(($data{size}/(102.4*102.4))+0.5)/100; + $page_content->{pkgsize_unit} = $cat->g( 'MByte' ); } $page_content->{architecture} = $arch; foreach (keys %data) {