X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;ds=inline;f=cgi-bin%2Fshow_package.pl;h=747db62ada96ee2b29bd87695a7b2255c19befd3;hb=2c68295edf18a88ff0e5437c6f7f9a67438fd65a;hp=bf84db04daae50da1a88e4cf018ec51165069fe4;hpb=4b7eb61d370a284dbfdf1de607c28b8c65a4bbde;p=deb%2Fpackages.git
diff --git a/cgi-bin/show_package.pl b/cgi-bin/show_package.pl
index bf84db0..747db62 100755
--- a/cgi-bin/show_package.pl
+++ b/cgi-bin/show_package.pl
@@ -13,6 +13,7 @@
# see http://www.fsf.org/copyleft/gpl.html for a copy of the license
use strict;
+use lib '../lib';
use CGI qw( -oldstyle_urls );
use CGI::Carp qw( fatalsToBrowser );
use POSIX;
@@ -21,171 +22,511 @@ use HTML::Entities;
use DB_File;
use Benchmark;
-use lib "../lib";
-
use Deb::Versions;
+use Packages::Config qw( $DBDIR $ROOT @SUITES @ARCHIVES @SECTIONS
+ @ARCHITECTURES %FTP_SITES );
+use Packages::CGI;
+use Packages::DB;
use Packages::Search qw( :all );
-use Packages::HTML ();
-
-my $HOME = "http://www.debian.org";
-my $ROOT = "";
-my $SEARCHPAGE = "http://packages.debian.org/";
-my @SUITES = qw( oldstable stable testing unstable experimental );
-my @DISTS = @SUITES;
-my @SECTIONS = qw( main contrib non-free );
-my @ARCHIVES = qw( us security installer );
-my @ARCHITECTURES = qw( alpha amd64 arm hppa hurd-i386 i386 ia64
- kfreebsd-i386 mips mipsel powerpc s390 sparc );
-my %SUITES = map { $_ => 1 } @SUITES;
-my %SECTIONS = map { $_ => 1 } @SECTIONS;
-my %ARCHIVES = map { $_ => 1 } @ARCHIVES;
-my %ARCHITECTURES = map { $_ => 1 } @ARCHITECTURES;
+use Packages::HTML;
+use Packages::Page ();
+use Packages::SrcPage ();
+
+&Packages::CGI::reset;
$ENV{PATH} = "/bin:/usr/bin";
# Read in all the variables set by the form
my $input;
-if ($ARGV[0] eq 'php') {
+if ($ARGV[0] && ($ARGV[0] eq 'php')) {
$input = new CGI(\*STDIN);
} else {
$input = new CGI;
}
my $pet0 = new Benchmark;
+my $tet0 = new Benchmark;
# use this to disable debugging in production mode completly
my $debug_allowed = 1;
my $debug = $debug_allowed && $input->param("debug");
-$debug = 0 if not defined($debug);
-$Search::Param::debug = 1 if $debug > 1;
+$debug = 0 if !defined($debug) || $debug !~ /^\d+$/o;
+$Packages::CGI::debug = $debug;
+
+&Packages::Config::init( '../' );
+&Packages::DB::init();
-# If you want, just print out a list of all of the variables and exit.
-print $input->header if $debug;
-# print $input->dump;
-# exit;
+if (my $path = $input->param('path')) {
+ my @components = map { lc $_ } split /\//, $path;
-my %params_def = ( package => { default => undef, match => '^([a-z0-9.+-]+)$' },
- suite => { default => undef, match => '^(\w+)$' },
- #format => { default => 'html', match => '^(\w+)$' }
+ my %SUITES = map { $_ => 1 } @SUITES;
+ my %SECTIONS = map { $_ => 1 } @SECTIONS;
+ my %ARCHIVES = map { $_ => 1 } @ARCHIVES;
+ my %ARCHITECTURES = map { $_ => 1 } @ARCHITECTURES;
+
+ foreach (@components) {
+ if ($SUITES{$_}) {
+ $input->param('suite', $_);
+ } elsif ($SECTIONS{$_}) {
+ $input->param('section', $_);
+ } elsif ($ARCHIVES{$_}) {
+ $input->param('archive', $_);
+ } elsif ($ARCHITECTURES{$_}) {
+ $input->param('arch', $_);
+ } elsif ($_ eq 'source') {
+ $input->param('source', 1);
+ }
+ }
+}
+
+my ( $pkg, $suite, @sections, @archs, @archives, $format );
+my %params_def = ( package => { default => undef, match => '^([a-z0-9.+-]+)$',
+ var => \$pkg },
+ suite => { default => undef, match => '^(\w+)$',
+ var => \$suite },
+ archive => { default => 'all', match => '^(\w+)$',
+ array => ',', var => \@archives,
+ replace => { all => [qw(us security non-US)] } },
+ section => { default => 'all', match => '^(\w+)$',
+ array => ',', var => \@sections,
+ replace => { all => \@SECTIONS } },
+ arch => { default => 'any', match => '^(\w+)$',
+ array => ',', var => \@archs,
+ replace => { any => \@ARCHITECTURES } },
+ format => { default => 'html', match => '^(\w+)$',
+ var => \$format },
+ source => { default => 0, match => '^(\d+)$' },
);
-my %params = Packages::Search::parse_params( $input, \%params_def );
+my %opts;
+my %params = Packages::Search::parse_params( $input, \%params_def, \%opts );
-my $format = $params{values}{format}{final};
#XXX: Don't use alternative output formats yet
$format = 'html';
-
if ($format eq 'html') {
print $input->header;
-} elsif ($format eq 'xml') {
-# print $input->header( -type=>'application/rdf+xml' );
- print $input->header( -type=>'text/plain' );
}
if ($params{errors}{package}) {
- print "Error: package not valid or not specified" if $format eq 'html';
- exit 0;
+ fatal_error( "package not valid or not specified" );
+ $pkg = '';
}
if ($params{errors}{suite}) {
- print "Error: package not valid or not specified" if $format eq 'html';
- exit 0;
+ fatal_error( "suite not valid or not specified" );
+ $suite = '';
}
-my $package = $params{values}{package}{final};
-my $suite = $params{values}{suite}{final};
-# for output
-if ($format eq 'html') {
-print Packages::HTML::header( title => 'Package Details' ,
- lang => 'en',
- title_tag => 'Package Details',
- print_title_above => 1
- );
-}
+$opts{h_suites} = { $suite => 1 };
+$opts{h_archs} = { map { $_ => 1 } @archs };
+$opts{h_sections} = { map { $_ => 1 } @sections };
+$opts{h_archives} = { map { $_ => 1 } @archives };;
-# read the configuration
-my $topdir;
-if (!open (C, "../config.sh")) {
- print "\nInternal Error: Cannot open configuration file.\n\n"
-if $format eq 'html';
- exit 0;
-}
-while ( \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 );
+
+ 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"}++;
+ }
+ }
+ foreach (suites_sort(keys %all_suites)) {
+ if (("$suite/$archive" eq $_)
+ || (!$all_suites{"$suite/$archive"} && ($suite eq $_))) {
+ $package_page .= "[ $_ ] ";
+ } else {
+ $package_page .=
+ "[ $_ ] ";
+ }
+ }
+ $package_page .= '
';
-# sort is gross -- only fails for experimental though
-for (sort keys %allsuites) {
- if ($suite eq $_) {
- print "$_ | ";
+ $package_page .= simple_menu( [ gettext( "Distribution:" ),
+ gettext( "Overview over this suite" ),
+ "$ROOT/$suite/",
+ $suite ],
+ [ gettext( "Section:" ),
+ gettext( "All packages in this section" ),
+ "$ROOT/$suite/$subsection/",
+ $subsection ],
+ );
+
+ my $title .= sprintf( gettext( "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 .= "".gettext( "Versions:" )." $v_str_arch
\n"
+ unless $version eq $v_str;
+
+ if ($suite eq "experimental") {
+ $package_page .= note( gettext( "Experimental package"),
+ gettext( "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.")."
". + gettext( "Users of experimental packages are encouraged to contact the package maintainers directly in case of problems." ) + ); + } + if ($subsection eq "debian-installer") { + note( gettext( "debian-installer udeb package"), + gettext( "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 ); + + # + # display dependencies + # + my $dep_list; + $dep_list = print_deps( \%packages, \%opts, $pkg, + $page->get_dep_field('depends'), + 'depends' ); + $dep_list .= print_deps( \%packages, \%opts, $pkg, + $page->get_dep_field('recommends'), + 'recommends' ); + $dep_list .= print_deps( \%packages, \%opts, $pkg, + $page->get_dep_field('suggests'), + 'suggests' ); + + if ( $dep_list ) { + $package_page .= "
".gettext("Architecture")." | ".gettext("Files")." | ".gettext( "Package Size")." | ".gettext("Installed Size")." |
---|---|---|---|
$a | \n"; + $package_page .= ""; + if ( $suite ne "experimental" ) { + $package_page .= sprintf( "[".gettext( "list of files" )."]\n", + "$ROOT/$suite/$encodedpkg/$a/filelist", $pkg ); + } else { + $package_page .= gettext( "no current information" ); + } + $package_page .= " | \n"; #FIXME: css + $package_page .= floor(($sizes_deb->{$a}/102.4)+0.5)/10 . " kB"; + $package_page .= " | \n"; #FIXME: css + $package_page .= $sizes_inst->{$a} . " kB"; + $package_page .= " | \n
".$packages_all{"$package $arch $version"}.""; -} + unless (@results || @non_results ) { + fatal_error( "No such package". + "{insert link to search page with substring search}" ); + } else { + unless (@results) { + fatal_error( "Package not available in this suite" ); + } else { + for my $entry (@results) { + debug( join(":", @$entry), 1 ); + my (undef, $archive, undef, $section, $subsection, + $priority, $version) = @$entry; + + my $data = $sources_all{"$pkg $version"}; + $page->merge_data($pkg, $version, $data) or debug( "Merging $pkg $version FAILED", 2 ); + } + $version = $page->{version}; + + my $st1 = new Benchmark; + my $std = timediff($st1, $st0); + debug( "Data search and merging took ".timestr($std) ); + + my $encodedpkg = uri_escape( $pkg ); + 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' ); + 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"}++; + } + } + foreach (suites_sort(keys %all_suites)) { + if (("$suite/$archive" eq $_) + || (!$all_suites{"$suite/$archive"} && ($suite eq $_))) { + $package_page .= "[ $_ ] "; + } else { + $package_page .= + "[ $_ ] "; + } + } + $package_page .= '
". + gettext( "Users of experimental packages are encouraged to contact the package maintainers directly in case of problems." ) + ); + } + if ($subsection eq "debian-installer") { + note( gettext( "debian-installer udeb package"), + gettext( "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 .= '
%s | %s | %s | ", + gettext("File"), + gettext("Size (in kB)"), + gettext("md5sum") ); + foreach( @$source_files ) { + my ($src_file_md5, $src_file_size, $src_file_name) = @$_; + my $src_url; + for ($archive) { + /security/o && do { + $src_url = $FTP_SITES{security}; last }; + /volatile/o && do { + $src_url = $FTP_SITES{volatile}; last }; + /backports/o && do { + $src_url = $FTP_SITES{backports}; last }; + /non-us/io && do { + $src_url = $FTP_SITES{'non-US'}; last }; + $src_url = $FTP_SITES{us}; + } + $src_url .= "/$source_dir/$src_file_name"; + + $package_page .= "
---|---|---|
$src_file_name | \n" + ."".sprintf("%.1f", (floor(($src_file_size/102.4)+0.5)/10))." | \n" + ."$src_file_md5 |