+print "write suite index files ...\n";
+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";
+ my $root = ($a eq 'us') ? '' : '../';
+ mkpath ( "$wwwdir/$key" );
+ foreach my $lang (@LANGUAGES) {
+ my $locale = get_locale( $lang );
+ setlocale ( LC_ALL, $locale ) or do {
+ warn "couldn't set locale ($lang/$locale)\n";
+ next;
+ };
+ 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 ), '<div id="lefthalfcol"><dl>';
+ my $i = 0; my $num_sections = keys %{$subsections->{$s}{$a}};
+ foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
+ next if $ssec eq '-';
+ if ($sections_descs{$ssec}) {
+ print {$pages{$key}{$lang}{index}{fh}} "<dt><a href=\"$ssec/\">".dgettext( 'sections', $sections_descs{$ssec}[0] )."</a></dt><dd>".dgettext( 'sections', $sections_descs{$ssec}[1] )."</dd>\n";
+ $i++;
+ if ($i eq ceil($num_sections/2)) {
+ print {$pages{$key}{$lang}{index}{fh}} "</dl>\n</div> <!-- end lefthalfcol -->\n<div id=\"righthalfcol\">\n<dl>\n";
+ }
+ }
+ }
+
+ print {$pages{$key}{$lang}{index}{fh}} '</dl></div>',
+ "<p class=\"psmallcenter\"><a href=\"allpackages\" title=\""._g( "List of all packages" )."\">".
+ _g( "All packages" ) ."</a><br>(<a href=\"allpackages.en.txt.gz\">".
+ _g( "compact compressed textlist" )."</a>)</p>\n";
+ print {$pages{$key}{$lang}{index}{fh}} trailer( "$root../", '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",
+ "$wwwdir/$key/index.$lang.html" );
+
+ }
+ }
+}
+setlocale( LC_ALL, 'C' ) or die "couldn't reset locale";
+