-my %sections_descs = (
- 'admin' => [ "Administration Utilities",
- "Utilities to administer system resources, manage user accounts, etc." ],
- 'base' => [ "Base Utilities",
- "Basic needed utilities of every Debian system." ],
- 'comm' => [ "Communication Programs",
- "Software to use your modem in the old fashioned style." ],
- 'devel' => [ "Development",
- "Development utilities, compilers, development environments, libraries, etc." ],
- 'doc' => [ "Documentation",
- "FAQs, HOWTOs and other documents trying to explain everything related to Debian, and software needed to browse documentation (man, info, etc)." ],
- 'editors' => [ "Editors",
- "Software to edit files. Programming environments." ],
- 'electronics' => [ "Electronics",
- "Electronics utilities." ],
- 'embedded' => [ "Embedded software",
- "Software suitable for use in embedded applications." ],
- 'games' => [ "Games",
- "Programs to spend a nice time with after all this setting up." ],
- 'gnome' => [ "GNOME",
- "The GNOME desktop environment, a powerful, easy to use set of integrated applications." ],
- 'graphics' => [ "Graphics",
- "Editors, viewers, converters... Everything to become an artist." ],
- 'hamradio' => [ "Ham Radio",
- "Software for ham radio." ],
- 'interpreters' => [ "Interpreters",
- "All kind of interpreters for interpreted languages. Macro processors." ],
- 'kde' => [ "KDE",
- "The K Desktop Environment, a powerful, easy to use set of integrated applications." ],
- 'libs' => [ "Libraries",
- "Libraries to make other programs work. They provide special features to developers." ],
- 'libdevel' => [ "Library development",
- "Libraries necessary for developers to write programs that use them." ],
- 'mail' => [ "Mail",
- "Programs to route, read, and compose E-mail messages." ],
- 'math' => [ "Mathematics",
- "Math software." ],
- 'misc' => [ "Miscellaneous",
- "Miscellaneous utilities that didn\'t fit well anywhere else." ],
- 'net' => [ "Network",
- "Daemons and clients to connect your Debian GNU/Linux system to the world." ],
- 'news' => [ "Newsgroups",
- "Software to access Usenet, to set up news servers, etc." ],
- 'non-US' => [ "Software restricted in the U.S.",
- "These packages probably may not be used in or distributed from the U.S. due to software patents. You should check the regulations in your country before using this software." ],
- 'oldlibs' => [ "Old Libraries",
- "Old versions of libraries, kept for backward compatibility with old applications." ],
- 'otherosfs' => [ "Other OS\'s and file systems",
- "Software to run programs compiled for other operating system, and to use their filesystems." ],
- 'perl' => [ "Perl",
- "Everything about Perl, an interpreted scripting language." ],
- 'python' => [ "Python",
- "Everything about Python, an interpreted, interactive object oriented language." ],
- 'science' => [ "Science",
- "Basic tools for scientific work" ],
- 'shells' => [ "Shells",
- "Command shells. Friendly user interfaces for beginners." ],
- 'sound' => [ "Sound",
- "Utilities to deal with sound: mixers, players, recorders, CD players, etc." ],
- 'tex' => [ "TeX",
- "The famous typesetting software and related programs." ],
- 'text' => [ "Text Processing",
- "Utilities to format and print text documents." ],
- 'utils' => [ "Utilities",
- "Utilities for file/disk manipulation, backup and archive tools, system monitoring, input systems, etc." ],
- 'virtual' => [ "Virtual packages",
- "Virtual packages." ],
- 'web' => [ "Web Software",
- "Web servers, browsers, proxies, download tools etc." ],
- 'x11' => [ "X Window System software",
- "X servers, libraries, fonts, window managers, terminal emulators and many related applications." ],
- 'debian-installer' => [ "debian-installer udeb packages",
- "Special packages for building customized debian-installer variants. Do not install them on a normal system!" ],
- );
-
-
-my (%pages);
-
-foreach my $s (@SUITES) {
- foreach my $a (@ARCHIVES) {
- next if $a eq 'security';
- next if $a eq 'non-US';
- my $key = ($a eq 'us') ? $s : "$s/$a";
- mkpath ( "$wwwdir/$key" );
- open $pages{$key}{index}{fh}, '>', "$wwwdir/$key/index.en.html.new"
- or die "can't open index file for output: $!";
- open $pages{$key}{fh}, '>', "$wwwdir/$key/allpackages.en.html.new"
- or die "can't open index file for output: $!";
-
- my $title = sprintf( gettext ( "Software Packages in \"%s\"" ),
- $s );
- my $index_title = sprintf( gettext ( "List of sections in \"%s\"" ),
- $s );
- print {$pages{$key}{fh}} header( title => $title,
- title_keywords => "debian, $s",
- desc => encode_entities( $title, '"' ),
- lang => 'en' ),
- title( $title ), '<dl>';
- print {$pages{$key}{index}{fh}} header( title => $index_title,
- title_keywords => "debian, $s",
- desc => encode_entities( $index_title, '"' ),
- lang => 'en' ),
- title( $index_title ), '<div id="lefthalfcol"><dl>';
-
- foreach my $sec (keys %{$sections->{$s}{$a}}) {
- 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( gettext ( "Software Packages in \"%s\", section %s" ),
- $s, $sec );
- print {$pages{$key}{$sec}{fh}} header( title => $title,
- title_keywords => "debian, $s, $sec",
- desc => encode_entities( $title, '"' ),
- lang => 'en' ),
- title( $title ), '<dl>';
+
+my @PACKAGES = sort keys %packages;
+my @SRC_PACKAGES = sort keys %src_packages;
+
+print "Found ".scalar(@PACKAGES)." packages\n";
+print "Found ".scalar(@SRC_PACKAGES)." source packages\n";
+
+my $template = new Packages::Template( "$TOPDIR/templates", 'html');
+my $txt_template = new Packages::Template( "$TOPDIR/templates", 'txt');
+
+my $charset = 'UTF-8';
+my (%cat, %lang_vars, $prov_string, %s, %fh);
+foreach my $lang (@LANGUAGES) {
+ $cat{$lang} = Packages::I18N::Locale->get_handle($lang)
+ or die "get_handle failed for $lang";
+ $lang_vars{$lang} = { po_lang => $lang, ddtp_lang => $lang,
+ charset => $charset,
+ cat => $cat{$lang}, used_langs => \@LANGUAGES };
+ $s{begin}{$lang} = '['.uc($lang).':';
+ $s{end}{$lang} = ':'.uc($lang).']';
+ $prov_string .= $s{begin}{$lang}.$cat{$lang}->g('virtual package provided by').$s{end}{$lang};
+}
+
+sub open_file {
+ my ($key, $vars, $file) = @_;
+
+ $file ||= 'index';
+
+ print "opening $key\n";
+ mkdirp ( "$wwwdir/$key" );
+ open($fh{$key}, '>',
+ "$wwwdir/$key/$file.slices.new")
+ or die "Cannot open file $wwwdir/$key/$file.slices.new: $!";
+
+ foreach my $lang (@LANGUAGES) {
+ print {$fh{$key}} "$s{begin}{$lang}\n";
+ $template->page( 'index_head',
+ { %{$lang_vars{$lang}},
+ %$vars },
+ $fh{$key});
+ print {$fh{$key}} "\n$s{end}{$lang}\n";
+ }
+}
+
+sub close_file {
+ my ($key, $vars, $file) = @_;
+
+ $file ||= 'index';
+
+ print "closing $key\n";
+
+ foreach my $lang (@LANGUAGES) {
+ print {$fh{$key}} "\n$s{begin}{$lang}\n";
+ $template->page( 'index_foot',
+ { %{$lang_vars{$lang}},
+ %$vars },
+ $fh{$key});
+ print {$fh{$key}} "\n$s{end}{$lang}\n";
+ }
+ close($fh{$key})
+ or die "Cannot close file $wwwdir/$key/$file.slices.new: $!";
+
+ activate("$wwwdir/$key/$file.slices");
+}
+
+
+sub open_txt_file {
+ my ($key, $vars, $file) = @_;
+
+ $file ||= 'allpackages';
+ my $lang = 'en';
+
+ print "opening $key (txt,lang=$lang)\n";
+ mkdirp ( "$wwwdir/$key" );
+ $fh{"$key/$lang/txt"} = gzopen("$wwwdir/$key/$file.$lang.txt.gz.new", 'wb9')
+ or die "Cannot open file $wwwdir/$key/$file.$lang.txt.gz.new: $!";
+
+ my $gztxt = $txt_template->page( 'index_head',
+ { %{$lang_vars{$lang}},
+ %$vars });
+ $fh{"$key/$lang/txt"}->gzwrite($gztxt);
+}
+
+sub close_txt_file {
+ my ($key, $vars, $file) = @_;
+
+ $file ||= 'allpackages';
+ my $lang = 'en';
+
+ print "closing $key (txt,lang=$lang)\n";
+ my $gztxt = $txt_template->page( 'index_foot',
+ { %{$lang_vars{$lang}},
+ %$vars });
+ $fh{"$key/$lang/txt"}->gzwrite($gztxt);
+ ($fh{"$key/$lang/txt"}->gzclose == Z_OK) or
+ warn("can't close text index file $wwwdir/$key/$file.$lang.txt.gz.new: "
+ . $fh{"$key/$lang/txt"}->gzerror);
+ activate("$wwwdir/$key/$file.$lang.txt.gz");
+}
+
+
+foreach my $source (("", "source/")) {
+ print "write headers ...\n";
+ foreach my $s (@SUITES) {
+ mkdirp ( "$wwwdir/$source$s" );
+ my %common_vars = ( suite => $s,
+ is_source => $source );
+
+ open_file("$source$s", \%common_vars, 'allpackages');
+ open_txt_file("$source$s", \%common_vars, 'allpackages');
+
+ foreach my $sec (keys %{$sections->{$s}}) {
+ open_file("$source$s/$sec",
+ { %common_vars,
+ category => { id => N_('Section'),
+ name => $sec }});