X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=cgi-bin%2Fshow_package.pl;h=53d0f7be63c670c56bc15a8135d00cfeae20ba4b;hp=260d5cee36d9535459989bb0b49768c1f6c84929;hb=5ca21f1ba07a6b559395bec8d6bc1e528eb238d1;hpb=1a910dd8949a5a4ce3c93fa581a1f70fe5675997;ds=sidebyside
diff --git a/cgi-bin/show_package.pl b/cgi-bin/show_package.pl
index 260d5ce..53d0f7b 100755
--- a/cgi-bin/show_package.pl
+++ b/cgi-bin/show_package.pl
@@ -21,452 +21,368 @@ 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::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 ();
+&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);
-$Packages::Search::debug = 1 if $debug > 1;
+$debug = 0 if !defined($debug) || $debug !~ /^\d+$/o;
+$Packages::CGI::debug = $debug;
-# If you want, just print out a list of all of the variables and exit.
-print $input->header if $debug;
-# print $input->dump;
-# exit;
+# read the configuration
+our $db_read_time ||= 0;
+
+&Packages::Config::init( '../' );
+
+if (my $path = $input->param('path')) {
+ my @components = map { lc $_ } split /\//, $path;
+
+ 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', $_);
+ }
+ }
+}
-my %params_def = ( package => { default => undef, match => '^([a-z0-9.+-]+)$' },
- suite => { default => undef, match => '^(\w+)$' },
- #format => { default => 'html', match => '^(\w+)$' }
+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)] } },
+ 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 }
);
-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;
-}
-my $package = $params{values}{package}{final};
-my $suite = $params{values}{suite}{final};
-
-# for output
-if ($format eq 'html') {
-print Packages::HTML::header( title => "Details of package $package in $suite" ,
- lang => 'en',
- title_tag => "Details of package $package in $suite",
- print_title_above => 1
- );
-}
-
-# 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;
+ fatal_error( "suite not valid or not specified" );
+ $suite = '';
}
-while ( \n/go;
- $long_desc =~ s/(((\n|\A) [^\n]*)+)/\n
";
-if (not exists $allsuites{$suite}) {
- print "Package not available in this suite";
- exit;
-}
-for my $entry (@results) {
- print join ":", @$entry;
- print "
\n";
- my ($foo, $arch, $section, $subsection,
- $priority, $version) = @$entry;
- print "".$packages_all{"$package $arch $version"}."
";
-}
+ read_entry_all( \%packages, $pkg, \@results, \@non_results, \%opts );
-&showpackage($package);
+ 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, $arch, $section, $subsection,
+ $priority, $version) = @$entry;
+
+ my $data = $packages_all{"$pkg $arch $version"};
+ $page->merge_data($pkg, $version, $arch, $data) or debug( "Merging $pkg $arch $version FAILED", 2 );
+ }
-sub showpackage {
- my ( $pkg ) = @_;
-
- my $name = $pkg->get_name;
-
- if ( $pkg->is_virtual ) {
- print_virt_pack( @_ );
- return;
- }
-
- my @all_archs = ( @{$env->{archs}}, 'all' );
-
- my $page = new Packages::Page( $name,
- { architectures => $env->{archs} } );
- my $d = $page->set_data( $env->{db}, $pkg );
-
- my %versions = $pkg->get_arch_versions( $env->{archs} );
- my %subsuites = $pkg->get_arch_fields( 'subdistribution',
- $env->{archs} );
- my %filenames = $pkg->get_arch_fields( 'filename',
- $env->{archs} );
- my %file_md5s = $pkg->get_arch_fields( 'md5sum',
- $env->{archs} );
-
- my $subsuite_kw = $d->{subsuite} || $env->{distribution};
- my $size_kw = exists $d->{sizes_deb}{i386} ? $d->{sizes_deb}{i386} : first_val($d->{sizes_deb});
-
-
- foreach my $lang (@{$env->{langs}}) {
- &Generated::Strings::string_lang($lang);
-
- my $dirname = "$env->{dest_dir}/$d->{subsection}";
- my $filename = "$dirname/$name.$lang.html";
-
- unless (( $lang eq 'en' )
- || $env->{db}->is_translated( $name, $d->{version},
- ${$versions{v2a}{$d->{version}}}[0],
- $lang )) {
- $files->delete_file( $filename )
- if $files->file_exists( $filename );
- next;
- }
- progress() if $env->{opts}{progress};
-
- #
- # process description
- #
- my $short_desc = encode_entities( $env->{db}->get_short_desc( $d->{desc_md5},
- $lang ), "<>&\"" );
- my $long_desc = encode_entities( $env->{db}->get_long_desc( $d->{desc_md5},
- $lang ), "<>&\"" );
-
- $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$1\n<\/pre>/sgo;
-
- $long_desc = conv_desc( $lang, $long_desc );
- $short_desc = conv_desc( $lang, $short_desc );
-
- #
- # begin output
- #
- my $package_page = header( title => $name, lang => $lang,
- desc => $short_desc,
- keywords => "$env->{distribution}, $subsuite_kw, $d->{section}, $d->{subsection}, size:$size_kw $d->{version}" );
- $package_page .= simple_menu( [ gettext( "Distribution:" ),
- gettext( "Overview over this distribution" ),
- "../",
- $env->{distribution} ],
- [ gettext( "Section:" ),
- gettext( "All packages in this section" ),
- "../$d->{subsection}/",
- $d->{subsection} ],
- );
-
- my $title .= sprintf( gettext( "Package: %s (%s)" ), $name, $d->{v_str_simple} );
- $title .= " ".marker( $d->{subsuite} ) if $d->{subsuite};
- $title .= " ".marker( $d->{section} ) if $d->{section} ne 'main';
- $package_page .= title( $title );
-
- $package_page .= "
".gettext( "Versions:" )." $d->{v_str_arch}
\n"
- unless $d->{version} eq $d->{v_str_simple};
-
- if ($env->{distribution} 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 ($d->{section} eq "debian-installer") { - $package_page .= 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 = print_deps( $env, $lang, $pkg, $d->{depends}, 'depends' ); - $dep_list .= print_deps( $env, $lang, $pkg, $d->{recommends}, 'recommends' ); - $dep_list .= print_deps( $env, $lang, $pkg, $d->{suggests}, 'suggests' ); - - if ( $dep_list ) { - $package_page .= "
\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)$/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 .= '
'; + + $package_page .= simple_menu( [ gettext( "Distribution:" ), + gettext( "Overview over this suite" ), + "/$suite/", + $suite ], + [ gettext( "Section:" ), + gettext( "All packages in this section" ), + "/$suite/$subsection/", + $subsection ], + ); + + my $title .= sprintf( gettext( "Package: %s (%s)" ), $pkg, $v_str ); + $title .= " ".marker( $archive ) if $archive ne 'us'; + $title .= " ".marker( $section ) if $section ne 'main'; + $package_page .= title( $title ); - $package_page .= pdeplegend( [ 'dep', gettext( 'depends' ) ], - [ 'rec', gettext( 'recommends' ) ], - [ 'sug', gettext( 'suggests' ) ], ); + $package_page .= "".gettext( "Versions:" )." $v_str_arch
\n" + unless $version eq $v_str; - $package_page .= $dep_list; - $package_page .= "
".gettext("Architecture")." | ".gettext("Files")." | ".gettext( "Package Size")." | ".gettext("Installed Size")." | ||||
---|---|---|---|---|---|---|---|
".gettext("Architecture")." | ".gettext("Files")." | ".gettext( "Package Size")." | ".gettext("Installed Size")." |
---|---|---|---|
\n "; - $package_page .= "&file=".uri_escape($filenames{a2f}->{$a}); - $package_page .= "&md5sum=$file_md5s{a2f}->{$a}"; + $package_page .= "&file=".uri_escape($filenames->{$a}); + $package_page .= "&md5sum=$file_md5sums->{$a}"; $package_page .= "&arch=$a"; # there was at least one package with two # different source packages on different # archs where one had a security update # and the other one not - if ($subsuites{a2f}{$a} - && ($subsuites{a2f}{$a} =~ /security/o) ) { - $package_page .= "&type=security"; - } elsif ($subsuites{a2f}{$a} - && ($subsuites{a2f}{$a} =~ /volatile/o) ) { - $package_page .= "&type=volatile"; - } elsif ($d->{is_nonus}) { - $package_page .= "&type=nonus"; - } else { + for ($archives->{$a}) { + /security/o && do { + $package_page .= "&type=security"; last }; + /volatile/o && do { + $package_page .= "&type=volatile"; last }; + /non-us/io && do { + $package_page .= "&type=nonus"; last }; $package_page .= "&type=main"; } $package_page .= "\">$a | \n";
$package_page .= ""; - if ( $env->{distribution} ne "experimental" ) { - $package_page .= sprintf( "[".gettext( "list of files" )."]\n", "$FILELIST_URL$encodedpack&version=$env->{distribution}&arch=$a", $name ); + if ( $suite ne "experimental" ) { + $package_page .= sprintf( "[".gettext( "list of files" )."]\n", "$FILELIST_URL$encodedpkg&version=$suite&arch=$a", $pkg ); } else { - $package_page .= "no files"; + $package_page .= gettext( "no current information" ); } $package_page .= " | \n"; - my $size = $d->{sizes_deb}{$a}; - $package_page .= "$size"; + $package_page .= floor(($sizes_deb->{$a}/102.4)+0.5)/10; $package_page .= " | \n"; - my $inst_size = $d->{sizes_inst}{$a}; - $package_page .= "$inst_size"; + $package_page .= $sizes_inst->{$a}; $package_page .= " | \n
".gettext ( "Size is measured in kBytes." )."
\n"; - $package_page .= "".gettext ( "Size is measured in kBytes." )."
\n"; + $package_page .= "