X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=lib%2FPackages%2FDoShow.pm;h=e3e1945b6b7cc7123e4705a47f681e79f16106f1;hp=0f97b83da0840268f02a6395499341171ec3d7c6;hb=8d29452530e823cbcd07a30898e98abe565a046c;hpb=56d4b3ed57e20359e5ea46feabb850cf4a94caf2 diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm index 0f97b83..e3e1945 100644 --- a/lib/Packages/DoShow.pm +++ b/lib/Packages/DoShow.pm @@ -1,6 +1,7 @@ package Packages::DoShow; use strict; +use warnings; use POSIX; use URI::Escape; @@ -27,13 +28,13 @@ sub do_show { my ($params, $opts, $html_header, $menu, $page_content) = @_; if ($params->{errors}{package}) { - fatal_error( _( "package not valid or not specified" ) ); + fatal_error( _g( "package not valid or not specified" ) ); } if ($params->{errors}{suite}) { - fatal_error( _( "suite not valid or not specified" ) ); + fatal_error( _g( "suite not valid or not specified" ) ); } if (@{$opts->{suite}} > 1) { - fatal_error( sprintf( _( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) ); + fatal_error( sprintf( _g( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) ); } my $pkg = $opts->{package}; @@ -68,36 +69,30 @@ sub do_show { } unless (@results || @non_results ) { - fatal_error( _( "No such package." )."
". - sprintf( _( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ); + fatal_error( _g( "No such package." )."
". + sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ); } else { my %all_suites; foreach (@results, @non_results) { my $a = $_->[1]; my $s = $_->[2]; - if ($a =~ /^(?:us|security|non-US)$/o) { - $all_suites{$s}++; - } else { - $all_suites{"$s/$a"}++; - } + $all_suites{$s}++; } foreach (suites_sort(keys %all_suites)) { - if (("$suite/$archive" eq $_) - || (!$all_suites{"$suite/$archive"} && ($suite eq $_))) { + if ($suite eq $_) { $$menu .= "[ $_ ] "; } else { - $$menu .= - "[ $_ ] "; + $$menu .= "[ $suite})."\">$_ ] "; } } $$menu .= '
'; unless (@results) { - fatal_error( _( "Package not available in this suite." ) ); + fatal_error( _g( "Package not available in this suite." ) ); } else { unless ($opts->{source}) { for my $entry (@results) { - debug( join(":", @$entry), 1 ); + debug( join(":", @$entry), 1 ) if DEBUG; my (undef, $archive, undef, $arch, $section, $subsection, $priority, $version, $provided_by) = @$entry; @@ -106,7 +101,8 @@ sub do_show { $data{package} = $pkg; $data{architecture} = $arch; $data{version} = $version; - $page->merge_package(\%data) or debug( "Merging $pkg $arch $version FAILED", 2 ); + $page->merge_package(\%data) + or debug( "Merging $pkg $arch $version FAILED", 2 ) if DEBUG; } else { $page->add_provided_by([split /\s+/, $provided_by]); } @@ -116,22 +112,22 @@ sub do_show { $version = $page->{newest}; my $source = $page->get_newest( 'source' ); $archive = $page->get_newest( 'archive' ); - debug( "find source package: source=$source", 1); + debug( "find source package: source=$source", 1) if DEBUG; my $src_data = $sources_all{"$archive $suite $source"}; $page->add_src_data( $source, $src_data ) if $src_data; my $st1 = new Benchmark; my $std = timediff($st1, $st0); - debug( "Data search and merging took ".timestr($std) ); + debug( "Data search and merging took ".timestr($std) ) if DEBUG; - my ($v_str, $v_str_arch, $v_str_arr) = $page->get_version_string(); my $did = $page->get_newest( 'description' ); $section = $page->get_newest( 'section' ); $subsection = $page->get_newest( 'subsection' ); my $filenames = $page->get_arch_field( 'filename' ); my $file_md5sums = $page->get_arch_field( 'md5sum' ); my $archives = $page->get_arch_field( 'archive' ); + my $versions = $page->get_arch_field( 'version' ); my $sizes_inst = $page->get_arch_field( 'installed-size' ); my $sizes_deb = $page->get_arch_field( 'size' ); my @archs = sort $page->get_architectures; @@ -148,40 +144,43 @@ sub do_show { $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 = conv_desc( $lang, $long_desc );
-# 	    $short_desc = conv_desc( $lang, $short_desc );
-
-			$$menu .= simple_menu( [ _( "Distribution:" ),
-						 _( "Overview over this suite" ),
-						 "$ROOT/$suite/",
-						 $suite ],
-					       [ _( "Section:" ),
-						 _( "All packages in this section" ),
-						 "$ROOT/$suite/$subsection/",
-						 $subsection ],
-					       );
-
-			my $title .= sprintf( _( "Package: %s (%s)" ), $pkg, $v_str );
+			my @menu = ( [ _g( "Distribution:" ),
+				       _g( "Overview over this suite" ),
+				       make_url("/",''),
+				       $suite ],
+				     [ _g( "Section:" ),
+				       _g( "All packages in this section" ),
+				       make_url("$subsection/",''),
+				       $subsection ], );
+			my $source = $page->get_src('package');
+			push @menu, [ _g( "Source:" ),
+				      _g( "Source package building this package" ),
+				      make_url($source,'',{source=>'source'}),
+				      $source ] if $source;
+			$$menu .= simple_menu( @menu );
+
+			my $v_str = $version;
+			my $multiple_versions = grep { $_ ne $version } values %$versions;
+			$v_str .= _g(" and others") if $multiple_versions;
+			my $title .= sprintf( _g( "Package: %s (%s)" ), $pkg, $v_str );
 			$title .=  " ".marker( $archive ) if $archive ne 'us';
 			$title .=  " ".marker( $subsection ) if $subsection eq 'non-US'
 			    and $archive ne 'non-US'; # non-US/security
 			$title .=  " ".marker( $section ) if $section ne 'main';
 			$package_page .= title( $title );
 			
-			$package_page .= "

"._( "Versions:" )." $v_str_arch

\n" - unless $version eq $v_str; if (my $provided_by = $page->{provided_by}) { - note( _( "This is also a virtual package provided by ").join( ', ', map { "$_" } @$provided_by) ); + note( _g( "This is also a virtual package provided by ").join( ', ', map { "$_" } @$provided_by) ); } if ($suite eq "experimental") { - note( _( "Experimental package"), - _( "Warning: This package is from the experimental distribution. That means it is likely unstable or buggy, and it may even cause data loss. If you ignore this warning and install it nevertheless, you do it on your own risk.")."

" + note( _g( "Experimental package"), + _g( "Warning: This package is from the experimental distribution. That means it is likely unstable or buggy, and it may even cause data loss. If you ignore this warning and install it nevertheless, you do it on your own risk.")."

" ); } if ($subsection eq "debian-installer") { - note( _( "debian-installer udeb package"), - _( 'Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.' ) + note( _g( "debian-installer udeb package"), + _g( 'Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.' ) ); } $package_page .= pdesc( $short_desc, $long_desc ); @@ -202,14 +201,11 @@ sub do_show { if ( $dep_list ) { $package_page .= "
\n"; - $package_page .= sprintf( "

"._( "Other Packages Related to %s" )."

\n", $pkg ); - if ($suite eq "experimental") { - note( sprintf( _( 'Note that the experimental distribution is not self-contained; missing dependencies are likely found in the unstable distribution.' ), "$ROOT/unstable/" ) ); - } + $package_page .= sprintf( "

"._g( "Other Packages Related to %s" )."

\n", $pkg ); - $package_page .= pdeplegend( [ 'dep', _( 'depends' ) ], - [ 'rec', _( 'recommends' ) ], - [ 'sug', _( 'suggests' ) ], ); + $package_page .= pdeplegend( [ 'dep', _g( 'depends' ) ], + [ 'rec', _g( 'recommends' ) ], + [ 'sug', _g( 'suggests' ) ], ); $package_page .= $dep_list; $package_page .= "
\n"; @@ -220,27 +216,36 @@ sub do_show { # my $encodedpack = uri_escape( $pkg ); $package_page .= "
"; - $package_page .= sprintf( "

"._( "Download %s\n" )."

", + $package_page .= sprintf( "

"._g( "Download %s\n" )."

", $pkg ) ; - $package_page .= "\n"; - $package_page .= "\n"; + $package_page .= "
"._("Download for all available architectures")."
\n"; + $package_page .= "\n"; $package_page .= "\n"; - $package_page .= "\n"; + $package_page .= ""; + $package_page .= "" + if $multiple_versions; + $package_page .= "\n"; foreach my $a ( @archs ) { $package_page .= "\n"; - $package_page .= "\n"; - $package_page .= "" + if $multiple_versions; + $package_page .= '\n\n"; } $package_page .= "
"._g("Download for all available architectures")."
"._("Architecture").""._("Files").""._( "Package Size").""._("Installed Size")."
"._g("Architecture").""._g("Version").""._g( "Package Size").""._g("Installed Size").""._g("Files")."
$a"; + $package_page .= "".$versions->{$a}."'; + # package size + $package_page .= sprintf(_g('%.1f kB'), + floor(($sizes_deb->{$a}/102.4)+0.5)/10); + $package_page .= ''; + # installed size + $package_page .= sprintf(_g('%d kB'), + $sizes_inst->{$a}); + $package_page .= ""; if ( $suite ne "experimental" ) { - $package_page .= sprintf( "["._( "list of files" )."]\n", - "$ROOT/$suite/$encodedpkg/$a/filelist", $pkg ); + $package_page .= sprintf( "["._g( "list of files" )."]\n", + make_url("$encodedpkg/$a/filelist",''), $pkg ); } else { - $package_page .= _( "no current information" ); + $package_page .= _g( "no current information" ); } - $package_page .= ''; - $package_page .= floor(($sizes_deb->{$a}/102.4)+0.5)/10 . " kB"; - $package_page .= ''; - $package_page .= $sizes_inst->{$a} . " kB"; $package_page .= "
\n"; @@ -256,63 +261,62 @@ sub do_show { changesandcopy => 1, maintainers => 1, search => 1 ); } else { # unless $page->is_virtual - $short_desc = _( "virtual package" ); + $short_desc = _g( "virtual package" ); - $$menu .= simple_menu( [ _( "Distribution:" ), - _( "Overview over this distribution" ), - "$ROOT/", + $$menu .= simple_menu( [ _g( "Distribution:" ), + _g( "Overview over this distribution" ), + make_url('/',''), $suite ], - [ _( "Section:" ), - _( "All packages in this section" ), - "$ROOT/$suite/virtual/", + [ _g( "Section:" ), + _g( "All packages in this section" ), + make_url("virtual/",''), 'virtual' ], ); - $package_page .= title( sprintf( _( "Virtual Package: %s" ), + $package_page .= title( sprintf( _g( "Virtual Package: %s" ), $pkg ) ); my $policy_url = 'http://www.debian.org/doc/debian-policy/'; - note( sprintf( _( 'This is a virtual package. See the Debian policy for a definition of virtual packages.' ), + note( sprintf( _g( 'This is a virtual package. See the Debian policy for a definition of virtual packages.' ), $policy_url, $policy_url )); - $package_page .= sprintf( "

"._( "Packages providing %s" )."

", $pkg ); + $package_page .= sprintf( "

"._g( "Packages providing %s" )."

", $pkg ); my $provided_by = $page->{provided_by}; $package_page .= pkg_list( \%packages, $opts, $provided_by, 'en'); } # else (unless $page->is_virtual) } else { # unless $opts->{source} for my $entry (@results) { - debug( join(":", @$entry), 1 ); + debug( join(":", @$entry), 1 ) if DEBUG; my (undef, $archive, undef, $section, $subsection, $priority, $version) = @$entry; my $data = $sources_all{"$archive $suite $pkg"}; $page->merge_data($pkg, $suite, $archive, $data) - or debug( "Merging $pkg $version FAILED", 2 ); + or debug( "Merging $pkg $version FAILED", 2 ) if DEBUG; } $version = $page->{version}; my $st1 = new Benchmark; my $std = timediff($st1, $st0); - debug( "Data search and merging took ".timestr($std) ); + debug( "Data search and merging took ".timestr($std) ) if DEBUG; - my ($v_str, $v_str_arr) = $page->get_version_string(); $archive = $page->get_newest( 'archive' ); $section = $page->get_newest( 'section' ); $subsection = $page->get_newest( 'subsection' ); - $$menu .= simple_menu( [ _( "Distribution:" ), - _( "Overview over this suite" ), - "/$suite/", + $$menu .= simple_menu( [ _g( "Distribution:" ), + _g( "Overview over this suite" ), + make_url('/',''), $suite ], - [ _( "Section:" ), - _( "All packages in this section" ), - "/$suite/$subsection/", + [ _g( "Section:" ), + _g( "All packages in this section" ), + make_url("$subsection/",''), $subsection ], ); - my $title .= sprintf( _( "Source Package: %s (%s)" ), - $pkg, $v_str ); + my $title .= sprintf( _g( "Source Package: %s (%s)" ), + $pkg, $version ); $title .= " ".marker( $archive ) if $archive ne 'us'; $title .= " ".marker( $subsection ) if $subsection eq 'non-US' and $archive ne 'non-US'; # non-US/security @@ -320,20 +324,20 @@ sub do_show { $package_page .= title( $title ); if ($suite eq "experimental") { - note( _( "Experimental package"), - _( "Warning: This package is from the experimental distribution. That means it is likely unstable or buggy, and it may even cause data loss. If you ignore this warning and install it nevertheless, you do it on your own risk.")."

" + note( _g( "Experimental package"), + _g( "Warning: This package is from the experimental distribution. That means it is likely unstable or buggy, and it may even cause data loss. If you ignore this warning and install it nevertheless, you do it on your own risk.")."

" ); } if ($subsection eq "debian-installer") { - note( _( "debian-installer udeb package"), - _( 'Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.' ) + note( _g( "debian-installer udeb package"), + _g( 'Warning: This package is intended for the use in building debian-installer images only. Do not install it on a normal Debian system.' ) ); } my $binaries = find_binaries( $pkg, $archive, $suite, \%src2bin ); if ($binaries && @$binaries) { $package_page .= '
'; - $package_page .= _( "The following binary packages are built from this source package:" ); + $package_page .= _g( "The following binary packages are built from this source package:" ); $package_page .= pkg_list( \%packages, $opts, $binaries, 'en' ); $package_page .= '
'; } @@ -351,14 +355,10 @@ sub do_show { if ( $dep_list ) { $package_page .= "
\n"; - $package_page .= sprintf( "

"._( "Other Packages Related to %s" )."

\n", $pkg ); - if ($suite eq "experimental") { - note( sprintf( _( 'Note that the experimental distribution is not self-contained; missing dependencies are likely found in the unstable distribution.' ), "$ROOT/unstable/" ) ); - - } + $package_page .= sprintf( "

"._g( "Other Packages Related to %s" )."

\n", $pkg ); - $package_page .= pdeplegend( [ 'adep', _( 'build-depends' ) ], - [ 'idep', _( 'build-depends-indep' ) ], + $package_page .= pdeplegend( [ 'adep', _g( 'build-depends' ) ], + [ 'idep', _g( 'build-depends-indep' ) ], ); $package_page .= $dep_list; @@ -369,22 +369,22 @@ sub do_show { # Source package download # $package_page .= "
\n"; - $package_page .= sprintf( "

"._( "Download %s" )."

\n", + $package_page .= sprintf( "

"._g( "Download %s" )."

\n", $pkg ) ; my $source_files = $page->get_src( 'files' ); my $source_dir = $page->get_src( 'directory' ); - $package_page .= sprintf( ''. + $package_page .= sprintf( '
'. "", - _("File"), - _("Size (in kB)"), - _("md5sum") ); + _g("File"), + _g("Size (in kB)"), + _g("md5sum") ); foreach( @$source_files ) { my ($src_file_md5, $src_file_size, $src_file_name) = split /\s+/, $_; my $src_url; - for ($archive) { + for ("$suite/$archive") { /security/o && do { $src_url = $FTP_SITES{security}; last }; /volatile/o && do { @@ -421,14 +421,14 @@ sub do_show { } # use Data::Dumper; -# debug( "Final page object:\n".Dumper($page), 3 ); +# debug( "Final page object:\n".Dumper($page), 3 ) if DEBUG; my $title = $opts->{source} ? - _( "Details of source package %s in %s" ) : - _( "Details of package %s in %s" ) ; + _g( "Details of source package %s in %s" ) : + _g( "Details of package %s in %s" ) ; my $title_tag = $opts->{source} ? - _( "Details of source package %s in %s" ) : - _( "Details of package %s in %s" ) ; + _g( "Details of source package %s in %s" ) : + _g( "Details of package %s in %s" ) ; %$html_header = ( title => sprintf( $title, $pkg, $suite ) , lang => $opts->{lang}, desc => $short_desc,
%s%s%s