From 2ec757bb58907b15c43548be5601d4f2b8c7caac Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Tue, 21 Nov 2006 23:46:55 +0000 Subject: [PATCH] The Big, the Fat and the Ugly commit ;) - Make output via Template Toolkit (libtemplate-perl) and not "manual". This should seperate the logic of data retrieval and data display and make adding new output formats and styles easier. Lets see how this turns out :) - While doing this I also reworked most of the site designs and added a lot of new information and hopefully structure to the output Currently broken: - Most of the l10n stuff since I need to find a good way to feed the templates to gettext first. (this is not "RC" for an use on p.d.o) - RSS feed of new packages. Didn't came around yet to convert this one. (this one is "RC") - probably a lot of minor things --- bin/create_index_pages | 311 +++++++------- bin/newpkg_info | 19 +- cgi-bin/dispatcher.pl | 71 ++-- config.sh.sed.in | 9 +- cron.d/050checkinst | 24 +- lib/Packages/CGI.pm | 81 ++-- lib/Packages/Config.pm | 38 +- lib/Packages/DoDownload.pm | 334 ++------------- lib/Packages/DoFilelist.pm | 22 +- lib/Packages/DoIndex.pm | 20 +- lib/Packages/DoNewPkg.pm | 144 +++---- lib/Packages/DoSearch.pm | 223 +++++----- lib/Packages/DoSearchContents.pm | 137 ++----- lib/Packages/DoShow.pm | 482 +++++++++++----------- lib/Packages/HTML.pm | 593 --------------------------- lib/Packages/Template.pm | 121 ++++++ static/packages.css.sed.in | 205 +++++++-- templates/config.tmpl | 39 ++ templates/config/architectures.tmpl | 21 + templates/config/archive_layout.tmpl | 5 + templates/config/mirrors.tmpl | 210 ++++++++++ templates/html/download.tmpl | 99 +++++ templates/html/error.tmpl | 4 + templates/html/filelist.tmpl | 17 + templates/html/foot.tmpl | 37 ++ templates/html/head.tmpl | 72 ++++ templates/html/index.tmpl | 41 ++ templates/html/menu.inc | 10 + templates/html/messages.tmpl | 31 ++ templates/html/newpkg.tmpl | 31 ++ templates/html/search.tmpl | 51 +++ templates/html/search_contents.tmpl | 123 ++++++ templates/html/show.tmpl | 246 +++++++++++ templates/html/suite_index.tmpl | 28 ++ templates/txt/index.tmpl | 20 + 35 files changed, 2140 insertions(+), 1779 deletions(-) delete mode 100644 lib/Packages/HTML.pm create mode 100644 lib/Packages/Template.pm create mode 100644 templates/config.tmpl create mode 100644 templates/config/architectures.tmpl create mode 100644 templates/config/archive_layout.tmpl create mode 100644 templates/config/mirrors.tmpl create mode 100644 templates/html/download.tmpl create mode 100644 templates/html/error.tmpl create mode 100644 templates/html/filelist.tmpl create mode 100644 templates/html/foot.tmpl create mode 100644 templates/html/head.tmpl create mode 100644 templates/html/index.tmpl create mode 100644 templates/html/menu.inc create mode 100644 templates/html/messages.tmpl create mode 100644 templates/html/newpkg.tmpl create mode 100644 templates/html/search.tmpl create mode 100644 templates/html/search_contents.tmpl create mode 100644 templates/html/show.tmpl create mode 100644 templates/html/suite_index.tmpl create mode 100644 templates/txt/index.tmpl diff --git a/bin/create_index_pages b/bin/create_index_pages index 2d6e472..69b60a2 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -8,15 +8,17 @@ use File::Path; use DB_File; use Storable; use HTML::Entities; +use URI::Escape; use Locale::gettext; use Compress::Zlib; use lib './lib'; use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES $LOCALES); -use Packages::HTML; +use Packages::Template; use Packages::I18N::Locale; use Packages::Page; +use Packages::SrcPage; use Packages::Sections; &Packages::Config::init( './' ); @@ -33,6 +35,12 @@ my $wwwdir = "$TOPDIR/www"; tie my %packages, 'DB_File', "$DBDIR/packages_small.db", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie DB $DBDIR/packages_small.db: $!"; +tie my %src_packages, 'DB_File', "$DBDIR/sources_small.db", + O_RDONLY, 0666, $DB_BTREE + or die "couldn't tie DB $DBDIR/sources_small.db: $!"; +tie my %src2bin, 'DB_File', "$DBDIR/sources_packages.db", + O_RDONLY, 0666, $DB_BTREE + or die "couldn't open $DBDIR/sources_packages.db: $!"; my $sections = retrieve "$DBDIR/sections.info"; my $subsections = retrieve "$DBDIR/subsections.info"; @@ -45,42 +53,45 @@ my $priorities = retrieve "$DBDIR/priorities.info"; my (%pages); +my $template = new Packages::Template( "$TOPDIR/templates", 'html', {} ); + print "write suite index files ...\n"; foreach my $s (@SUITES) { my $key = $s; mkpath ( "$wwwdir/$key" ); foreach my $lang (@LANGUAGES) { my $locale = get_locale( $lang ); + my $charset = get_locale( $lang ); setlocale ( LC_ALL, $locale ) or do { warn "couldn't set locale ($lang/$locale)\n"; next; }; + print "writing $key/index (lang=$lang)...\n"; open $pages{$key}{$lang}{index}{fh}, '>', "$wwwdir/$key/index.$lang.html.new" or die "can't open index file for output: $!"; - my $index_title = sprintf( _g( "List of sections in \"%s\"" ), - $key ); - print {$pages{$key}{$lang}{index}{fh}} header( title => $index_title, - title_keywords => "debian, $s", - desc => encode_entities( $index_title, '"' ), - lang => $lang ), - title( $index_title ), '
'; - my $i = 0; my $num_sections = keys %{$subsections->{$s}}; + + my %content = ( subsections => [], suite => $s, + lang => $lang, charset => $charset ); + $content{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) }; + $content{make_url} = sub { return &Packages::CGI::make_url(@_) }; + # needed to work around the limitations of the the FILTER syntax + $content{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') }; + $content{uri_escape} = sub { return URI::Escape::uri_escape(@_) }; + $content{quotemeta} = sub { return quotemeta($_[0]) }; + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { next if $ssec eq '-'; if ($sections_descs{$ssec}) { - print {$pages{$key}{$lang}{index}{fh}} "
".dgettext( 'sections', $sections_descs{$ssec}[0] )."
".dgettext( 'sections', $sections_descs{$ssec}[1] )."
\n"; - $i++; - if ($i eq ceil($num_sections/2)) { - print {$pages{$key}{$lang}{index}{fh}} "
\n
\n
\n
\n"; - } + push @{$content{subsections}}, { + id => $ssec, + name => dgettext( 'sections', $sections_descs{$ssec}[0] ), + desc => dgettext( 'sections', $sections_descs{$ssec}[1] ), + }; } } - print {$pages{$key}{$lang}{index}{fh}} '
', - "

". - _g( "All packages" ) ."
(". - _g( "compact compressed textlist" ).")

\n"; - print {$pages{$key}{$lang}{index}{fh}} trailer( "../", 'index', $lang, @LANGUAGES ); + print {$pages{$key}{$lang}{index}{fh}} $template->page( 'suite_index', \%content ); + print {$pages{$key}{$lang}{index}{fh}} $template->trailer( 'index', $lang, \@LANGUAGES ); close $pages{$key}{$lang}{index}{fh} or warn "can't close index file $wwwdir/$key/index.$lang.html.new: $!"; rename( "$wwwdir/$key/index.$lang.html.new", @@ -90,70 +101,8 @@ foreach my $s (@SUITES) { } setlocale( LC_ALL, 'C' ) or die "couldn't reset locale"; -print "opening files ...\n"; -foreach my $s (@SUITES) { - my $key = $s; - mkpath ( "$wwwdir/$key" ); - open $pages{$key}{fh}, '>', "$wwwdir/$key/allpackages.en.html.new" - or die "can't open index file for output: $!"; - $pages{$key}{textgz} = gzopen("$wwwdir/$key/allpackages.en.txt.gz.new", - 'wb9') - or die "can't open text index file for output: $!"; - - my $title = sprintf( _g( "Software Packages in \"%s\"" ), - $key ); - print {$pages{$key}{fh}} header( title => $title, - title_keywords => "debian, $s", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - my $title_txt = sprintf( _g( "All Debian Packages in \"%s\"" ), - $key )."\n\n"; - $title_txt .= _g( "Last Modified: " ).gmtime()."\n". - sprintf(_g( "Copyright (C) 1997-%d SPI;\nSee for the license terms."), (gmtime)[5]+1900 )."\n\n"; - $pages{$key}{textgz}->gzwrite($title_txt); - - foreach my $sec (keys %{$sections->{$s}}) { - mkpath ( "$wwwdir/$key/$sec" ); - open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( _g( "Software Packages in \"%s\", section %s" ), - $key, $sec ); - print {$pages{$key}{$sec}{fh}} header( title => $title, - title_keywords => "debian, $s, $sec", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - } - foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { - next if $ssec eq '-'; - mkpath ( "$wwwdir/$key/$ssec" ); - open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( _g( "Software Packages in \"%s\", subsection %s" ), - $key, $ssec ); - print {$pages{$key}{$ssec}{fh}} header( title => $title, - title_keywords => "debian, $s, $ssec", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - } - foreach my $prio (keys %{$priorities->{$s}}) { - next if $prio eq '-'; - mkpath ( "$wwwdir/$key/$prio" ); - open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( _g( "Software Packages in \"%s\", priority %s" ), - $key, $prio ); - print {$pages{$key}{$prio}{fh}} header( title => $title, - title_keywords => "debian, $s, $prio", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - } -} - -print "writing package info ...\n"; +print "collecting package info ...\n"; +my %allpkgs; while (my ($pkg, $data) = each %packages) { my (%pkg,%virt); my ($virt, $p_data) = split /\000/o, $data, 2; @@ -176,87 +125,135 @@ while (my ($pkg, $data) = each %packages) { $pkg{$_} ||= new Packages::Page( $pkg ); $pkg{$_}->add_provided_by([split /\s+/, $virt{$_}]); } - + while (my ($key, $entry) = each %pkg) { + $allpkgs{$key} ||= []; + + my %p = ( name => $pkg, providers => [], versions => '' ); if (my $provided_by = $entry->{provided_by}) { - my $str = "
$pkg ". - "
\n
virtual package provided by ". - join( ', ',map { "$_" } @$provided_by)."
\n"; - my $txt_str = "$pkg\tvirtual package provided by ".join(', ', @$provided_by)."\n"; - print {$pages{$key}{virtual}{fh}} $str - or die "couldn't write to output file: $!"; - } - next if $entry->is_virtual; - my (undef, $v_str) = $entry->get_version_string; - my $subsection = $entry->get_newest( 'subsection' ); - my $section = $entry->get_newest( 'section' ); - my $archive = $entry->get_newest( 'archive' ); - my $short_desc_txt = $entry->get_newest( 'description' ); - my $short_desc = encode_entities( $short_desc_txt, "<>&\"" ); - my $priority = $entry->get_newest( 'priority' ); - - my $str = "
$pkg ($v_str) "; - my $txt_str = "$pkg ($v_str)"; - if ($section ne 'main') { - $str .= marker( $section ); - $txt_str .= " [$section]"; - } - if ($archive ne 'us') { - $str .= marker( $archive ); - $txt_str .= " [$archive]"; - } - $str .= "
\n
$short_desc
\n"; - $txt_str .= " $short_desc_txt\n"; - print {$pages{$key}{fh}} $str - or die "couldn't write to output file: $!"; - $pages{$key}{textgz}->gzwrite($txt_str) - or die "couldn't write to output file: ".$pages{$key}{textgz}->gzerror; - print {$pages{$key}{$section}{fh}} $str - or die "couldn't write to output file: $!"; - if ($subsection ne '-') { - print {$pages{$key}{$subsection}{fh}} $str - or die "couldn't write to output file: $!"; - } - if ($priority ne '-') { - print {$pages{$key}{$priority}{fh}} $str - or die "couldn't write to output file: $!"; + $p{providers} = $provided_by; + } + $p{subsection} = $p{section} = $p{archive} = $p{desc} = $p{priority} = ''; + unless ($entry->is_virtual) { + (undef, $p{versions}) = $entry->get_version_string; + $p{subsection} = $entry->get_newest( 'subsection' ); + $p{section} = $entry->get_newest( 'section' ); + $p{archive} = $entry->get_newest( 'archive' ); + $p{desc} = $entry->get_newest( 'description' ); + $p{priority} = $entry->get_newest( 'priority' ); } + push @{$allpkgs{$key}}, \%p; } } -print "closing files ...\n"; -foreach my $s (@SUITES) { - my $key = $s; - print {$pages{$key}{fh}} '
', trailer( "../" ); - ($pages{$key}{textgz}->gzclose == Z_OK) or - warn "can't close text index file $wwwdir/$key/allpackages.en.txt.gz.new: ".$pages{$key}{textgz}->gzerror; - close $pages{$key}{fh} or - warn "can't close index file $wwwdir/$key/allpackages.en.html.new: $!"; - rename( "$wwwdir/$key/allpackages.en.html.new", - "$wwwdir/$key/allpackages.en.html" ); - rename( "$wwwdir/$key/allpackages.en.txt.gz.new", - "$wwwdir/$key/allpackages.en.txt.gz" ); - foreach my $sec (keys %{$sections->{$s}{'us'}}) { - print {$pages{$key}{$sec}{fh}} '
', trailer( "../../" ); - close $pages{$key}{$sec}{fh} or - warn "can't close index file $wwwdir/$key/$sec/index.en.html.new: $!"; - rename( "$wwwdir/$key/$sec/index.en.html.new", - "$wwwdir/$key/$sec/index.en.html" ); +write_files(\%allpkgs); + +print "collecting source package info ...\n"; +my %allsrcpkgs; +while (my ($pkg, $data) = each %src_packages) { + my %pkg; + foreach (split /\000/o, $data||'') { + my @data = split ( /\s/o, $_ ); + $pkg{$data[1]} ||= new Packages::SrcPage( $pkg ); + $pkg{$data[1]}->merge_package( { package => $pkg, + archive => $data[0], + suite => $data[1], + section => $data[2], + subsection => $data[3], + priority => $data[4], + version => $data[5], + } ); + } + + while (my ($key, $entry) = each %pkg) { + $allsrcpkgs{$key} ||= []; + + my %p = ( name => $pkg, providers => [], versions => '' ); + $p{versions} = $entry->{version}; + $p{subsection} = $entry->get_newest( 'subsection' ); + $p{section} = $entry->get_newest( 'section' ); + $p{archive} = $entry->get_newest( 'archive' ); + $p{priority} = $entry->get_newest( 'priority' ); + + $p{desc} = ''; + $p{binaries} = []; +# my $binaries = find_binaries( $pkg, $p{archive}, $p{suite}, \%src2bin ); +# if ($binaries && @$binaries) { +# pkg_list( \%packages, $opts, $binaries, 'en', $contents{binaries} ); +# } + + push @{$allsrcpkgs{$key}}, \%p; } - foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { - next if $ssec eq '-'; - print {$pages{$key}{$ssec}{fh}} '
', trailer( "../../" ); - close $pages{$key}{$ssec}{fh} or - warn "can't close index file $wwwdir/$key/$ssec/index.en.html.new: $!"; - rename( "$wwwdir/$key/$ssec/index.en.html.new", - "$wwwdir/$key/$ssec/index.en.html" ); +} + +write_files(\%allsrcpkgs, 1); + +sub write_files { + my ($pkgs, $source) = @_; + + $source = $source ? 'source/' : ''; + print "writing files ...\n"; + foreach my $s (@SUITES) { + my $key = $s; + mkpath ( "$wwwdir/$source$key" ); + print "writing $source$s/allpackages...\n"; + $template->process( 'html/index.tmpl', { packages => $pkgs->{$key}, suite => $s, lang => 'en', is_source => $source }, + "$wwwdir/$source$key/allpackages.en.html.new" ) + or die "error writing allpackages for $key: ".$template->error(); + print "writing $source$s/allpackages (txt)...\n"; + my $gzfh = gzopen("$wwwdir/$source$key/allpackages.en.txt.gz.new", + 'wb9') + or die "can't open text index file for output: $!"; + my $gztxt; + $template->process( 'txt/index.tmpl', { packages => $pkgs->{$key}, suite => $s, lang => 'en', is_source => $source }, + \$gztxt ) + or die "error writing allpackages txt for $key: ".$template->error(); + $gzfh->gzwrite($gztxt); + ($gzfh->gzclose == Z_OK) or + warn "can't close text index file $wwwdir/$source$key/allpackages.en.txt.gz.new: ".$gzfh->gzerror; + + rename( "$wwwdir/$source$key/allpackages.en.html.new", + "$wwwdir/$source$key/allpackages.en.html" ); + rename( "$wwwdir/$source$key/allpackages.en.txt.gz.new", + "$wwwdir/$source$key/allpackages.en.txt.gz" ); + + foreach my $sec (keys %{$sections->{$s}}) { + mkpath ( "$wwwdir/$source$key/$sec" ); + + print "writing $source$s/$sec/index...\n"; + $template->process( 'html/index.tmpl', { packages => [ grep { $_->{section} eq $sec } @{$pkgs->{$key}} ], + suite => $s, lang => 'en', is_source => $source, + category => { id => 'section', name => $sec } }, + "$wwwdir/$source$key/$sec/index.en.html.new" ) + or die "error writing section index for $key/$sec: ".$template->error(); + rename( "$wwwdir/$source$key/$sec/index.en.html.new", + "$wwwdir/$source$key/$sec/index.en.html" ); } - foreach my $prio (keys %{$priorities->{$s}}) { - next if $prio eq '-'; - print {$pages{$key}{$prio}{fh}} '
', trailer( "../../" ); - close $pages{$key}{$prio}{fh} or - warn "can't close index file $wwwdir/$key/$prio/index.en.html.new: $!"; - rename( "$wwwdir/$key/$prio/index.en.html.new", - "$wwwdir/$key/$prio/index.en.html" ); + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { + next if $ssec eq '-'; + mkpath ( "$wwwdir/$source$key/$ssec" ); + + print "writing $source$s/$ssec/index...\n"; + $template->process( 'html/index.tmpl', { packages => [ grep { $_->{subsection} eq $ssec } @{$pkgs->{$key}} ], + suite => $s, lang => 'en', is_source => $source, + category => { id => 'subsection', name => $ssec } }, + "$wwwdir/$source$key/$ssec/index.en.html.new" ) + or die "error writing subsection index for $key/$ssec: ".$template->error(); + rename( "$wwwdir/$source$key/$ssec/index.en.html.new", + "$wwwdir/$source$key/$ssec/index.en.html" ); + } + foreach my $prio (keys %{$priorities->{$s}}) { + next if $prio eq '-'; + mkpath ( "$wwwdir/$source$key/$prio" ); + + print "writing $source$s/$prio/index...\n"; + $template->process( 'html/index.tmpl', { packages => [ grep { $_->{priority} eq $prio } @{$pkgs->{$key}} ], + suite => $s, lang => 'en', is_source => $source, + category => { id => 'priority', name => $prio } }, + "$wwwdir/$source$key/$prio/index.en.html.new" ) + or die "error writing priority index for $key/$prio: ".$template->error(); + rename( "$wwwdir/$source$key/$prio/index.en.html.new", + "$wwwdir/$source$key/$prio/index.en.html" ); + } } } diff --git a/bin/newpkg_info b/bin/newpkg_info index 175119a..e2f36ae 100755 --- a/bin/newpkg_info +++ b/bin/newpkg_info @@ -11,12 +11,12 @@ use Packages::Config qw( $TOPDIR $DBDIR ); use Packages::Search qw( :all ); &Packages::Config::init( './' ); -my $suite = $ARGV[0] or die "No suite given"; +my $suite = $ARGV[0] or die "Fatal Error: No suite given"; my $start_time = time; tie my %packages, 'DB_File', "$DBDIR/packages_small.db", O_RDONLY, 0666, $DB_BTREE - or die "couldn't tie DB $DBDIR/packages_small.db: $!\n"; + or die "Fatal Error: Couldn't tie DB $DBDIR/packages_small.db: $!\n"; sub get_iso_date { my ($age) = @_; @@ -28,23 +28,26 @@ sub get_iso_date { } open CHANGES, '>', "$TOPDIR/files/packages/newpkg_info.new" - or die "Couldn't open CHANGES file: $!"; + or die "Fatal Error: Couldn't open CHANGES file: $!"; for (my $age = 0; $age < 7; $age++) { my (%old, %changes); my $newday = get_iso_date( $age ); my $oldday = get_iso_date( $age+1 ); open OLD, '<', "$TOPDIR/files/packages/package_names_$suite.$oldday" or do { - warn"Couldn't open OLD file $TOPDIR/files/packages/package_names_$suite.$oldday: $!\n"; - last; + warn "Warning: Couldn't open OLD file $TOPDIR/files/packages/package_names_$suite.$oldday: $!\n"; + next; + }; + open NEW, '<', "$TOPDIR/files/packages/package_names_$suite.$newday" + or do { + warn "Warning: Couldn't open NEW file $TOPDIR/files/packages/package_names_$suite.$newday: $!\n"; + next; }; while () { chomp; $old{$_} = 1; } close OLD; - open NEW, '<', "$TOPDIR/files/packages/package_names_$suite.$newday" - or die "Couldn't open NEW file $TOPDIR/files/packages/package_names_$suite.$newday: $!\n"; while () { chomp; if ($old{$_}) { @@ -62,7 +65,7 @@ for (my $age = 0; $age < 7; $age++) { my %archives = map { $_ => 1 } qw( us security non-US ); foreach (sort keys %changes) { my $entry = read_entry_simple( \%packages, $_, \%archives, $suite) - or die "Can't find entry for package $_\n"; + or die "Fatal Error: Can't find entry for package $_\n"; shift @$entry; # remove virtual pkg info print CHANGES join(" ", $_, $age, @$entry)."\n"; print "Wrote entry: ".join(" ", $_, $age, @$entry)."\n"; diff --git a/cgi-bin/dispatcher.pl b/cgi-bin/dispatcher.pl index 04d5acb..45d1b46 100755 --- a/cgi-bin/dispatcher.pl +++ b/cgi-bin/dispatcher.pl @@ -13,19 +13,23 @@ use warnings; use lib '../lib'; use CGI; use POSIX; +use File::Basename; use URI::Escape; use HTML::Entities; +use Template; use DB_File; use Benchmark ':hireswallclock'; use I18N::AcceptLanguage; use Locale::gettext; use Deb::Versions; -use Packages::Config qw( $DBDIR $ROOT @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES @LANGUAGES $LOCALES ); -use Packages::CGI; +use Packages::Config qw( $DBDIR $ROOT $TEMPLATEDIR $CACHEDIR + @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES @PRIORITIES + @LANGUAGES $LOCALES ); +use Packages::CGI qw( :DEFAULT get_all_messages ); use Packages::DB; use Packages::Search qw( :all ); -use Packages::HTML (); +use Packages::Template (); use Packages::Sections; use Packages::I18N::Locale; @@ -38,6 +42,7 @@ use Packages::DoDownload; use Packages::DoFilelist; &Packages::CGI::reset; +$Packages::Search::too_many_hits = 0; # clean up env $ENV{PATH} = "/bin:/usr/bin"; @@ -60,7 +65,8 @@ my $debug = DEBUG && $input->param("debug"); $debug = 0 if !defined($debug) || $debug !~ /^\d+$/o; $Packages::CGI::debug = $debug; -&Packages::Config::init( '../' ); +my $homedir = dirname($ENV{SCRIPT_FILENAME}).'/../'; +&Packages::Config::init( $homedir ); &Packages::DB::init(); my $acc = I18N::AcceptLanguage->new(); @@ -115,6 +121,7 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) { my %SECTIONS = map { $_ => 1 } @SECTIONS; my %ARCHIVES = map { $_ => 1 } @ARCHIVES; my %ARCHITECTURES = map { $_ => 1 } (@ARCHITECTURES, 'all'); + my %PRIORITIES = map { $_ => 1 } @PRIORITIES; my %params_set; sub set_param_once { my ($cgi, $params_set, $key, $val) = @_; @@ -147,6 +154,8 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) { set_param_once( $input, \%params_set, 'source', 1); } elsif ($ARCHITECTURES{$_}) { set_param_once( $input, \%params_set, 'arch', $_); + } elsif ($PRIORITIES{$_}) { + set_param_once( $input, \%params_set, 'priority', $_); } else { push @pkg, $_; } @@ -195,11 +204,15 @@ my %params_def = ( keywords => { default => undef, subsection => { default => 'default', match => '^([\w-]+)$', array => ',', var => \@subsections, replace => { default => [] } }, + priority => { default => 'default', match => '^([\w-]+)$', + array => ',', + replace => { default => [] } }, arch => { default => 'any', match => '^([\w-]+)$', array => ',', var => \@archs, replace => { any => \@ARCHITECTURES } }, format => { default => 'html', match => '^([\w.]+)$', }, mode => { default => undef, match => '^(\w+)$', }, + sort_by => { default => 'file', match => '^(\w+)$', }, ); my %opts; my %params = Packages::CGI::parse_params( $input, \%params_def, \%opts ); @@ -238,50 +251,40 @@ my $pet1 = new Benchmark; my $petd = timediff($pet1, $pet0); debug( "Parameter evaluation took ".timestr($petd) ) if DEBUG; -my (%html_header, $menu, $page_content); +my $template = new Packages::Template( $TEMPLATEDIR, $opts{format}, { lang => $opts{lang}, charset => $charset, debug => ( DEBUG ? $opts{debug} : 0 ) }, ( $CACHEDIR ? { COMPILE_DIR => $CACHEDIR } : {} ) ); + +my (%html_header, %page_content); unless (@Packages::CGI::fatal_errors) { no strict 'refs'; &{"do_$what_to_do"}( \%params, \%opts, \%html_header, - \$menu, \$page_content ); -} else { - %html_header = ( title => _g('Error'), - lang => $opts{lang}, - print_title => 1, - print_search_field => 'packages', - search_field_values => { - keywords => _g('search for a package'), - searchon => 'default', - arch => 'any', - suite => 'all', - section => 'all', - exact => 1, - debug => $debug, - }, - ); + \%page_content ); } -print $input->header( -charset => $charset ); +$page_content{opts} = \%opts; +$page_content{params} = \%params; -print Packages::HTML::header( %html_header ); +$page_content{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) }; +$page_content{make_url} = sub { return &Packages::CGI::make_url(@_) }; +# needed to work around the limitations of the the FILTER syntax +$page_content{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') }; +$page_content{uri_escape} = sub { return URI::Escape::uri_escape(@_) }; +$page_content{quotemeta} = sub { return quotemeta($_[0]) }; -print $menu||''; -print_errors(); -print_hints(); -print_msgs(); -print_debug() if DEBUG; -print_notes(); +print $input->header( -charset => $charset ); + +#use Data::Dumper; +#print '
'.Dumper(\%ENV, \%html_header, \%page_content, get_all_messages()).'
'; unless (@Packages::CGI::fatal_errors) { - print $page_content; +print $template->page( $what_to_do, { %page_content, %{ get_all_messages() } } ); +} else { +print $template->error_page( get_all_messages() ); } my $tet1 = new Benchmark; my $tetd = timediff($tet1, $tet0); -print "Total page evaluation took ".timestr($tetd)."
" - if DEBUG; -my $trailer = Packages::HTML::trailer( $ROOT ); +my $trailer = $template->trailer( undef, undef, undef, $tetd ); print $trailer; # vim: ts=8 sw=4 - diff --git a/config.sh.sed.in b/config.sh.sed.in index ea6703a..d5d8498 100644 --- a/config.sh.sed.in +++ b/config.sh.sed.in @@ -14,14 +14,16 @@ podir=${topdir}/po localedir=%TOPDIR%/locale staticdir=${topdir}/static configdir=${topdir}/conf +templatedir=${topdir}/templates +cachedir=${topdir}/cache # unset this if %SITE% moves somewhere where the packages files # cannot be obtained locally # -localdir=/org/ftp.debian.org/ftp +#localdir=/org/ftp.debian.org/ftp # path to private ftp directory -ftproot=/org/ftp.root +#ftproot=/org/ftp.root ftpsite=http://ftp.debian.org/debian nonus_ftpsite=http://ftp.uk.debian.org/debian-non-US @@ -41,6 +43,7 @@ archives="us non-US security amd64 kfreebsd backports volatile" sections="main contrib non-free" parts="$sections" suites="oldstable stable stable-volatile stable-backports testing unstable experimental" +priorities="required important standard optional extra" dists="$suites" architectures="alpha amd64 arm hppa hurd-i386 i386 ia64 kfreebsd-i386 kfreebsd-amd64 m68k mips mipsel powerpc s390 sparc" arch_oldstable="alpha arm hppa i386 ia64 m68k mips mipsel powerpc s390 sparc" @@ -53,4 +56,4 @@ arch_stable_proposed_updates="${arch_stable}" # Miscellaneous # -admin_email="djpig@debian.org,joey@infodrom.org" +admin_email="djpig@debian.org" diff --git a/cron.d/050checkinst b/cron.d/050checkinst index ad6397a..7f054cb 100755 --- a/cron.d/050checkinst +++ b/cron.d/050checkinst @@ -16,6 +16,7 @@ locales="de_DE.UTF-8 en_US.UTF-8 nl_NL fr_FR.UTF-8" packages=`tempfile` locs=`tempfile` +cache=`tempfile` trap "rm -f $packages $locs" INT EXIT for p in $required @@ -36,7 +37,22 @@ do fi done -if [ -s $packages -o -s $locs ] +if [ -n "$cachedir" ] +then + if [ ! -d "$cachedir" ] + then + echo "cachedir missing." >> $cache + else + perm=$(ls -ld "$cachedir" | perl -ne 'print "ok" if /^drwxrws--- \d+ www-data/') + if [ -z "$perm" ] + then + echo "cachedir has wrong permissions." >> $cache + echo "make sure it is writable by the web server." >> $cache + fi + fi +fi + +if [ -s $packages -o -s $locs -o -s $cache ] then ( echo "Subject: Problem packages.debian.org on `hostname -s`" @@ -56,6 +72,12 @@ then echo cat $locs fi + if [ -s $cache ] + then + echo "Problems with cachedir:" + echo + cat $cache + fi ) | /usr/sbin/sendmail -t fi diff --git a/lib/Packages/CGI.pm b/lib/Packages/CGI.pm index 236dd8d..9a8584f 100644 --- a/lib/Packages/CGI.pm +++ b/lib/Packages/CGI.pm @@ -7,9 +7,10 @@ use Exporter; use Packages::Config; our @ISA = qw( Exporter ); -our @EXPORT = qw( fatal_error error hint debug msg note - print_errors print_hints print_debug print_msgs - print_notes DEBUG make_url make_search_url ); +our @EXPORT = qw( DEBUG debug fatal_error ); +our @EXPORT_OK = qw( error hint msg note get_all_messages + make_url make_search_url ); + # define this to 0 in production mode use constant DEBUG => 1; @@ -40,50 +41,22 @@ sub msg { sub note { push @notes, [ @_ ]; } -sub print_errors { - return unless @fatal_errors || @errors; - print '
'; - foreach ((@fatal_errors, @errors)) { - print "

ERROR: $_

"; - } - print '
'; -} -sub print_debug { +sub get_errors { (@fatal_errors, @errors) } +sub get_debug { return unless $debug && @debug; - print '
'; - print '

Debugging:

';
-    foreach (@debug) {
-	print "$_\n";
-    }
-    print '
'; -} -sub print_hints { - return unless @hints; - print '
'; - foreach (@hints) { - print "

$_

"; - } - print '
'; -} -sub print_msgs { - print '
'; - foreach (@msgs) { - print "

$_

"; - } - print '
'; + return @debug; } -sub print_notes { - foreach (@notes) { - my ( $title, $note ) = @$_; - - print '
'; - if ($note) { - print "

$title

"; - } else { - $note = $title; - } - print "

$note

"; - } +sub get_msgs { @msgs }; +sub get_hints { @hints }; +sub get_notes { @notes }; +sub get_all_messages { + return { + errors => [ @fatal_errors, @errors ], + debugs => $debug ? \@debug : [], + msgs => \@msgs, + hints => \@hints, + notes => \@notes, + }; } our $USE_PAGED_MODE = 1; @@ -400,9 +373,14 @@ sub init_url { } sub make_url { - my ($add_path, $add_query, $override) = @_; + my ($add_path, $add_query, @override) = @_; my (@path, @query_string) = ()x2; - $override ||= {}; + my $override = {}; + if (ref $override[0]) { + $override = $override[0]; + } elsif (@override) { + $override = { @override }; + } push @path, $Packages::Config::ROOT; foreach my $p (qw(lang source suite archive arch)) { @@ -428,9 +406,14 @@ sub make_url { } sub make_search_url { - my ($add_path, $add_query, $override) = @_; + my ($add_path, $add_query, @override) = @_; my (@path, @query_string) = ()x2; - $override ||= {}; + my $override ||= {}; + if (ref $override[0]) { + $override = $override[0]; + } elsif (@override) { + $override = { @override }; + } push @path, $Packages::Config::SEARCH_URL if $Packages::Config::SEARCH_URL; diff --git a/lib/Packages/Config.pm b/lib/Packages/Config.pm index e749735..8252a1b 100644 --- a/lib/Packages/Config.pm +++ b/lib/Packages/Config.pm @@ -4,23 +4,18 @@ use strict; use warnings; use Exporter; -use Packages::CGI; +use Packages::CGI qw( :DEFAULT error ); our @ISA = qw( Exporter ); -our ( $TOPDIR, $DBDIR, $ROOT, $HOSTNAME, $HOME, $CONTACT_MAIL, $WEBMASTER_MAIL, - $SEARCH_PAGE, $SEARCH_URL, @LANGUAGES, $LOCALES, - $SRC_SEARCH_URL, $CONTENTS_SEARCH_CGI, - $CN_HELP_URL, $BUG_URL, $SRC_BUG_URL, $QA_URL, $DDPO_URL, +our ( $TOPDIR, $DBDIR, $TEMPLATEDIR, $CACHEDIR, $ROOT, + @LANGUAGES, $LOCALES, @SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES, - %FTP_SITES ); -our @EXPORT_OK = qw( $TOPDIR $DBDIR $ROOT $HOSTNAME $HOME $CONTACT_MAIL - $WEBMASTER_MAIL @LANGUAGES $LOCALES - $SEARCH_PAGE $SEARCH_URL - $SRC_SEARCH_URL $CONTENTS_SEARCH_CGI - $CN_HELP_URL $BUG_URL $SRC_BUG_URL $QA_URL $DDPO_URL + @PRIORITIES, %FTP_SITES ); +our @EXPORT_OK = qw( $TOPDIR $DBDIR $TEMPLATEDIR $CACHEDIR $ROOT + @LANGUAGES $LOCALES @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES - %FTP_SITES ); + @PRIORITIES %FTP_SITES ); our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); our $config_read_time; @@ -37,21 +32,10 @@ sub init { next if /^\s*\#/o; chomp; $TOPDIR = $1 if /^\s*topdir="?([^\"]*)"?\s*$/o; + $TEMPLATEDIR = $1 if /^\s*templatedir="?([^\"]*)"?\s*$/o; + $CACHEDIR = $1 if /^\s*cachedir="?([^\"]*)"?\s*$/o; $ROOT = $1 if /^\s*root="?([^\"]*)"?\s*$/o; - $HOSTNAME = $1 if /^\s*hostname="?([^\"]*)"?\s*$/o; - $HOME = $1 if /^\s*home="?([^\"]*)"?\s*$/o; $LOCALES = $1 if /^\s*localedir="?([^\"]*)"?\s*$/o; -# $SEARCH_CGI = $1 if /^\s*search_cgi="?([^\"]*)"?\s*$/o; - $SEARCH_PAGE = $1 if /^\s*search_page="?([^\"]*)"?\s*$/o; - $SEARCH_URL = $1 if /^\s*search_url="?([^\"]*)"?\s*$/o; - $SRC_SEARCH_URL = $1 if /^\s*search_src_url="?([^\"]*)"?\s*$/o; - $WEBMASTER_MAIL = $1 if /^\s*webmaster="?([^\"]*)"?\s*$/o; - $CONTACT_MAIL = $1 if /^\s*contact="?([^\"]*)"?\s*$/o; - $BUG_URL = $1 if /^\s*bug_url="?([^\"]*)"?\s*$/o; - $SRC_BUG_URL = $1 if /^\s*src_bug_url="?([^\"]*)"?\s*$/o; - $QA_URL = $1 if /^\s*qa_url="?([^\"]*)"?\s*$/o; - $DDPO_URL = $1 if /^\s*ddpo_url="?([^\"]*)"?\s*$/o; - $CN_HELP_URL = $1 if /^\s*cn_help_url="?([^\"]*)"?\s*$/o; $FTP_SITES{us} = $1 if /^\s*ftpsite="?([^\"]*)"?\s*$/o; $FTP_SITES{$1} = $2 if /^\s*(\w+)_ftpsite="?([^\"]*)"?\s*$/o; @LANGUAGES = split(/\s+/, $1) if /^\s*polangs="?([^\"]*)"?\s*$/o; @@ -59,6 +43,10 @@ sub init { @SECTIONS = split(/\s+/, $1) if /^\s*sections="?([^\"]*)"?\s*$/o; @ARCHIVES = split(/\s+/, $1) if /^\s*archives="?([^\"]*)"?\s*$/o; @ARCHITECTURES = split(/\s+/, $1) if /^\s*architectures="?([^\"]*)"?\s*$/o; + @PRIORITIES = split(/\s+/, $1) if /^\s*priorities="?([^\"]*)"?\s*$/o; + } + foreach (($TEMPLATEDIR, $CACHEDIR, $LOCALES)) { + s/\$\{?topdir\}?/$TOPDIR/g; } close (C); debug( "read config ($modtime > $config_read_time)" ) if DEBUG; diff --git a/lib/Packages/DoDownload.pm b/lib/Packages/DoDownload.pm index 89da639..bd7f8e1 100644 --- a/lib/Packages/DoDownload.pm +++ b/lib/Packages/DoDownload.pm @@ -3,6 +3,7 @@ package Packages::DoDownload; use strict; use warnings; +use POSIX; use CGI (); use DB_File; use Benchmark ':hireswallclock'; @@ -10,200 +11,17 @@ use Exporter; use Deb::Versions; use Packages::I18N::Locale; -use Packages::HTML (); use Packages::Search qw( :all ); -use Packages::Config qw( $HOME $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES $SEARCH_URL ); +use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES ); use Packages::CGI; use Packages::DB; our @ISA = qw( Exporter ); our @EXPORT = qw( do_download ); -# TODO: find a way to get the U.S. mirror list from a more authoritive -# location automatically. might not be overly smart to automatize it -# completely, since I hand pick sites that are up-to-date, fast, and -# have HTTP on a reasonably short URL -# -- Joy - -# hint: -# grep-dctrl -F Site,Alias -e '(udel|bigfoot|kernel|crosslink|internap|cerias|lcs.mit|progeny)' Mirrors.masterlist | timestamps/archive_mirror_check.py -our @north_american_sites = ( - "ftp.us.debian.org/debian", - "http.us.debian.org/debian", - "ftp.debian.org/debian", -# "ftp.ca.debian.org/debian", - "ftp.egr.msu.edu/debian", - "mirrors.kernel.org/debian", - "archive.progeny.com/debian", - "debian.crosslink.net/debian", - "ftp-mirror.internap.com/pub/debian", - "ftp.cerias.purdue.edu/pub/os/debian", - "ftp.lug.udel.edu/debian", - "debian.lcs.mit.edu/debian", - "debian.teleglobe.net", - "debian.rutgers.edu", - "debian.oregonstate.edu/debian", - ); -our @european_sites = ( - "ftp.de.debian.org/debian", - "ftp.at.debian.org/debian", - "ftp.bg.debian.org/debian", - "ftp.cz.debian.org/debian", - "ftp.dk.debian.org/debian", - "ftp.ee.debian.org/debian", - "ftp.fi.debian.org/debian", - "ftp.fr.debian.org/debian", - "ftp.hr.debian.org/debian", - "ftp.hu.debian.org/debian", - "ftp.ie.debian.org/debian", - "ftp.is.debian.org/debian", - "ftp.it.debian.org/debian", - "ftp.nl.debian.org/debian", - "ftp.no.debian.org/debian", - "ftp.pl.debian.org/debian", - "ftp.si.debian.org/debian", - "ftp.es.debian.org/debian", - "ftp.se.debian.org/debian", - "ftp.tr.debian.org/debian", - "ftp.uk.debian.org/debian", - ); -our @south_american_sites = ( - "ftp.br.debian.org/debian", - "ftp.cl.debian.org/debian", - ); -our @australian_sites = ( - "ftp.au.debian.org/debian", - "ftp.wa.au.debian.org/debian", - "ftp.nz.debian.org/debian", - ); -our @asian_sites = ( - "ftp.jp.debian.org/debian", -# "ftp.kr.debian.org/debian", - "linux.csie.nctu.edu.tw/debian", - "debian.linux.org.tw/debian", - "linux.cdpa.nsysu.edu.tw/debian", - ); - -our @volatile_european_sites = ( - "volatile.debian.net/debian-volatile", - "ftp2.de.debian.org/debian-volatile", - "ftp.sk.debian.org/debian-volatile", - ); -our @backports_european_sites = ( - "www.backports.org/debian", - "debian.sil.at/backports.org/", - "backports.debian.or.at/backports.org", - "mirror.realroute.net/backports.org", - "backports.cisbg.com", - "backports.linuxdediziert.de/backports.org", - "debian.netcologne.de/debian-backports", - "ftp.de.debian.org/backports.org", - "mirror.buildd.net/backports.org", - "ftp.estpak.ee/backports.org", - "debian.acantho.net/backports.org", - "backports.essentkabel.com/backports.org", - "backports.sipo.nl", - "ftp.tuke.sk", - ); -our @backports_asian_sites = ( - "backports.mithril-linux.org", - ); -our @backports_australian_sites = ( - "mirror.linux.org.au/backports.org", - ); -our @amd64_european_sites = ( - "amd64.debian.net/debian", - "ftp.de.debian.org/debian-amd64/debian", - "bach.hpc2n.umu.se/debian-amd64/debian", - "bytekeeper.as28747.net/debian-amd64/debian", - "mirror.switch.ch/debian-amd64/debian", - "ftp.nl.debian.org/debian-amd64/debian", - ); -our @amd64_asian_sites = ( - "hanzubon.jp/debian-amd64/debian", - ); -our @amd64_north_american_sites = ( - "mirror.espri.arizona.edu/debian-amd64/debian", - ); -our @kfreebsd_north_american_sites = ( - "www.gtlib.gatech.edu/pub/gnuab/debian", - ); -our @kfreebsd_european_sites = ( - # master site, aka ftp.gnuab.org - "kfreebsd-gnu.debian.net/debian", - "ftp.easynet.be/ftp/gnuab/debian", - "ftp.de.debian.org/debian-kfreebsd", - "ftp.sh.cvut.cz/MIRRORS/debian-non-linux", - "ftp.eila.jussieu.fr/pub/Debian-gnuab", - ); -my @kfreebsd_asian_sites = ( - "ftp.citkit.ru/pub/HURD/debian", - ); -our @nonus_north_american_sites = ( -# "ftp.ca.debian.org/debian-non-US", - "debian.yorku.ca/debian/non-US", - "mirror.direct.ca/linux/debian-non-US", - ); -our @nonus_european_sites = ( - "non-us.debian.org/debian-non-US", - "ftp.de.debian.org/debian-non-US", - "ftp.at.debian.org/debian-non-US", - "ftp.bg.debian.org/debian-non-US", - "ftp.cz.debian.org/debian-non-US", - "ftp.fi.debian.org/debian-non-US", - "ftp.fr.debian.org/debian-non-US", - "ftp.hr.debian.org/debian-non-US", - "ftp.hu.debian.org/debian-non-US", - "ftp.ie.debian.org/debian-non-US", - "ftp.is.debian.org/debian-non-US", - "ftp.it.debian.org/debian-non-US", - "ftp.nl.debian.org/debian-non-US", - "ftp.no.debian.org/debian-non-US", - "ftp.pl.debian.org/debian/non-US", - "ftp.si.debian.org/debian-non-US", - "ftp.es.debian.org/debian-non-US", - "ftp.se.debian.org/debian-non-US", - "ftp.tr.debian.org/debian-non-US", - "ftp.uk.debian.org/debian/non-US", - ); -our @nonus_australian_sites = ( - "ftp.au.debian.org/debian-non-US", - "ftp.wa.au.debian.org/debian-non-US", - "ftp.nz.debian.org/debian-non-US", - ); -our @nonus_asian_sites = ( - "ftp.jp.debian.org/debian-non-US", -# "ftp.kr.debian.org/debian-non-US", - "linux.csie.nctu.edu.tw/debian-non-US", - "debian.linux.org.tw/debian-non-US", - "linux.cdpa.nsysu.edu.tw/debian-non-US", - ); -our @nonus_south_american_sites = ( - "ftp.br.debian.org/debian-non-US", - "ftp.cl.debian.org/debian-non-US", - ); - -# list of architectures -our %arches = ( - i386 => 'Intel x86', - m68k => 'Motorola 680x0', - sparc => 'SPARC', - alpha => 'Alpha', - powerpc => 'PowerPC', - arm => 'ARM', - hppa => 'HP PA-RISC', - ia64 => 'Intel IA-64', - mips => 'MIPS', - mipsel => 'MIPS (DEC)', - s390 => 'IBM S/390', - "hurd-i386" => 'Hurd (i386)', - amd64 => 'AMD64', - "kfreebsd-i386" => 'GNU/kFreeBSD (i386)', - "kfreebsd-amd64" => 'GNU/kFreeBSD (amd64)' -); sub do_download { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_content) = @_; if ($params->{errors}{package}) { fatal_error( _g( "package not valid or not specified" ) ); @@ -228,7 +46,7 @@ sub do_download { our (%packages_all); my (@results); - my ($final_result, $file, $filen, $md5sum, @file_components, $archive) = ("")x5; + my ($final_result, $filename, $directory, @file_components, $archive) = ("")x5; my $st0 = new Benchmark; unless (@Packages::CGI::fatal_errors) { @@ -240,8 +58,8 @@ sub do_download { @results = grep { $_->[7] ne 'v' } @results; unless (@results) { - fatal_error( _g( "No such package." )."
". - sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ); +# fatal_error( _g( "No such package." )."
". +# sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ); } else { my $final_result = shift @results; foreach (@results) { @@ -253,120 +71,38 @@ sub do_download { debug( "final_result=@$final_result", 1 ); $archive = $final_result->[1]; my %data = split /\000/, $packages_all{"$pkg $arch $final_result->[7]"}; - $file = $data{filename}; - @file_components = split('/', $file); - $filen = pop(@file_components); - - $md5sum = $data{md5sum}; - } - } - - %$html_header = ( title => _g( "Package Download Selection" ), - lang => $opts->{lang}, - print_title => 1 ); - - if ($file) { - if ($arch ne 'all') { - $$page_content .= '

'.sprintf( _g('Download Page for %s on %s machines'), $filen, $arches{$arch} ).'

'; - } else { - $$page_content .= '

'.sprintf( _g('Download Page for %s'), $filen ).'

'; - } - my $directory = join( '/', @file_components).'/'; - if ($archive ne 'security' ) { - $$page_content .= "

".sprintf( _g( 'You can download the requested file from the %s subdirectory at any of these sites:' ), $directory )."

\n"; - } else { - $$page_content .= "

".sprintf( _g( 'You can download the requested file from the %s subdirectory at:' ), $directory )."

\n"; - } - - hint(sprintf(_g("If you are running Debian, it's strongly suggested to use a - package manager like aptitude or synaptic to download and install - packages, instead of doing so manually via this website."), - make_url('aptitude','',{arch=>undef}), - make_url('synaptic','',{arch=>undef}) ) ); - - if ($archive eq 'security') { - - $$page_content .= ""; - $$page_content .= '

'._g( 'Debian security updates are currently officially distributed only via security.debian.org.' ).'

'; - } elsif ($archive eq 'amd64') { - - $$page_content .= print_links( _g( "North America" ), $file, @amd64_north_american_sites ); - $$page_content .= print_links( _g( "Europe" ), $file, @amd64_european_sites ); - $$page_content .= print_links( _g( "Asia" ), $file, @amd64_asian_sites ); - - $$page_content .= '

'._g( 'Note that AMD64 is not officialy included in the Debian archive yet, but the AMD64 porter group keeps their archive in sync with the official archive as close as possible. See the AMD64 ports page for current information.' ).'

'; - } elsif ($archive eq 'kfreebsd') { - - $$page_content .= print_links( _g( "North America" ), $file, @kfreebsd_north_american_sites ); - $$page_content .= print_links( _g( "Europe" ), $file, @kfreebsd_european_sites ); - $$page_content .= print_links( _g( "Asia" ), $file, @kfreebsd_asian_sites ); - - $$page_content .= '

'._g( 'Note that GNU/kFreeBSD is not officialy included in the Debian archive yet, but the GNU/kFreeBSD porter group keeps their archive in sync with the official archive as close as possible. See the GNU/kFreeBSD ports page for current information.' ).'

'; - } elsif ($archive eq 'non-US') { - - $$page_content .= '
'; - $$page_content .= print_links( _g( "North America" ), $file, @nonus_north_american_sites ); - $$page_content .= print_links( _g( "Australia and New Zealand" ), $file, - @nonus_australian_sites ); - $$page_content .= print_links( _g( "Asia" ), $file, @nonus_asian_sites ); - $$page_content .= print_links( _g( "South America" ), $file, @nonus_south_american_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "Europe" ), $file, @nonus_european_sites ); - $$page_content .= '
'; - - $$page_content .= '

'.sprintf( _g('If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://www.debian.org/mirror/list-non-US' ).'

'; - } elsif ($archive eq 'backports') { - - $$page_content .= '
'; - $$page_content .= print_links( _g( "Europe" ), $file, @backports_european_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "Australia and New Zealand" ), $file, - @backports_australian_sites ); - $$page_content .= print_links( _g( "Asia" ), $file, @backports_asian_sites ); - $$page_content .= '
'; - - $$page_content .= '

'.sprintf( _g( 'If none of the above sites are fast enough for you, please see our complete mirror list.'), 'http://www.backports.org/debian/README.mirrors.html' ).'

'; - } elsif ($archive eq 'volatile') { - - $$page_content .= print_links( _g( "Europe" ), $file, @volatile_european_sites ); + 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 ); +# fatal_error( _g( "No such package." )."
". +# sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) ) unless %data; + } + @file_components = split('/', $data{filename}); + $filename = pop(@file_components); + $directory = join( '/', @file_components).'/'; + + $page_content->{archive} = $archive; + $page_content->{suite} = $suite; + $page_content->{pkg} = $pkg; + $page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/102.4)+0.5)/10 ); + $page_content->{pkgsize_unit} = _g( 'kByte' ); + if ($page_content->{pkgsize} > 1024) { + $page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/(102.4*102.4))+0.5)/100 ); + $page_content->{pkgsize_unit} = _g( 'MByte' ); + } + $page_content->{architecture} = $arch; + foreach (keys %data) { + $page_content->{$_} = $data{$_}; + } + $page_content->{filename} = { file => $filename, + directory => $directory, + full => $data{filename}, + }; - $$page_content .= '

'.sprintf( _g( 'If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://volatile.debian.net/mirrors.html' ).'

'; - } elsif ($archive eq 'us') { - - $$page_content .= '
'; - $$page_content .= print_links( _g( "North America" ), $file, @north_american_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "Europe" ), $file, @european_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "Australia and New Zealand" ), $file, @australian_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "Asia" ), $file, @asian_sites ); - $$page_content .= '
'; - $$page_content .= print_links( _g( "South America" ), $file, @south_american_sites ); - $$page_content .= '
'; - - $$page_content .= '

'.sprintf( _g( 'If none of the above sites are fast enough for you, please see our complete mirror list.' ), 'http://www.debian.org/mirror/list' ).'

'; } - - $$page_content .= '

'._g( 'Note that in some browsers you will need to tell your browser you want the file saved to a file. For example, in Firefox or Mozilla, you should hold the Shift key when you click on the URL.' ).'

'; - $$page_content .= "

".sprintf( _g( 'The MD5sum for %s is %s' ), $filen, $md5sum ).'

' - if $md5sum; - } -} - -sub print_links { - my ( $title, $file, @servers ) = @_; - - my $str = "

$title

"; - $str .= "
    "; - foreach (@servers) { - $str .= "
  • $_
  • \n"; - # $str .= "
  • $_
  • \n"; } - $str .= "
"; - - return $str; + } 1; diff --git a/lib/Packages/DoFilelist.pm b/lib/Packages/DoFilelist.pm index a1dda56..97e9f01 100644 --- a/lib/Packages/DoFilelist.pm +++ b/lib/Packages/DoFilelist.pm @@ -17,7 +17,6 @@ use Packages::I18N::Locale; use Packages::CGI; use Packages::DB; use Packages::Search qw( :all ); -use Packages::HTML; use Packages::Page (); use Packages::SrcPage (); @@ -25,7 +24,7 @@ our @ISA = qw( Exporter ); our @EXPORT = qw( do_filelist ); sub do_filelist { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_content) = @_; if ($params->{errors}{package}) { fatal_error( _g( "package not valid or not specified" ) ); @@ -37,17 +36,12 @@ sub do_filelist { fatal_error( _g( "architecture not valid or not specified" ) ); } - $$menu = ''; my $pkg = $opts->{package}; my $suite = $opts->{suite}[0]; my $arch = $opts->{arch}[0] ||''; - - %$html_header = ( title => sprintf( _g( "Filelist of package %s in %s of architecture %s" ), $pkg, $suite, $arch ), - title_tag => sprintf( _g( "Filelist of package %s/%s/%s" ), $pkg, $suite, $arch ), - lang => $opts->{lang}, - keywords => "debian, $suite, $arch, filelist", - print_title => 1, - ); + $page_content->{pkg} = $pkg; + $page_content->{suite} = $suite; + $page_content->{arch} = $arch; unless (@Packages::CGI::fatal_errors) { if (tie my %contents, 'DB_File', "$DBDIR/contents/filelists_${suite}_${arch}.db", @@ -57,13 +51,13 @@ sub do_filelist { fatal_error( _g( "No such package in this suite on this architecture." ) ); } else { my @files = unpack "L/(CC/a)", $contents{$pkg}; - my $file = ""; - $$page_content .= '
';
+		my $file;
+
+		$page_content->{files} = [];
 		for (my $i=0; $i{files}}, "/$file";
 		}
-		$$page_content .= '
'; } } else { fatal_error( _g( "Invalid suite/architecture combination" ) ); diff --git a/lib/Packages/DoIndex.pm b/lib/Packages/DoIndex.pm index 064a18a..0ed874a 100644 --- a/lib/Packages/DoIndex.pm +++ b/lib/Packages/DoIndex.pm @@ -44,9 +44,12 @@ sub send_file { } my $wwwdir = "$TOPDIR/www"; - my $path = "$opts->{suite}[0]/"; + my $path = ""; + $path .= "source/" if $opts->{source}; + $path .= "$opts->{suite}[0]/"; $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1; $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}}; + $path .= "$opts->{priority}[0]/" if @{$opts->{priority}}; # we don't have translated index pages for subsections yet $opts->{lang} = 'en' if @{$opts->{subsection}} or $file eq 'allpackages'; $path .= "$file.$opts->{lang}.$opts->{format}"; @@ -71,21 +74,6 @@ sub send_file { $path, $! ) ); } } - - %$html_header = ( title => _g('Error'), - lang => $opts->{lang}, - print_title => 1, - print_search_field => 'packages', - search_field_values => { - keywords => _g('search for a package'), - searchon => 'default', - arch => 'any', - suite => 'all', - section => 'all', - exact => 1, - debug => $Packages::CGI::debug, - }, - ); } 1; diff --git a/lib/Packages/DoNewPkg.pm b/lib/Packages/DoNewPkg.pm index 059d5a3..7ee921a 100644 --- a/lib/Packages/DoNewPkg.pm +++ b/lib/Packages/DoNewPkg.pm @@ -16,10 +16,10 @@ use Packages::I18N::Locale; use Packages::Search qw( :all ); use Packages::CGI; use Packages::DB; -use Packages::Config qw( $TOPDIR @SECTIONS $HOSTNAME $ROOT ); +use Packages::Config qw( $TOPDIR @SECTIONS $ROOT ); sub do_newpkg { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_content) = @_; if ($params->{errors}{suite}) { fatal_error( _g( "suite not valid or not specified" ) ); @@ -38,10 +38,6 @@ sub do_newpkg { my $one_section = @{$opts->{section}} == 1 ? $opts->{section}[0] : undef; - my @full_path = ($HOSTNAME, $ROOT, $suite); - push @full_path, $one_archive if $one_archive; - my $full_path = join( '/', @full_path ); - my @new_pkgs; #FIXME: move to Packages::DB? open NEWPKG, '<', "$TOPDIR/files/packages/newpkg_info" @@ -63,90 +59,60 @@ sub do_newpkg { my $now_time = strftime ("%B %d, %Y", @date); my $rss_time = strftime ("%Y-%m-%dT%H:%M+00:00", @date); - unless ($opts->{format} eq 'rss') { - my $title = sprintf( _g( "New Packages in \"%s\"" ), - $suite ); - %$html_header = ( title => $title, - title_keywords => "debian, "._g('new packages').", $suite, @{$opts->{section}}", - meta => "", - lang => $opts->{lang}, - print_title => 1 ); - - $$page_content .= "

" - . sprintf(_g( "The following packages were added to suite %s%s in the Debian archive during the last 7 days."), $suite, - $one_section ? sprintf(_g(" (section %s)"),$one_section):'')."

" - . "

".sprintf( _g( "This information is also available as an RSS feed." ), "newpkg?format=rss" ) - ." \"[RSS

"; - - if (@new_pkgs) { - $$page_content .= "\n
    \n"; - - foreach my $pkg (sort { &$sort_func($a,$b) } @new_pkgs) { - $$page_content .= sprintf ("
  • %s\n -- %s%s", - $pkg->[0], $pkg->[0], - encode_entities($pkg->[-1], '"&<>'), - $pkg->[1] ? - sprintf(_g(" (%s days old)"),$pkg->[1]): - ''); - } - $$page_content .= "\n
\n" if @new_pkgs; - } - - my $slist = ''; - if ($one_section) { - foreach my $s (@SECTIONS) { - $slist .= ", " if $slist; - $slist .= $one_section eq $s ? $s : - "$s"; - } - } - - $$page_content .= '

". - _g( "All packages" ) ."
('txt.gz'})."\">". - _g( "compact compressed textlist" ).")
". - ($slist ? sprintf(_g( "New packages in %s" ), $slist ):''). - "

\n"; - - } else { # unless ($opts->{format} eq 'rss') - my ( $rss_link, $rss_description, $rss_date ); - - $rss_description = sprintf(_g( "The following packages were added to suite %s%s in the Debian archive during the last 7 days."), $suite, - $one_section ? sprintf(_g(" (section %s)"),$one_section):''); - - my $rss = new XML::RSS (version => '1.0'); - $rss_link = "$full_path".($one_section?"$one_section/":'')."/newpkg?format=rss"; - $rss->channel( - title => _g("New Debian Packages"), - link => $rss_link, - description => $rss_description, - dc => { - date => $rss_time, - publisher => 'debian-www@lists.debian.org', - rights => 'Copyright '.($date[5]+1900).', SPI Inc.', - language => $opts->{lang}, - }, - syn => { - updatePeriod => "daily", - updateFrequency => "2", -# updateBase => "1901-01-01T00:00+00:00", - } ); - - foreach my $pkg (sort { &$sort_func($a,$b) } @new_pkgs) { - $rss->add_item( - title => $pkg->[0], - link => "$full_path/$pkg->[0]", - description => $pkg->[-1], - dc => { - subject => $pkg->[6], - } ); - } - my $charset = get_charset( $opts->{lang} ); - print &CGI::header( -type => 'application/rss+xml', - -charset => $charset ); - print $rss->as_string; - exit; + $page_content->{make_url} = sub { return &Packages::CGI::make_url(@_) }; + + if (@new_pkgs) { + $page_content->{new_packages} = [ sort { &$sort_func($a,$b) } @new_pkgs ]; } + + $page_content->{suite} = $suite; + $page_content->{section} = $one_section if $one_section; + $page_content->{archive} = $one_archive if $one_archive; + $page_content->{sections} = \@SECTIONS; + +# my @full_path = ($HOSTNAME, $ROOT, $suite); +# push @full_path, $one_archive if $one_archive; +# my $full_path = join( '/', @full_path ); + +# } else { # unless ($opts->{format} eq 'rss') +# my ( $rss_link, $rss_description, $rss_date ); + +# $rss_description = sprintf(_g( "The following packages were added to suite %s%s in the Debian archive during the last 7 days."), $suite, +# $one_section ? sprintf(_g(" (section %s)"),$one_section):''); + +# my $rss = new XML::RSS (version => '1.0'); +# $rss_link = "$full_path".($one_section?"$one_section/":'')."/newpkg?format=rss"; +# $rss->channel( +# title => _g("New Debian Packages"), +# link => $rss_link, +# description => $rss_description, +# dc => { +# date => $rss_time, +# publisher => 'debian-www@lists.debian.org', +# rights => 'Copyright '.($date[5]+1900).', SPI Inc.', +# language => $opts->{lang}, +# }, +# syn => { +# updatePeriod => "daily", +# updateFrequency => "2", +# # updateBase => "1901-01-01T00:00+00:00", +# } ); + +# foreach my $pkg (sort { &$sort_func($a,$b) } @new_pkgs) { +# $rss->add_item( +# title => $pkg->[0], +# link => "$full_path/$pkg->[0]", +# description => $pkg->[-1], +# dc => { +# subject => $pkg->[6], +# } ); +# } +# my $charset = get_charset( $opts->{lang} ); +# print &CGI::header( -type => 'application/rss+xml', +# -charset => $charset ); +# print $rss->as_string; +# exit; +# } } 1; diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index f8782b1..df9a91d 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -14,15 +14,12 @@ our @EXPORT = qw( do_search ); use Deb::Versions; use Packages::I18N::Locale; use Packages::Search qw( :all ); -use Packages::CGI; +use Packages::CGI qw( :DEFAULT msg ); use Packages::DB; -use Packages::HTML qw(marker); -use Packages::Config qw( $DBDIR $SEARCH_URL $SEARCH_PAGE - @SUITES @ARCHIVES $ROOT ); -use Packages::HTML; +use Packages::Config qw( $DBDIR @SUITES @ARCHIVES $ROOT ); sub do_search { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_content) = @_; $Params::Search::too_many_hits = 0; @@ -33,8 +30,6 @@ sub do_search { fatal_error( _g( "keyword too short (keywords need to have at least two characters)" ) ); } - $$menu = ""; - my @keywords = @{$opts->{keywords}}; my $searchon = $opts->{searchon}; @@ -56,19 +51,19 @@ sub do_search { if ($searchon eq 'names') { if ($opts->{source}) { - do_names_search( \@keywords, \%sources, $sp_obj, + do_names_search( [ @keywords ], \%sources, $sp_obj, \&read_src_entry_all, $opts, \@results, \@non_results ); } else { - do_names_search( \@keywords, \%packages, $p_obj, + do_names_search( [ @keywords ], \%packages, $p_obj, \&read_entry_all, $opts, \@results, \@non_results ); } } else { - do_names_search( \@keywords, \%packages, $p_obj, + do_names_search( [ @keywords ], \%packages, $p_obj, \&read_entry_all, $opts, \@results, \@non_results ); - do_fulltext_search( \@keywords, "$DBDIR/descriptions.txt", + do_fulltext_search( [ @keywords ], "$DBDIR/descriptions.txt", \%did2pkg, \%packages, \&read_entry_all, $opts, \@results, \@non_results ); @@ -110,11 +105,11 @@ sub do_search { unless (@non_results) { error( _g( "Can't find that package." ) ); } else { - hint( _g( "Can't find that package." )." ". - sprintf( _g( '%s'. - " results have not been displayed due to the". - " search parameters." ), "$SEARCH_URL/$keyword_esc" , - $#non_results+1 ) ); +# hint( _g( "Can't find that package." )." ". +# sprintf( _g( '%s'. +# " results have not been displayed due to the". +# " search parameters." ), "$SEARCH_URL/$keyword_esc" , +# $#non_results+1 ) ); } } else { @@ -132,27 +127,23 @@ sub do_search { encode_entities(make_search_url('',"keywords=$keyword_esc",{exact => 0})) ) ); } } - hint( sprintf( _g( 'You can try a different search on the Packages search page.' ), "$SEARCH_PAGE#search_packages" ) ); +# hint( sprintf( _g( 'You can try a different search on the Packages search page.' ), "$SEARCH_PAGE#search_packages" ) ); } - %$html_header = ( title => _g( 'Package Search Results' ) , - lang => $opts->{lang}, - title_tag => _g( 'Debian Package Search Results' ), - print_title => 1, - print_search_field => 'packages', - search_field_values => { - keywords => $keyword_enc, - searchon => $opts->{searchon_form}, - arch => $archs_enc, - suite => $suites_enc, - section => $sections_enc, - exact => $opts->{exact}, - debug => $opts->{debug}, - }, - ); - - $$page_content = ''; + $page_content->{make_url} = sub { return &Packages::CGI::make_url(@_) }; + $page_content->{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) }; + + $page_content->{search_field_values} = { + keywords => $keyword_enc, + searchon => $opts->{searchon_form}, + arch => $archs_enc, + suite => $suites_enc, + section => $sections_enc, + exact => $opts->{exact}, + debug => $opts->{debug}, + }; + if (@results) { my (%pkgs, %subsect, %sect, %archives, %desc, %binaries, %provided_by); @@ -177,10 +168,10 @@ sub do_search { my %uniq_pkgs = map { $_ => 1 } (keys %pkgs, keys %provided_by); my @pkgs = sort keys %uniq_pkgs; - $$page_content .= print_packages( \%pkgs, \@pkgs, $opts, \@keywords, - \&print_package, \%provided_by, - \%archives, \%sect, \%subsect, - \%desc ); + process_packages( $page_content, 'packages', \%pkgs, \@pkgs, $opts, \@keywords, + \&process_package, \%provided_by, + \%archives, \%sect, \%subsect, + \%desc ); } else { # unless $opts->{source} foreach (@results) { @@ -208,134 +199,112 @@ sub do_search { } my @pkgs = sort keys %pkgs; - $$page_content .= print_packages( \%pkgs, \@pkgs, $opts, \@keywords, - \&print_src_package, \%archives, - \%sect, \%subsect, \%binaries ); + process_packages( $page_content, 'src_packages', \%pkgs, \@pkgs, $opts, \@keywords, + \&process_src_package, \%archives, + \%sect, \%subsect, \%binaries ); } # else unless $opts->{source} } # if @results } # sub do_search -sub print_packages { - my ($pkgs, $pkgs_list, $opts, $keywords, $print_func, @func_args) = @_; +sub process_packages { + my ($content, $target, $pkgs, $pkgs_list, $opts, $keywords, $print_func, @func_args) = @_; + + my @categories; + $content->{results} = scalar @$pkgs_list; - #my ($start, $end) = multipageheader( $input, scalar @pkgs, \%opts ); - my $str = '
'; - $str .= "

".sprintf( _g( "Found %s matching packages." ), - scalar @$pkgs_list )."

"; - #my $count = 0; my $keyword; $keyword = $keywords->[0] if @$keywords == 1; my $have_exact; if ($keyword && grep { $_ eq $keyword } @$pkgs_list) { $have_exact = 1; - $str .= '

'._g( "Exact hits" ).'

'; - $str .= &$print_func( $keyword, $pkgs->{$keyword}||{}, - map { $_->{$keyword}||{} } @func_args ); + $categories[0]{name} = _g( "Exact hits" ); + + $categories[0]{$target} = [ &$print_func( $keyword, $pkgs->{$keyword}||{}, + map { $_->{$keyword}||{} } @func_args ) ]; @$pkgs_list = grep { $_ ne $keyword } @$pkgs_list; } if (@$pkgs_list && (($opts->{searchon} ne 'names') || !$opts->{exact})) { - $str .= '

'._g( 'Other hits' ).'

' - if $have_exact; + my %cat; + $cat{name} = _g( 'Other hits' ) if $have_exact; + $cat{packages} = []; foreach my $pkg (@$pkgs_list) { - #$count++; - #next if $count < $start or $count > $end; - $str .= &$print_func( $pkg, $pkgs->{$pkg}||{}, - map { $_->{$pkg}||{} } @func_args ); + push @{$cat{$target}}, &$print_func( $pkg, $pkgs->{$pkg}||{}, + map { $_->{$pkg}||{} } @func_args ); } + push @categories, \%cat; } elsif (@$pkgs_list) { - $str .= "

".sprintf( _g( '%s results have not been displayed because you requested only exact matches.' ), - encode_entities(make_search_url('',"keywords=$opts->{keyword_esc}",{exact => 0})), - scalar @$pkgs_list )."

"; + $content->{skipped} = scalar @$pkgs_list; } - $str .= '
'; - return $str; + $content->{categories} = \@categories; } -sub print_package { +sub process_package { my ($pkg, $pkgs, $provided_by, $archives, $sect, $subsect, $desc) = @_; - my $str = '

'.sprintf( _g( 'Package %s' ), $pkg ).'

'; - $str .= '
    '; + my %pkg = ( pkg => $pkg, + suites => [] ); + foreach my $suite (@SUITES) { - my $override = { suite => $suite }; - if (exists $pkgs->{$suite}) { - my %archs_printed; - my @versions = version_sort keys %{$pkgs->{$suite}}; - my $origin_str = ""; - if ($sect->{$suite}{$versions[0]}) { - $origin_str .= " ".marker($sect->{$suite}{$versions[0]}); - } - $str .= sprintf( "
  • %s (%s): %s %s\n", - make_url($pkg,'',$override), $suite, $subsect->{$suite}{$versions[0]}, - $desc->{$suite}{$versions[0]}, $origin_str ); + my %suite = ( suite => $suite ); + if (exists $pkgs->{$suite}) { + my %archs_printed; + my @versions = version_sort keys %{$pkgs->{$suite}}; + $suite{section} = $sect->{$suite}{$versions[0]}; + $suite{subsection} = $subsect->{$suite}{$versions[0]}; + $suite{desc} = $desc->{$suite}{$versions[0]}; + $suite{versions} = []; - foreach my $v (@versions) { - my $archive_str = ""; - if ($archives->{$suite}{$v} ne 'us') { - $archive_str .= " ".marker($archives->{$suite}{$v}); - } + foreach my $v (@versions) { + my %version; + $version{version} = $v; + $version{archive} = $archives->{$suite}{$v}; - my @archs_to_print = grep { !$archs_printed{$_} } sort keys %{$pkgs->{$suite}{$v}}; - $str .= sprintf( "
    %s$archive_str: %s\n", - $v, join (" ", @archs_to_print )) - if @archs_to_print; - $archs_printed{$_}++ foreach @archs_to_print; - } - if (my $p = $provided_by->{$suite}) { - $str .= '
    '._g( 'also provided by: ' ). - join( ', ', map { "$_" } @$p); - } - $str .= "
  • \n"; - } elsif (my $p = $provided_by->{$suite}) { - $str .= sprintf( "
  • %s: "._g('Virtual package').'
    ', - make_url($pkg,'',$override), $suite ); - $str .= _g( 'provided by: ' ). - join( ', ', map { "$_" } @$p); + $version{architectures} = [ grep { !$archs_printed{$_} } sort keys %{$pkgs->{$suite}{$v}} ]; + push @{$suite{versions}}, \%version if @{$version{architectures}}; + + $archs_printed{$_}++ foreach @{$version{architectures}}; } + if (my $p = $provided_by->{$suite}) { + $suite{providers} = $p; + } + } elsif (my $p = $provided_by->{$suite}) { + $suite{desc} = _g('Virtual package'); + $suite{providers} = $p; + } + push @{$pkg{suites}}, \%suite if $suite{versions} || $suite{providers}; } - $str .= "
\n"; - return $str; + + return \%pkg; } -sub print_src_package { +sub process_src_package { my ($pkg, $pkgs, $archives, $sect, $subsect, $binaries) = @_; - my $str = '

'.sprintf( _g( 'Source package %s' ), $pkg ).'

'; - $str .= "
    \n"; + my %pkg = ( pkg => $pkg, + origins => [] ); + foreach my $suite (@SUITES) { foreach my $archive (@ARCHIVES) { if (exists $pkgs->{$suite}{$archive}) { - my $origin_str = ""; - if ($sect->{$suite}{$archive}{source}) { - $origin_str .= " ".marker($sect->{$suite}{$archive}{source}); - } - if ($archives->{$suite}{$archive}{source}) { - $origin_str .= " ".marker($archives->{$suite}{$archive}{source}); - } - $str .= sprintf( "
  • %s (%s): %s %s", - $suite.(($archive ne 'us')?"/$archive":''), $pkg, $suite.(($archive ne 'us')?"/$archive":''), $subsect->{$suite}{$archive}{source}, - $pkgs->{$suite}{$archive}, $origin_str ); - - $str .= "
    "._g( 'Binary packages: ' ); - my @bp_links; - foreach my $bp (@{$binaries->{$suite}{$archive}}) { - my $bp_link = sprintf( "%s", - $suite.(($archive ne 'us')?"/$archive":''), uri_escape( $bp ), $bp ); - push @bp_links, $bp_link; - } - $str .= join( ", ", @bp_links ); - $str .= "
  • \n"; + my %origin; + $origin{version} = $pkgs->{$suite}{$archive}; + $origin{suite} = $suite; + $origin{archive} = $archive; + $origin{section} = $sect->{$suite}{$archive}{source}; + $origin{subsection} = $subsect->{$suite}{$archive}{source}; + $origin{real_archive} = $archives->{$suite}{$archive}{source}; + + $origin{binaries} = $binaries->{$suite}{$archive}; + push @{$pkg{origins}}, \%origin; } } } - $str .= "
\n"; - return $str; + + return \%pkg; } 1; diff --git a/lib/Packages/DoSearchContents.pm b/lib/Packages/DoSearchContents.pm index 1a51ba3..f512ec4 100644 --- a/lib/Packages/DoSearchContents.pm +++ b/lib/Packages/DoSearchContents.pm @@ -16,11 +16,10 @@ use Packages::I18N::Locale; use Packages::Search qw( :all ); use Packages::CGI; use Packages::DB; -use Packages::Config qw( $DBDIR $SEARCH_URL $SEARCH_PAGE - @SUITES @ARCHIVES @ARCHITECTURES $ROOT ); +use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @ARCHITECTURES $ROOT ); sub do_search_contents { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_content) = @_; if ($params->{errors}{keywords}) { fatal_error( _g( "keyword not valid or missing" ) ); @@ -42,26 +41,12 @@ sub do_search_contents { fatal_error( sprintf( _g( "more than one suite specified for contents search (%s)" ), "@{$opts->{suite}}" ) ); } - $$menu = ""; - my @keywords = @{$opts->{keywords}}; my $mode = $opts->{mode} || ''; my $suite = $opts->{suite}[0]; my $archive = $opts->{archive}[0] ||''; $Packages::Search::too_many_hits = 0; - # for URL construction - my $keyword_esc = uri_escape( "@keywords" ); - my $suites_param = join ',', @{$params->{values}{suite}{no_replace}}; - my $sections_param = join ',', @{$params->{values}{section}{no_replace}}; - my $archs_param = join ',', @{$params->{values}{arch}{no_replace}}; - - # for output - my $keyword_enc = encode_entities "@keywords" || ''; - my $suites_enc = encode_entities( join( ', ', @{$params->{values}{suite}{no_replace}} ), '&<>"' ); - my $sections_enc = encode_entities( join( ', ', @{$params->{values}{section}{no_replace}} ), '&<>"' ); - my $archs_enc = encode_entities( join( ', ', @{$params->{values}{arch}{no_replace}} ), '&<>"' ); - my $st0 = new Benchmark; my (@results); @@ -110,61 +95,8 @@ sub do_search_contents { my $st1 = new Benchmark; my $std = timediff($st1, $st0); debug( "Search took ".timestr($std) ) if DEBUG; - } - - my $suite_wording = sprintf(_g("suite %s"), $suites_enc ); - my $section_wording = $sections_enc eq 'all' ? _g("all sections") - : sprintf(_g("section(s) %s"), $sections_enc ); - my $arch_wording = $archs_enc eq 'any' ? _g("all architectures") - : sprintf(_g("architecture(s) %s"), $archs_enc ); - my $wording = _g("paths that end with"); - if ($mode eq 'filename') { - $wording = _g("files named"); - } elsif ($mode eq 'exactfilename') { - $wording = _g("filenames that contain"); - } - msg( sprintf( _g("You have searched for %s %s in %s, %s, and %s." ), - $wording, $keyword_enc, - $suite_wording, $section_wording, $arch_wording ) ); - - if ($mode ne 'filename') { - msg( ''filename'}). - "\">"._g("Search within filenames").""); - } - if ($mode ne 'exactfilename') { - msg( ''exactfilename'}). - "\">"._g("Search exact filename").""); - } - if ($mode eq 'exactfilename' || $mode eq 'filename') { - msg( 'undef}). - "\">"._g("Search for paths ending with").""); - } - - msg( _g("Search in other suite:")." ". - join( ' ', map { '[$_}). - "\">$_]" } @SUITES ) ); - - if ($Packages::Search::too_many_hits) { - error( _g( "Your search was too wide so we will only display only the first about 100 matches. Please consider using a longer keyword or more keywords." ) ); - } - - %$html_header = ( title => _g( 'Package Contents Search Results' ), - lang => $opts->{lang}, - title_tag => _g( 'Debian Package Contents Search Results' ), - print_title => 1, - print_search_field => 'packages', - search_field_values => { - keywords => $keyword_enc, - searchon => 'contents', - arch => $archs_enc, - suite => $suites_enc, - section => $sections_enc, - exact => $opts->{exact}, - debug => $opts->{debug}, - }, - ); + } - $$page_content = ''; my (%results,%archs); foreach my $result (sort { $a->[0] cmp $b->[0] } @results) { my $file = shift @$result; @@ -180,52 +112,47 @@ sub do_search_contents { } my @all_archs = keys %archs; @all_archs = @ARCHITECTURES unless @all_archs; - debug( "all_archs = @all_archs", 1 ) if DEBUG; - msg(_g("Limit search to a specific architecture:")." ". - join( ' ', map { '[$_}). - "\">$_]" } @all_archs ) ) - unless (@{$opts->{arch}} == 1) || (@all_archs == 1); - msg(sprintf(_g('Search in all architectures'), - make_search_url('',"keywords=$keyword_esc",{arch=>undef}))) - if @{$opts->{arch}} == 1; + $page_content->{suite} = $suite; + $page_content->{archive} = $archive; + $page_content->{all_architectures} = \@all_archs; + $page_content->{all_suites} = \@SUITES; + $page_content->{mode} = $mode; + $page_content->{search_architectures} = $opts->{arch}; + $page_content->{search_keywords} = $opts->{keywords}; + $page_content->{sections} = $opts->{section}; + $page_content->{too_many_hits} = $Packages::Search::too_many_hits; - if (!@Packages::CGI::fatal_errors && !keys(%results)) { - error( _g( "Nothing found" ) ); - } + debug( "all_archs = @all_archs", 1 ) if DEBUG; if (keys %results) { - $$page_content .= "

".sprintf( _g( 'Found %s results' ), - scalar keys %results )."

"; - $$page_content .= '
\n"; - foreach my $file (sort keys %results) { - my $file_enc = encode_entities($file); - foreach my $kw (@{$opts->{keywords}}) { - my $kw_enc = encode_entities($kw); - $file_enc =~ s#(\Q$kw_enc\E)#$1#g; - } - $$page_content .= "\n"; + push @{$page_content->{results}}, \%result; } - $$page_content .= '\n" if @results > 20; - $$page_content .= '
'._g('File').''._g('Packages') - ."
/$file_enc"; - my @pkgs; + my $sort_func = sub { $_[0] cmp $_[1] }; + $sort_func = sub { (sort keys %{$results{$_[0]}})[0] + cmp + (sort keys %{$results{$_[1]}})[0] + } if $opts->{sort_by} eq 'pkg'; + + $page_content->{results} = []; + foreach my $file (sort {&$sort_func($a,$b)} keys %results) { + my %result; + $result{file} = "/$file"; + $result{packages} = []; foreach my $pkg (sort keys %{$results{$file}}) { my $arch_str = ''; my @archs = keys %{$results{$file}{$pkg}}; + my $arch_neg = 0; unless ($results{$file}{$pkg}{all} || (@archs == @all_archs)) { - if (@archs < @all_archs/2) { - $arch_str = ' ['.join(' ',sort @archs).']'; - } else { - $arch_str = ' ['._g('not').' '. - join(' ', grep { !$results{$file}{$pkg}{$_} } @all_archs).']'; + if (@archs >= @all_archs/2) { + @archs = grep { !$results{$file}{$pkg}{$_} } @all_archs; + $arch_neg = 1; } + } else { + @archs = (); } - push @pkgs, "$suite})."\">$pkg$arch_str"; + push @{$result{packages}}, { pkg => $pkg, architectures => \@archs, architectures_are_rev => $arch_neg }; } - $$page_content .= join( ", ", @pkgs); - $$page_content .= "
'._g('File').''._g('Packages')."
'; } } # sub do_search_contents diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm index 5b22552..62324a7 100644 --- a/lib/Packages/DoShow.pm +++ b/lib/Packages/DoShow.pm @@ -11,13 +11,12 @@ use Benchmark ':hireswallclock'; use Exporter; use Deb::Versions; -use Packages::Config qw( $DBDIR $ROOT @SUITES @ARCHIVES @SECTIONS - @ARCHITECTURES %FTP_SITES $SEARCH_URL ); +use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @SECTIONS + @ARCHITECTURES %FTP_SITES ); use Packages::I18N::Locale; -use Packages::CGI; +use Packages::CGI qw( :DEFAULT make_url make_search_url note ); use Packages::DB; use Packages::Search qw( :all ); -use Packages::HTML; use Packages::Page (); use Packages::SrcPage (); @@ -25,7 +24,7 @@ our @ISA = qw( Exporter ); our @EXPORT = qw( do_show ); sub do_show { - my ($params, $opts, $html_header, $menu, $page_content) = @_; + my ($params, $opts, $html_header, $page_contents) = @_; if ($params->{errors}{package}) { fatal_error( _g( "package not valid or not specified" ) ); @@ -37,20 +36,20 @@ sub do_show { fatal_error( sprintf( _g( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) ); } + my %contents; + $contents{make_url} = sub { return &Packages::CGI::make_url(@_) }; + my $pkg = $opts->{package}; - my $encodedpkg = uri_escape( $pkg ); + $contents{pkg} = $pkg; my $suite = $opts->{suite}[0]; + $contents{suite} = $suite; my $archive = $opts->{archive}[0] ||''; - my $DL_URL = "$pkg/download"; - my $FILELIST_URL = "$pkg/files"; - our (%packages_all, %sources_all); my (@results, @non_results); my $page = $opts->{source} ? new Packages::SrcPage( $pkg ) : new Packages::Page( $pkg ); - my $package_page = ""; my ($short_desc, $version, $section, $subsection) = ("")x5; my $st0 = new Benchmark; @@ -78,19 +77,13 @@ sub do_show { my $s = $_->[2]; $all_suites{$s}++; } - foreach (suites_sort(keys %all_suites)) { - if ($suite eq $_) { - $$menu .= "[ $_ ] "; - } else { - $$menu .= "[ $_})."\">$_ ] "; - } - } - $$menu .= '
'; + $contents{suites} = [ suites_sort(keys %all_suites) ]; unless (@results) { fatal_error( _g( "Package not available in this suite." ) ); } else { unless ($opts->{source}) { + for my $entry (@results) { debug( join(":", @$entry), 1 ) if DEBUG; my (undef, $archive, undef, $arch, $section, $subsection, @@ -110,8 +103,11 @@ sub do_show { unless ($page->is_virtual()) { $version = $page->{newest}; + $contents{version} = $version; my $source = $page->get_newest( 'source' ); $archive = $page->get_newest( 'archive' ); + $contents{archive} = $archive; + debug( "find source package: source=$source", 1) if DEBUG; my $src_data = $sources_all{"$archive $suite $source"}; $page->add_src_data( $source, $src_data ) @@ -123,10 +119,13 @@ sub do_show { my $did = $page->get_newest( 'description' ); my @tags = split(/, /, $page->get_newest( 'tag' )); + $contents{tags} = \@tags; + $section = $page->get_newest( 'section' ); + $contents{section} = $section; $subsection = $page->get_newest( 'subsection' ); - my $filenames = $page->get_arch_field( 'filename' ); - my $file_md5sums = $page->get_arch_field( 'md5sum' ); + $contents{subsection} = $subsection; + my $archives = $page->get_arch_field( 'archive' ); my $versions = $page->get_arch_field( 'version' ); my $sizes_inst = $page->get_arch_field( 'installed-size' ); @@ -145,149 +144,77 @@ 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;
-			my @menu = ( [ _g( "Distribution:" ),
-				       _g( "Overview over this suite" ),
-				       make_url("/",''),
-				       $suite ],
-				     [ _g( "Section:" ),
-				       _g( "All packages in this section" ),
-				       make_url("$subsection/",''),
-				       $subsection ], );
-			push @menu, [ _g( "Source:" ),
-				      _g( "Source package building this package" ),
-				      make_url($source,'',{source=>'source'}),
-				      $source ] if $source;
-			$$menu .= simple_menu( @menu );
+
+			$contents{desc} = { short => $short_desc,
+					    long => $long_desc, };
 
 			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 );
-			
-			if (my $provided_by = $page->{provided_by}) {
-			    note( _g( "This is also a virtual package provided by ").join( ', ', map { "$_"  } @$provided_by) );
-			}
-			
-			if ($suite eq "experimental") {
-			    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( _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 ); - $package_page .= ptags( $pkg, @tags ) if @tags; + $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; # # 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 .= "
\n"; - $package_page .= sprintf( "

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

\n", $pkg ); - - $package_page .= pdeplegend( [ 'dep', _g( 'depends' ) ], - [ 'rec', _g( 'recommends' ) ], - [ 'sug', _g( 'suggests' ) ], ); - - $package_page .= $dep_list; - $package_page .= "
\n"; - } + build_deps( \%packages, $opts, $pkg, + $page->get_dep_field('depends'), + 'depends', \%contents ); + build_deps( \%packages, $opts, $pkg, + $page->get_dep_field('recommends'), + 'recommends', \%contents ); + build_deps( \%packages, $opts, $pkg, + $page->get_dep_field('suggests'), + 'suggests', \%contents ); # # Download package # - my $encodedpack = uri_escape( $pkg ); - $package_page .= "
"; - $package_page .= sprintf( "

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

", - $pkg ) ; - $package_page .= "\n"; - $package_page .= "\n"; - $package_page .= "\n"; - $package_page .= ""; - $package_page .= "" - if $multiple_versions; - $package_page .= "\n"; + my @downloads; foreach my $a ( @archs ) { - $package_page .= "\n"; - $package_page .= "\n"; - $package_page .= "" - if $multiple_versions; - $package_page .= '\n\n"; + push @downloads, \%d; } - $package_page .= "
"._g("Download for all available architectures")."
"._g("Architecture").""._g("Version").""._g( "Package Size").""._g("Installed Size").""._g("Files")."
$a".$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 .= ""; + my %d = ( arch => $a, + pkgsize => sprintf( '%.1f', floor(($sizes_deb->{$a}/102.4)+0.5)/10 ), + instsize => $sizes_inst->{$a}, ); + + $d{version} = $versions->{$a} if $multiple_versions; if ( ($suite ne "experimental") && ($subsection ne 'debian-installer')) { - $package_page .= sprintf( "["._g( "list of files" )."]\n", - make_url("$encodedpkg/$a/filelist",''), $pkg ); - } else { - $package_page .= _g( "no current information" ); + $d{contents_avail} = 1; } - $package_page .= "
\n"; - $package_page .= "
\n"; + $contents{downloads} = \@downloads; # # more information # - $package_page .= pmoreinfo( name => $pkg, data => $page, - opts => $opts, - env => \%FTP_SITES, - bugreports => 1, sourcedownload => 1, - changesandcopy => 1, maintainers => 1, - search => 1 ); + moreinfo( name => $pkg, data => $page, vars => \%contents, + opts => $opts, + env => \%FTP_SITES, + bugreports => 1, sourcedownload => 1, + changesandcopy => 1, maintainers => 1, + search => 1 ); } else { # unless $page->is_virtual - $short_desc = _g( "virtual package" ); - - $$menu .= simple_menu( [ _g( "Distribution:" ), - _g( "Overview over this distribution" ), - make_url('/',''), - $suite ], - [ _g( "Section:" ), - _g( "All packages in this section" ), - make_url("virtual/",''), - - 'virtual' ], ); - - $package_page .= title( sprintf( _g( "Virtual Package: %s" ), - $pkg ) ); + $contents{is_virtual} = 1; + $contents{desc}{short} = _g( "virtual package" ); + $contents{subsection} = 'virtual'; my $policy_url = 'http://www.debian.org/doc/debian-policy/'; 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( "

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

", $pkg ); my $provided_by = $page->{provided_by}; - $package_page .= pkg_list( \%packages, $opts, $provided_by, 'en'); + $contents{providers} = []; + pkg_list( \%packages, $opts, $provided_by, 'en', $contents{providers} ); } # else (unless $page->is_virtual) } else { # unless $opts->{source} + $contents{is_source} = 1; + for my $entry (@results) { debug( join(":", @$entry), 1 ) if DEBUG; my (undef, $archive, undef, $section, $subsection, @@ -298,114 +225,64 @@ sub do_show { or debug( "Merging $pkg $version FAILED", 2 ) if DEBUG; } $version = $page->{version}; + $contents{version} = $version; my $st1 = new Benchmark; my $std = timediff($st1, $st0); debug( "Data search and merging took ".timestr($std) ) if DEBUG; $archive = $page->get_newest( 'archive' ); + $contents{archive} = $archive; $section = $page->get_newest( 'section' ); + $contents{section} = $section; $subsection = $page->get_newest( 'subsection' ); - - $$menu .= simple_menu( [ _g( "Distribution:" ), - _g( "Overview over this suite" ), - make_url('/',''), - $suite ], - [ _g( "Section:" ), - _g( "All packages in this section" ), - make_url("$subsection/",''), - $subsection ], - ); + $contents{subsection} = $subsection; - 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 - $title .= " ".marker( $section ) if $section ne 'main'; - $package_page .= title( $title ); - - if ($suite eq "experimental") { - 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( _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 .= _g( "The following binary packages are built from this source package:" ); - $package_page .= pkg_list( \%packages, $opts, $binaries, 'en' ); - $package_page .= '
'; + $contents{binaries} = []; + pkg_list( \%packages, $opts, $binaries, 'en', $contents{binaries} ); } # # display dependencies # - my $dep_list; - $dep_list = print_deps( \%packages, $opts, $pkg, - $page->get_dep_field('build-depends'), - 'build-depends' ); - $dep_list .= print_deps( \%packages, $opts, $pkg, - $page->get_dep_field('build-depends-indep'), - 'build-depends-indep' ); - - if ( $dep_list ) { - $package_page .= "
\n"; - $package_page .= sprintf( "

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

\n", $pkg ); - - $package_page .= pdeplegend( [ 'adep', _g( 'build-depends' ) ], - [ 'idep', _g( 'build-depends-indep' ) ], - ); - - $package_page .= $dep_list; - $package_page .= "
\n"; - } + build_deps( \%packages, $opts, $pkg, + $page->get_dep_field('build-depends'), + 'build-depends', \%contents ); + build_deps( \%packages, $opts, $pkg, + $page->get_dep_field('build-depends-indep'), + 'build-depends-indep', \%contents ); # # Source package download # - $package_page .= "
\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( ''. - "", - _g("File"), - _g("Size (in kB)"), - _g("md5sum") ); + $contents{srcfiles} = []; foreach( @$source_files ) { my ($src_file_md5, $src_file_size, $src_file_name) = split /\s+/, $_; (my $server = lc $archive) =~ s/-//go; # non-US hack - my $src_url = $FTP_SITES{$server} + $server = $FTP_SITES{$server} || $FTP_SITES{us}; - $src_url .= "/$source_dir/$src_file_name"; + my $path = "/$source_dir/$src_file_name"; - $package_page .= "\n" - ."\n" - .""; + push @{$contents{srcfiles}}, { server => $server, path => $path, filename => $src_file_name, + size => sprintf("%.1f", (floor(($src_file_size/102.4)+0.5)/10)), + md5sum => $src_file_md5 }; } - $package_page .= "
%s%s%s
$src_file_name".sprintf("%.1f", (floor(($src_file_size/102.4)+0.5)/10))."$src_file_md5
\n"; - $package_page .= "
\n"; # # more information # - $package_page .= pmoreinfo( name => $pkg, data => $page, - opts => $opts, - env => \%FTP_SITES, - bugreports => 1, - changesandcopy => 1, maintainers => 1, - search => 1, is_source => 1 ); + moreinfo( name => $pkg, data => $page, vars => \%contents, + opts => $opts, + env => \%FTP_SITES, + bugreports => 1, + changesandcopy => 1, maintainers => 1, + search => 1, is_source => 1 ); } # else (unless $opts->{source}) } # else (unless @results) @@ -413,33 +290,174 @@ sub do_show { } # use Data::Dumper; -# debug( "Final page object:\n".Dumper($page), 3 ) if DEBUG; - - my $title = $opts->{source} ? - _g( "Details of source package %s in %s" ) : - _g( "Details of package %s in %s" ) ; - my $title_tag = $opts->{source} ? - _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, - keywords => "$suite, $archive, $section, $subsection, $version", - title_tag => sprintf( $title_tag, $pkg, $suite ), - print_search_field => 'packages', - search_field_values => { - keywords => '', - searchon => $opts->{source} ? 'sourcenames' : 'names', - arch => 'any', - suite => 'all', - section => 'all', - exact => 0, - debug => $opts->{debug}, - }, - ); - - $$page_content = $package_page; +# debug( "Final page object:\n".Dumper(\%contents), 3 ) if DEBUG; + + %$page_contents = %contents; +} + +sub moreinfo { + my %info = @_; + + my $name = $info{name} or return; + my $env = $info{env} or return; + my $opts = $info{opts} or return; + my $page = $info{data} or return; + my $contents = $info{vars} or return; + my $is_source = $info{is_source}; + my $suite = $opts->{suite}[0]; + + my $source = $page->get_src( 'package' ); + my $source_version = $page->get_src( 'version' ); + my $src_dir = $page->get_src('directory'); + if ($info{sourcedownload}) { + $contents->{src}{url} = make_url($source,'',{source=>'source'}); + $contents->{src}{pkg} = $source; + + my @downloads; + my $files = $page->get_src( 'files' ); + if (defined($files) and @$files) { + foreach( @$files ) { + my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_; + my ($name, $server, $path); + # non-US hack + ($server = lc $page->get_newest('archive')) =~ s/-//go; + $server = $env->{$server}||$env->{us}; + $path = "$src_dir/$src_file_name"; + if ($src_file_name =~ /dsc$/) { + $name = 'dsc' + } else { + $name = $src_file_name; + } + push @downloads, { name => $name, server => $server, path => $path }; + } + } + $contents->{src}{downloads} = \@downloads; + } + + if ($info{changesandcopy}) { + if ( $src_dir ) { + (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" ); + } + } + + if ($info{maintainers}) { + my $uploaders = $page->get_src( 'uploaders' ); + if ($uploaders && @$uploaders) { + my @maintainers = map { { name => $_->[0], mail => $_->[1] } } @$uploaders; + $contents->{maintainers} = \@maintainers; + } + } + +} + +sub providers { + my ($suite, $entry, $also) = @_; + my %tmp = map { $_ => 1 } split /\s/, $entry; + my @provided_by = keys %tmp; # weed out duplicates + my %out = ( also => $also, + pkgs => \@provided_by ); + return \%out; +} + +sub build_deps { + my ( $packages, $opts, $pkg, $relations, $type, $contents) = @_; + my %dep_type = ('depends' => 'dep', 'recommends' => 'rec', + 'suggests' => 'sug', 'build-depends' => 'adep', + 'build-depends-indep' => 'idep' ); + my $suite = $opts->{suite}[0]; + + my %out = ( id => $dep_type{$type}, terms => [] ); + +# use Data::Dumper; +# debug( "print_deps called:\n".Dumper( $pkg, $relations, \$type ), 3 ) if DEBUG; + + foreach my $rel (@$relations) { + my %rel_out; + $rel_out{is_old_pkgs} = $rel->[0]; + $rel_out{alternatives} = []; + + foreach my $rel_alt ( @$rel ) { + next unless ref($rel_alt); + my ( $p_name, $pkg_version, $arch_neg, + $arch_str, $subsection, $available ) = @$rel_alt; + + if ($arch_str ||= '') { + if ($arch_neg) { + $arch_str = _g("not")." $arch_str"; + } else { + $arch_str = $arch_str; + } + } + + my %rel_alt_out = ( name => $p_name, + version => $pkg_version, + arch_str => $arch_str, + arch_neg => $arch_neg ); + + my @results; + my %entries; + my $entry = $entries{$p_name} || + read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite); + my $short_desc = $entry->[-1]; + my $arch = $entry->[3]; + my $archive = $entry->[1]; + my $p_suite = $entry->[2]; + if ( $short_desc ) { + $rel_alt_out{desc} = $short_desc; + $rel_alt_out{suite} = $p_suite; + if ( $rel_out{is_old_pkgs} ) { + } elsif (defined $entry->[1]) { + $entries{$p_name} ||= $entry; + $rel_alt_out{providers} = providers( $p_suite, + $entry->[0], + 1 ) if defined $entry->[0]; + } elsif (defined $entry->[0]) { + $rel_alt_out{desc} = undef; + $rel_alt_out{providers} = providers( $p_suite, + $entry->[0] ); + #FIXME: we don't handle virtual packages from + # the fallback suite correctly here + $rel_alt_out{suite} = $suite; + } + } elsif ( $rel_out{is_old_pkgs} ) { + } else { + $rel_alt_out{desc} = _g( "Package not available" ); + $rel_alt_out{suite} = ''; + } + push @{$rel_out{alternatives}}, \%rel_alt_out; + } + + push @{$out{terms}}, \%rel_out; + } + + $contents->{relations} ||= []; + push @{$contents->{relations}}, \%out if @{$out{terms}}; +} # end print_deps + +sub pkg_list { + my ( $packages, $opts, $pkgs, $lang, $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]; + + if ( $short_desc ) { + push @$list, { name => $p, desc => $short_desc, available => 1 }; + } else { + push @$list, { name => $p, desc => _g("Not available") }; + } + } } + 1; diff --git a/lib/Packages/HTML.pm b/lib/Packages/HTML.pm deleted file mode 100644 index e0814a7..0000000 --- a/lib/Packages/HTML.pm +++ /dev/null @@ -1,593 +0,0 @@ -package Packages::HTML; - -use strict; -use warnings; - -use Exporter; -use URI::Escape; -use HTML::Entities; -use Locale::gettext; - -use Packages::CGI qw(make_url make_search_url); -use Packages::Search qw( read_entry_simple ); -use Packages::Config qw( :all ); - -#use Packages::Util; -use Packages::I18N::Locale; -use Packages::I18N::Languages; -use Packages::I18N::LanguageNames; -#use Generated::Strings qw( gettext dgettext ); - -our @ISA = qw( Exporter ); -our @EXPORT = qw( header title trailer file_changed time_stamp - read_md5_hash write_md5_hash simple_menu - ds_begin ds_item ds_end title marker pdesc ptags - pdeplegend pkg_list pmoreinfo print_deps print_src_deps ); - -our $CHANGELOG_URL = '/changelogs'; - -sub img { - my ( $root, $url, $src, $alt, %attr ) = @_; - my @attr; - - foreach my $a ( keys %attr ) { - push @attr, "$a=\"$attr{$a}\""; - } - - return "\"$alt\""; -} - -sub simple_menu { - my $str = ""; - foreach my $entry (@_) { - $str .= "[ $entry->[0] [1]\" href=\"$entry->[2]\">$entry->[3] ]\n"; - } - return $str; -} - -sub title { - return "

$_[0]

\n"; -} - -sub marker { - return "[$_[0]]"; -} - -sub pdesc { - my ( $short_desc, $long_desc ) = @_; - my $str = ""; - - $str .= "
\n"; - $str .= "

$short_desc

\n"; - - $str .= "

$long_desc\n"; - $str .= "

\n"; - - return $str; -} - -sub ptags { - my ( $package, @tags ) = @_; - my $str = ""; - - $str .= "
\n

"; - $str .= "Tags:\n"; - foreach my $tag (@tags) { - $str .= "$tag\n"; - } - $str .= "

\n
\n"; - - return $str; -} - -sub pdeplegend { - my $str = "\n"; - - foreach my $entry (@_) { - $str .= ""; - } - - $str .= "\n
[0].gif\" alt=\"[$entry->[0]]\" width=\"16\" height=\"16\">= $entry->[1]
\n"; - return $str; -} - -sub pkg_list { - my ( $packages, $opts, $pkgs, $lang ) = @_; - my $suite = $opts->{suite}[0]; - - my $str = ""; - 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]; - - if ( $short_desc ) { - $str .= "
undef})."\">$p
\n". - "\t
$short_desc
\n"; - } else { - $str .= "
$p
\n\t
"._g("Not available")."
\n"; - } - } - if ($str) { - $str = "
$str
\n"; - } - - return $str; -} - -sub pmoreinfo { - my %info = @_; - - my $name = $info{name} or return; - my $env = $info{env} or return; - my $opts = $info{opts} or return; - my $page = $info{data} or return; - my $is_source = $info{is_source}; - my $suite = $opts->{suite}[0]; - - my $str = "
"; - $str .= sprintf( "

"._g( "More Information on %s" )."

", - $name ); - - if ($info{bugreports}) { - my $bug_url = $is_source ? $SRC_BUG_URL : $BUG_URL; - $str .= "

\n".sprintf( _g( "Check for Bug Reports about %s." )."
\n", - $bug_url.$name, $name ); - } - - my $source = $page->get_src( 'package' ); - my $source_version = $page->get_src( 'version' ); - my $src_dir = $page->get_src('directory'); - if ($info{sourcedownload}) { - my $files = $page->get_src( 'files' ); - $str .= _g( "Source Package:" ); - $str .= " 'source'})."\">$source, ". - _g( "Download" ).":\n"; - - unless (defined($files) and @$files) { - $str .= _g( "Not found" ); - } else { - foreach( @$files ) { - my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_; - # non-US hack - (my $server = lc $page->get_newest('archive')) =~ s/-//go; - $str .= sprintf("[", - $env->{$server}||$env->{us}); - if ($src_file_name =~ /dsc$/) { - $str .= "dsc"; - } else { - $str .= $src_file_name; - } - $str .= "]\n"; - } - } -# $package_page .= sprintf( _g( " (These sources are for version %s)\n" ), $src_version ) -# if ($src_version ne $version) && !$src_version_given_in_control; - } - - if ($info{changesandcopy}) { - if ( $src_dir ) { - (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; - $str .= "
".sprintf( _g( 'View the Debian changelog' ), - "$CHANGELOG_URL/$src_dir/$src_basename/changelog" )."
\n"; - my $copyright_url = "$CHANGELOG_URL/$src_dir/$src_basename/"; - $copyright_url .= ( $is_source ? 'copyright' : "$name.copyright" ); - - $str .= sprintf( _g( 'View the copyright file' ), - $copyright_url )."

"; - } - } - - if ($info{maintainers}) { - my $uploaders = $page->get_src( 'uploaders' ); - if ($uploaders && @$uploaders) { - foreach (@$uploaders) { - $_->[0] = encode_entities( $_->[0], '&<>' ); - } - my ($maint_name, $maint_mail) = @{shift @$uploaders}; - unless (@$uploaders) { - $str .= "

\n".sprintf( _g( "%s is responsible for this Debian package." ). - "\n", - "$maint_name" - ); - } else { - my $up_str = "$maint_name"; - my @uploaders_str; - foreach (@$uploaders) { - push @uploaders_str, "[1]\">$_->[0]"; - } - my $last_up = pop @uploaders_str; - $up_str .= ", ".join ", ", @uploaders_str if @uploaders_str; - $up_str .= sprintf( _g( " and %s are responsible for this Debian package." ), $last_up ); - $str .= "

\n$up_str "; - } - } - - $str .= sprintf( _g( "See the developer information for %s." )."

", $QA_URL.$source, $name ) if $source; - } - - if ($info{search}) { - my $encodedname = uri_escape( $name ); - my $search_url = $is_source ? "$ROOT/source" : $ROOT; - $str .= "

".sprintf( _g( "Search for other versions of %s" ), - "$search_url/$encodedname", $name )."

\n"; - } - - $str .= "
\n"; - return $str; -} - -sub dep_item { - my ( $suite, $name, $info, $desc ) = @_; - my ($link, $post_link) = ('', ''); - if ($suite) { - $link = "$suite,source=>undef})."\">"; - $post_link = ''; - } - if ($info) { - $info = " $info"; - } else { - $info = ''; - } - if ($desc) { - $desc = "
$desc
"; - } else { - $desc = ''; - } - - return "$link$name$post_link$info$desc"; -} # end dep_item - -sub provides_string { - my ($suite, $entry, $also) = @_; - my %tmp = map { $_ => 1 } split /\s/, $entry; - my @provided_by = keys %tmp; # weed out duplicates - my $short_desc = $also ? _g("also a virtual package provided by ") - : _g("virtual package provided by "); - if (@provided_by < 10) { - $short_desc .= join( ', ',map { "$suite,source=>undef})."\">$_" } @provided_by); - } else { - $short_desc .= sprintf( _g("%s packages"), scalar(@provided_by)); - } - return $short_desc; -} - -sub print_deps { - my ( $packages, $opts, $pkg, $relations, $type) = @_; - my %dep_type = ('depends' => 'dep', 'recommends' => 'rec', - 'suggests' => 'sug', 'build-depends' => 'adep', - 'build-depends-indep' => 'idep' ); - my $res = "
    \n"; - my $first = 1; - my $suite = $opts->{suite}[0]; - -# use Data::Dumper; -# debug( "print_deps called:\n".Dumper( $pkg, $relations, \$type ), 3 ) if DEBUG; - - foreach my $rel (@$relations) { - my $is_old_pkgs = $rel->[0]; - my @res_pkgs = (); - - if ($is_old_pkgs) { - $res .= "
    "; - } else { - if ($first) { - $res .= "
  • "; - $first = 0; - } else { - $res .= "
  • \n
  • "; - } - $res .= "
    \"[$dep_type{$type}]\" "; - } - - foreach my $rel_alt ( @$rel ) { - next unless ref($rel_alt); - my ( $p_name, $pkg_version, $arch_neg, - $arch_str, $subsection, $available ) = @$rel_alt; - - if ($arch_str ||= '') { - if ($arch_neg) { - $arch_str = " ["._g("not")." $arch_str]"; - } else { - $arch_str = " [$arch_str]"; - } - } - $pkg_version = "($pkg_version)" if $pkg_version ||= ''; - - my @results; - my %entries; - my $entry = $entries{$p_name} || - read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite); - my $short_desc = $entry->[-1]; - my $arch = $entry->[3]; - my $archive = $entry->[1]; - my $p_suite = $entry->[2]; - if ( $short_desc ) { - if ( $is_old_pkgs ) { - push @res_pkgs, dep_item( $p_suite, - $p_name, "$pkg_version$arch_str" ); - } elsif (defined $entry->[1]) { - $entries{$p_name} ||= $entry; - $short_desc = encode_entities( $short_desc, "<>&\"" ); - $short_desc .= "
    ".provides_string( $p_suite, - $entry->[0], - 1 ) - if defined $entry->[0]; - push @res_pkgs, dep_item( $p_suite, - $p_name, "$pkg_version$arch_str", $short_desc ); - } elsif (defined $entry->[0]) { - $short_desc = provides_string( $p_suite, - $entry->[0] ); - #FIXME: we don't handle virtual packages from - # the fallback suite correctly here - push @res_pkgs, dep_item( $suite, - $p_name, "$pkg_version$arch_str", $short_desc ); - } - } elsif ( $is_old_pkgs ) { - push @res_pkgs, dep_item( undef, $p_name, "$pkg_version$arch_str" ); - } else { - my $short_desc = _g( "Package not available" ); - push @res_pkgs, dep_item( undef, $p_name, "$pkg_version$arch_str", $short_desc ); - } - - } - - $res .= "\n".join( "
    "._g( "or" )." ", @res_pkgs )."\n"; - } - if (@$relations) { - $res .= "
  • \n"; - $res .= "
\n"; - } else { - $res = ""; - } - return $res; -} # end print_deps - -my $ds_begin = '
'; -my $ds_item_desc = '
'; -my $ds_item = ':
'; -my $ds_item_end = '
'; -my $ds_end = '
'; -# my $ds_begin = ''; -# my $ds_item_desc = ''; -# my $ds_end = '
'; -# my $ds_item = ''; -# my $ds_item_end = '
'; - -sub ds_begin { - return $ds_begin; -} -sub ds_item { - return "$ds_item_desc$_[0]$ds_item$_[1]$ds_item_end\n"; -} -sub ds_end { - return $ds_end; -} - -sub header { - my (%params) = @_; - - my $DESC_LINE; - if (defined $params{desc}) { - $DESC_LINE = ""; - } - else { - $DESC_LINE = ''; - } - - my $title_keywords = $params{title_keywords} || $params{title} || ''; - my $title_tag = $params{title_tag} || $params{title} || ''; - my $title_in_header = $params{page_title} || $params{title} || ''; - my $page_title = $params{page_title} || $params{title} || ''; - my $meta = $params{meta} || ''; - - my $search_in_header = ''; - $params{print_search_field} ||= ""; - if ($params{print_search_field} eq 'packages') { - my %values = %{$params{search_field_values}}; - my %checked_searchon = ( names => "", - all => "", - sourcenames => "", - contents => ""); - $checked_searchon{$values{searchon}} = "checked=\"checked\""; - $checked_searchon{names} = "checked=\"checked\"" - if $values{searchon} eq 'default'; - $search_in_header = < -
- - -%s -
-
%s - -   - - -
- - - - -
-
- -MENU -; - $search_in_header = sprintf( $search_in_header, - _g( 'Search' ), - _g( 'Full options' ), - _g( 'Search on:'), - _g( 'Package Names' ), - _g( 'Descriptions' ), - _g( 'Source package names' ), - _g( 'Package contents' )); -# } elsif ($params{print_search_field} eq 'contents') { -# my %values = %{$params{search_field_values}}; -# my %checked_searchmode = ( searchfiles => "", -# searchfilesanddirs => "", -# searchword => "", -# filelist => "", ); -# $checked_searchmode{$values{searchmode}} = "checked=\"checked\""; -# $search_in_header = < -#
-# -# -# -# -#   -# -# Full options -#
-#
Display: -# -# -# -# -#
-# -# -# -# -#
-#
-# -# MENU -# ; - } - - my $keywords = $params{keywords} || ''; - my $KEYWORDS_LINE = ""; - - my $LANG = $params{lang}; - my $charset = get_charset($LANG); - my $txt = < - - -Debian -- $title_tag - - - -$KEYWORDS_LINE -$DESC_LINE -$meta - - - - - + + diff --git a/templates/html/head.tmpl b/templates/html/head.tmpl new file mode 100644 index 0000000..31cc40b --- /dev/null +++ b/templates/html/head.tmpl @@ -0,0 +1,72 @@ + + + +[% organisation %] -- [% title_tag %] + + + + + +[% html_meta %] + + + + + + +
+
+ +[%- IF page_title %] +

[% page_title %]

+ [%- PROCESS 'html/messages.tmpl' -%] +[% END -%] diff --git a/templates/html/index.tmpl b/templates/html/index.tmpl new file mode 100644 index 0000000..8985294 --- /dev/null +++ b/templates/html/index.tmpl @@ -0,0 +1,41 @@ +[% PROCESS 'config/archive_layout.tmpl' %] +[% pkg_type = is_source ? 'Source' : 'Software'; + title_common = category ? "$pkg_type Packages in \"$suite\", $category.id $category.name" + : "$pkg_type Packages in \"$suite\""; + IF category; + navigation_pre = [ { prefix=>'Distribution:', title=>'Overview over this suite', url=>"../", name=>suite }, + { prefix=>"$category.id:", name=>category.name } ]; + ELSE; + navigation_pre = [ { prefix=>'Distribution:', title=>'Overview over this suite', url=>"index", name=>suite }, + { name=>'All Packages' } ]; + END +%] +[% PROCESS 'html/head.tmpl' + title_tag = title_common + page_title = title_common + keywords = "$suite, $category.name" + navigation = navigation_pre +%] + +[% FOREACH packages %] + [% '
' IF loop.first %] + + [% BLOCK marker %] [[% text %]] [%- END %] + [% BLOCK markers %] + [% PROCESS marker text=section IF section != main_section %] + [% PROCESS marker text=archive IF archive != main_archive %] + [% END %] + [% IF providers.size %] +
[% name %]
+
virtual package provided by [% FOREACH provider IN providers %][% provider %][% END %]
+ [% IF versions.length %] +
[% name %] ([% versions %])[% PROCESS markers %]
+
[% desc | html %]
+ [% END %] + [% ELSE %] +
[% name %] ([% versions %])[% PROCESS markers %]
+
[% desc | html %]
+ [% END %] + + [% '
' IF loop.last %] +[% END %] diff --git a/templates/html/menu.inc b/templates/html/menu.inc new file mode 100644 index 0000000..aa9c43d --- /dev/null +++ b/templates/html/menu.inc @@ -0,0 +1,10 @@ +[% BLOCK menuitem -%] + [ [% prefix -%] + [%- IF url -%] + [% name %] + [%- ELSE -%] + [% name %] + [%- END -%] +  ] +[%- END -%] +[% BLOCK marker %] [[% text %]] [%- END %] diff --git a/templates/html/messages.tmpl b/templates/html/messages.tmpl new file mode 100644 index 0000000..3d8b6a6 --- /dev/null +++ b/templates/html/messages.tmpl @@ -0,0 +1,31 @@ + +[%- FOREACH error IN errors %] +[%- '
' IF loop.first %] +

[% error %]

+[% '
' IF loop.last -%] +[% END -%] +[%- FOREACH debug IN debugs %] +[%- '

Debugging:

' IF loop.first -%]
+[% debug %]
+[% '
' IF loop.last -%] +[% END -%] +[%- FOREACH hint IN hints %] +[%- '
' IF loop.first %] +

[% hint %]

+[% '
' IF loop.last -%] +[% END -%] +[%- FOREACH msg IN msgs %] +[%- '
' IF loop.first %] +

[% msg %]

+[% '
' IF loop.last -%] +[% END -%] +[%- FOREACH note IN notes %] +[%- '
' IF loop.first %] +[%- IF note.1 %] +

[% note.0 %]

+

[% note.1 %]

+[% ELSE %] +

[% note.0 %]

+[% END -%] +[% '
' IF loop.last -%] +[% END -%] diff --git a/templates/html/newpkg.tmpl b/templates/html/newpkg.tmpl new file mode 100644 index 0000000..0586a6e --- /dev/null +++ b/templates/html/newpkg.tmpl @@ -0,0 +1,31 @@ +[%- PROCESS 'html/head.tmpl' + title_tag = "New Packages in \"$suite\"" + description = desc + keywords = "$suite, new packages, $section" + html_meta = '' +-%] +

New Packages in "[% suite %]"

+ +

The following packages were added to suite [% suite %][% " (section $section)" IF section %] in the [% organisation %] archive during the last 7 days.

+

This information is also available as an RSS feed +[RSS 1.0 Feed]

+ +[% FOREACH pkg IN new_packages %] + [% '
    ' IF loop.first %] +
  • [% pkg.0 %] + -- [% pkg.-1 | html %][% " ($pkg.1 days old)" IF pkg.1 %] + [% '
' IF loop.last %] +[% END %] + +

All packages
+(compact compressed textlist)
+ New packages in +[% FOREACH s IN sections %] + [%- IF s == section -%] +[% s %] + [%- ELSE -%] +[% s %] + [%- END -%] +[% ', ' UNLESS loop.last %] +[% END %] +

\ No newline at end of file diff --git a/templates/html/search.tmpl b/templates/html/search.tmpl new file mode 100644 index 0000000..69c9db0 --- /dev/null +++ b/templates/html/search.tmpl @@ -0,0 +1,51 @@ +[%- PROCESS 'config/archive_layout.tmpl' -%] +[%- PROCESS 'html/head.tmpl' + title_tag = 'Debian Package Search Results' + print_search_field = 'packages' + navigation = [ { name => 'Package Search Results' } ] +-%] + +[%- PROCESS 'html/messages.tmpl' -%] + +
+

Found [% results %] matching packages.

+[% FOREACH categories %] + [% "

$name

" IF name %] + +[% FOREACH packages %] +

Package [% pkg %]

+
    + [% FOREACH s IN suites %] +
  • [% s.suite %][% ' (' _ s.subsect _ ')' IF s.subsect %]: [% s.desc %] [%- IF s.section %] [[% s.section %]][% END %] + [% FOREACH s.versions %] +
    [% version %] [%- IF archive != main_archive %] [[% archive %]][% END %]: [% architectures.join(' ') %] + [% END %] + [% IF s.providers %] +
    [% 'also ' IF s.versions.size > 0 %]provided by: [% FOREACH provider IN s.providers %][% provider %][% ', ' UNLESS loop.last %][% END %] + [% END %] +
  • + [% END %] +
+[% END %] + +[% FOREACH src_packages %] +

Source Package [% pkg %]

+
    + [% FOREACH origins %] + [% origin = (archive == 'us') ? suite : "$suite/$archive" %] +
  • [% origin %] ([% subsection %]): [% version %] + [%- IF section %] [[% section %]][% END %] + [%- IF real_archive %] [[% real_archive %]][% END %] +
    Binary packages: [% FOREACH binary IN binaries %][% binary %][% ', ' UNLESS loop.last %][% END %] +
  • + [% END %] +
+[% END %] + +[% END %] + +[% IF skipped %] +

[% skipped %] results have not been displayed because you requested only exact matches. +[% END %] + +

diff --git a/templates/html/search_contents.tmpl b/templates/html/search_contents.tmpl new file mode 100644 index 0000000..7b794ac --- /dev/null +++ b/templates/html/search_contents.tmpl @@ -0,0 +1,123 @@ +[%- PROCESS 'html/head.tmpl' + title_tag = "$organisation Package Contents Search Results" + keywords = "$suite" + print_search_field = 'packages' + navigation = [ { title => '', name => 'Packages Contents Search Results', url => '' } ] + search_field_values = { + keywords => search_keywords.join(' '), + searchon => 'contents', + mode => mode, + sort_by => sort_by, + suite => suite, + architectures => params.values.arch.no_replace.join(','), + sections => params.values.section.no_replace.join(','), + } +-%] + +[% keyword_str = search_keywords.join(' '); + keyword_esc = uri_escape(keyword_str); + keyword_enc = html_encode(keyword_str); + + section_str = params.values.section.no_replace.join(', '); + section_esc = uri_escape(section_str); + section_enc = html_encode(section_str); + + architectures_str = params.values.arch.no_replace.join(', '); + architectures_esc = uri_escape(architectures_str); + architectures_enc = html_encode(architectures_str); +%] +
+ + + +

Search in other suite: +[% FOREACH s IN all_suites %] +[[% s %]] +[% END %] + +[% UNLESS search_architectures.size == 1 || all_architectures.size == 1 %] +

Limit search to a specific architecture: +[% FOREACH a IN all_architectures %] [[% a %]][% END %] +[% END %] + +[% IF search_architectures.size == 1 %] +

Search in all architectures +[% END %] + +

+ +[%- PROCESS 'html/messages.tmpl' -%] +
+ +[% suite_wording = "suite $suite"; + section_wording = ( section_enc == 'all' ? "all sections" : "section(s) $section_enc" ); + arch_wording = ( architectures_enc == 'any' ? "all architectures" : "architecture(s) $architectures_enc" ); + wording = "paths that end with"; + IF mode == 'filename'; + wording = "files named"; + ELSIF mode == 'exactfilename'; + wording = "filenames that contain"; + END %] +

You have searched for [% wording %] [% keyword_enc %] in [% suite_wording %], [% section_wording %], and [% arch_wording %]. + +[% IF results %] +Found [% results.size %] results. + +[% IF too_many_hits %] +

Note: Your search was too wide so we will only display only the first about 100 matches. +Please consider using a longer keyword or more keywords.

+[% END %] + + + + + + + + + + +[% FOREACH results %] +[% file = html_encode(file); + FOREACH k IN search_keywords; + k_enc = html_encode(k); + k_quo = quotemeta(k); + file = file.replace(k_quo, "$k_enc"); + END %] + + + + +[% END %] + +[% IF results.size > 20 %] + +[% END %] +
FilePackages
[% file %] + [% FOREACH packages %] + [% arch_str = architectures.join(', '); + SET arch_str = "not $arch_str" IF ( arch_str && architectures_are_rev ); + SET arch_str = " [$arch_str]" IF arch_str; + pkg_esc = uri_escape(pkg) %] + [% pkg | html %][% arch_str %][% ', ' UNLESS loop.last %] + [% END %] +
FilePackages
+
+ +[% ELSE %] + +

Sorry, your search gave no results

+ +[% END %] diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl new file mode 100644 index 0000000..4a51464 --- /dev/null +++ b/templates/html/show.tmpl @@ -0,0 +1,246 @@ +[% PROCESS 'config/archive_layout.tmpl' %] +[%- PROCESS 'html/head.tmpl' + title_tag = ( is_source ? "Details of source package $pkg in $suite" + : "Details of package $pkg in $suite" ) + description = desc + keywords = "$suite, $archive, $section, $subsection, $version" + print_search_field = 'packages' + search_field_values = { + keywords => '', + searchon => is_source ? 'sourcenames' : 'names', + arch => 'any', + suite => 'all', + section => 'all', + exact => 0 + } + navigation = [ { prefix=>'Distribution:', title=>'Overview over this suite', url=>make_url('/'), name=>suite }, + { prefix=>'Section:', title=>'All packages in this section', url=>make_url("$subsection/"), name=>subsection }, + { prefix=>'Package:', name=>pkg } ] +-%] + +[% PROCESS 'html/menu.inc' %] +[% FOREACH s IN suites %] + [% '
' IF loop.first %] + [%- IF s == suite -%] + [% PROCESS menuitem name=s url='' %] + [%- ELSE -%] + [% PROCESS menuitem name=s url=make_url(pkg,'','suite',s) %] + [%- END -%] + [%- '
' IF loop.last -%] +[% END %] +
+ +[% IF src %] +
+[% PROCESS menuitem prefix='Source:' title='Source package building this package' url=make_url(src.pkg,'','source','source') name=src.pkg %] +
+[% END %] + +[%- PROCESS 'html/messages.tmpl' -%] + +[% IF is_virtual %] +

Virtual Package: [% pkg %] +[% ELSIF is_source %] +

Source Package: [% pkg %] ([% version %]) +[% ELSE %] +

Package: [% pkg %] ([% versions.short %]) +[% END %] +[%- PROCESS marker text=archive IF archive && archive != main_archive %] +[%- PROCESS marker text=subsection IF subsection == 'non-US' and archive != 'non-US' %] +[%- PROCESS marker text=section IF section && section != main_section %]

+ +[% IF suite == "experimental" || subsection == "debian-installer" %] +
+[% IF suite == "experimental" %] +

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. +Please be sure to consult the changelog and other possible documentation before +using it.

+[% END %] +[% IF subsection == "debian-installer" %] +

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.

+[% END %] +
+[% END %] + +[% UNLESS is_virtual %] +
+

[% desc.short %]

+

[% desc.long %] +

+[% END %] + +[% FOREACH tag IN tags %] + [% IF loop.first -%] +

+ Tags: + [%- END %] + [% tag %][% ', ' UNLESS loop.last %] + [% IF loop.last -%] +

+
+ [%- END %] +[% END %] + +[% FOREACH providers %] + [% IF loop.first %]

Packages providing [% pkg %]

[% END %] +
[% IF available %][% name %][% ELSE %][% name %][% END %]
+
[% desc %]
+ [% '
' IF loop.last %] +[% END %] + +[% FOREACH binaries %] + [% IF loop.first %]
The following binary packages are built from this source package:
[% END %] +
[% IF available %][% name %][% ELSE %][% name %][% END %]
+
[% desc %]
+ [% '
' IF loop.last %] +[% END %] + +[% FOREACH relations %] + [% IF loop.first -%] +
+

Other Packages Related to [% pkg %]

+ + + [% IF is_source %] + + + [% ELSE %] + + + + [% END %] +
[adep]= build-depends[idep]= build-depends-indep[dep]= depends[rec]= recommends[sug]= suggests
+ [%- END %] + +
    + [% FOREACH terms %] + [% '
  • ' UNLESS is_old_pkgs %] + [% FOREACH alternatives %] + [% '
    ' IF loop.first %] +
    [% IF loop.first %][[% id %]][% ELSE %]or [% END %] + [% IF suite %][% name %][% ELSE %][% name %][% END %] + [% ' (' _ version _ ')' IF version %] + [% ' [' _ arch_str _ ']' IF arch_str %]
    + [%- IF !is_old_pkgs -%] +
    [% desc -%] + [%- IF providers.size > 0 -%] + [% '
    also a ' IF providers.also %]virtual package provided by + [%- IF providers.pkgs.size < 11 -%] + [% FOREACH provider IN providers.pkgs %][% provider %][% ', ' UNLESS loop.last %][% END %] + [%- ELSE -%] + [% providers.pkgs.size %] packages + [% END %] + [% END %] +
    + [% END %] + [% '
    ' IF loop.last %] + [% END %] + [% END %] +
+ + [% IF loop.last -%] +
+ [%- END %] +[% END %] + +[% FOREACH downloads %] + [% IF loop.first -%] +
+

Download [% pkg %]

+ + + + [% '' IF versions.multiple %] + [%- END %] + + +[% download_url = pkg _ '/' _ arch _ '/download' + filelist_url = pkg _ '/' _ arch _ '/filelist' %] + +[% '' IF versions.multiple %] + + + + + [% IF loop.last -%] +
Download for all available architectures
ArchitectureVersionPackage SizeInstalled SizeFiles
[% arch %]' _ version _ '[% pkgsize %] kB[% instsize %] kB +[% IF contents_avail %] + [list of files] +[% ELSE %] + no current information +[% END %] +
+ +
+ [%- END %] +[% END %] + +[% FOREACH srcfiles %] + [% IF loop.first -%] +
+

Download [% pkg %]

+ + + + [%- END %] + + + + + + + + [% IF loop.last -%] +
FileSize (in kB)md5sum
[% filename %][% size %][% md5sum %]
+ +
+ [%- END %] +[% END %] + + +[% UNLESS is_virtual %] +
+

More Information on [% pkg %]

+Check for Bug Reports about [% pkg %].
+[% IF src %] + Source Package: [% src.pkg %], Download: + [% FOREACH src.downloads %] + [[% name %]] + [% END %] + [% IF src.downloads.size == 0 %] + Not found + [% END %] +[% END %] + +[% IF files %] +
View the Debian changelog
+View the copyright file

+[% END %] +

+[% IF maintainers.size == 1 -%] + [%- FOREACH maintainers -%] + [% name | html %] is responsible for this Debian package. + [%- END -%] +[%- ELSE -%] + [%- FOREACH maintainers -%] + [%- IF loop.first -%] +[% name | html %] + [%- ELSIF loop.last -%] + and [% name | html %] are responsible for this Debian package. + [%- ELSE -%] +, [% name | html %] + [%- END -%] + [%- END -%] +[%- END %] +[% IF src -%] +See the developer information for [% pkg %]. +[%- END %] +

+

Search for other versions of [% pkg %]

+
+[% END %] diff --git a/templates/html/suite_index.tmpl b/templates/html/suite_index.tmpl new file mode 100644 index 0000000..ed4f901 --- /dev/null +++ b/templates/html/suite_index.tmpl @@ -0,0 +1,28 @@ +[% PROCESS 'html/head.tmpl' + title_tag = "List of sections in \"$suite\"" + page_title = "List of sections in \"$suite\"" + keywords = suite + navigation = [ { name=> suite }, + { name => 'Index' }, ] +%] + +[% FOREACH subsections %] + [% '
' IF loop.first %] + +
[% name %]
+
[% desc %]
+ + [%- loop_half = loop.size / 2 -%] + [%- IF ( loop.count <= loop_half ) && ( loop.count >= ( loop_half - 1 ) ) -%] +
+
+
+
+ [%- END -%] + [% '
' IF loop.last %] +[% END %] + +

+ All packages
+ (compact compressed textlist) +

diff --git a/templates/txt/index.tmpl b/templates/txt/index.tmpl new file mode 100644 index 0000000..ab8c473 --- /dev/null +++ b/templates/txt/index.tmpl @@ -0,0 +1,20 @@ +[%- PROCESS 'config/archive_layout.tmpl' -%] +All Debian Packages in "[% suite %]" + +Last Modified: [% timestamp.string %] +Copyright (C) [% copyright.years %] [% copyright.name %]; +See for the license terms. + +[% FOREACH packages -%] + [%- BLOCK marker %] [[% text %][% END -%] + [%- BLOCK markers -%] + [%- PROCESS marker text=section IF section != main_section -%] + [%- PROCESS marker text=archive IF archive != main_archive -%] + [%- END -%] + [%- IF providers %] +[% name %] virtual package provided by [% providers.join(', ') %] + [%- END -%] + [%- IF versions %] +[% name %] ([% versions %])[% PROCESS markers %] [% desc %] + [%- END -%] +[%- END %] -- 2.39.2