15 use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES $LOCALES);
17 use Packages::I18N::Locale;
19 use Packages::Sections;
20 &Packages::Config::init( './' );
22 delete $ENV{'LANGUAGE'};
24 delete $ENV{'LC_ALL'};
25 delete $ENV{'LC_MESSAGES'};
26 bindtextdomain ( 'pdo', $LOCALES );
27 bindtextdomain ( 'sections', $LOCALES );
30 my $wwwdir = "$TOPDIR/www";
32 tie my %packages, 'DB_File', "$DBDIR/packages_small.db",
33 O_RDONLY, 0666, $DB_BTREE
34 or die "couldn't tie DB $DBDIR/packages_small.db: $!";
36 my $sections = retrieve "$DBDIR/sections.info";
37 my $subsections = retrieve "$DBDIR/subsections.info";
38 # work around problems with non-US security updates
39 $subsections->{oldstable}{us}{'non-US'}++;
40 my $priorities = retrieve "$DBDIR/priorities.info";
43 #print STDERR Dumper($sections, $subsections, $priorities);
47 print "write suite index files ...\n";
48 foreach my $s (@SUITES) {
49 foreach my $a (@ARCHIVES) {
50 next if $a eq 'security';
51 next if $a eq 'non-US';
52 my $key = ($a eq 'us') ? $s : "$s/$a";
53 my $root = ($a eq 'us') ? '' : '../';
54 mkpath ( "$wwwdir/$key" );
55 foreach my $lang (@LANGUAGES) {
56 my $locale = get_locale( $lang );
57 setlocale ( LC_ALL, $locale ) or do {
58 warn "couldn't set locale ($lang/$locale)\n";
61 open $pages{$key}{$lang}{index}{fh}, '>', "$wwwdir/$key/index.$lang.html.new"
62 or die "can't open index file for output: $!";
63 my $index_title = sprintf( _g( "List of sections in \"%s\"" ),
65 print {$pages{$key}{$lang}{index}{fh}} header( title => $index_title,
66 title_keywords => "debian, $s",
67 desc => encode_entities( $index_title, '"' ),
69 title( $index_title ), '<div id="lefthalfcol"><dl>';
70 my $i = 0; my $num_sections = keys %{$subsections->{$s}{$a}};
71 foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
73 if ($sections_descs{$ssec}) {
74 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";
76 if ($i eq ceil($num_sections/2)) {
77 print {$pages{$key}{$lang}{index}{fh}} "</dl>\n</div> <!-- end lefthalfcol -->\n<div id=\"righthalfcol\">\n<dl>\n";
82 print {$pages{$key}{$lang}{index}{fh}} '</dl></div>',
83 "<p class=\"psmallcenter\"><a href=\"allpackages\" title=\""._g( "List of all packages" )."\">".
84 _g( "All packages" ) ."</a><br>(<a href=\"allpackages.en.txt.gz\">".
85 _g( "compact compressed textlist" )."</a>)</p>\n";
86 print {$pages{$key}{$lang}{index}{fh}} trailer( "$root../", 'index', $lang, @LANGUAGES );
87 close $pages{$key}{$lang}{index}{fh} or
88 warn "can't close index file $wwwdir/$key/index.$lang.html.new: $!";
89 rename( "$wwwdir/$key/index.$lang.html.new",
90 "$wwwdir/$key/index.$lang.html" );
95 setlocale( LC_ALL, 'C' ) or die "couldn't reset locale";
97 print "opening files ...\n";
98 foreach my $s (@SUITES) {
99 foreach my $a (@ARCHIVES) {
100 next if $a eq 'security';
101 next if $a eq 'non-US';
102 my $key = ($a eq 'us') ? $s : "$s/$a";
103 mkpath ( "$wwwdir/$key" );
104 open $pages{$key}{fh}, '>', "$wwwdir/$key/allpackages.en.html.new"
105 or die "can't open index file for output: $!";
107 my $title = sprintf( _g( "Software Packages in \"%s\"" ),
109 print {$pages{$key}{fh}} header( title => $title,
110 title_keywords => "debian, $s",
111 desc => encode_entities( $title, '"' ),
113 title( $title ), '<dl>';
115 foreach my $sec (keys %{$sections->{$s}{$a}}) {
116 mkpath ( "$wwwdir/$key/$sec" );
117 open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new"
118 or die "can't open index file for output: $!";
119 $title = sprintf( _g( "Software Packages in \"%s\", section %s" ),
121 print {$pages{$key}{$sec}{fh}} header( title => $title,
122 title_keywords => "debian, $s, $sec",
123 desc => encode_entities( $title, '"' ),
125 title( $title ), '<dl>';
127 foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
128 next if $ssec eq '-';
129 mkpath ( "$wwwdir/$key/$ssec" );
130 open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new"
131 or die "can't open index file for output: $!";
132 $title = sprintf( _g( "Software Packages in \"%s\", subsection %s" ),
134 print {$pages{$key}{$ssec}{fh}} header( title => $title,
135 title_keywords => "debian, $s, $ssec",
136 desc => encode_entities( $title, '"' ),
138 title( $title ), '<dl>';
140 foreach my $prio (keys %{$priorities->{$s}{$a}}) {
141 next if $prio eq '-';
142 mkpath ( "$wwwdir/$key/$prio" );
143 open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new"
144 or die "can't open index file for output: $!";
145 $title = sprintf( _g( "Software Packages in \"%s\", priority %s" ),
147 print {$pages{$key}{$prio}{fh}} header( title => $title,
148 title_keywords => "debian, $s, $prio",
149 desc => encode_entities( $title, '"' ),
151 title( $title ), '<dl>';
156 print "writing package info ...\n";
157 while (my ($pkg, $data) = each %packages) {
159 foreach (split /\000/o, $data) {
160 my @data = split ( /\s/o, $_, 8 );
162 if ($data[0] !~ /^(?:us|security|non-US)$/o) {
163 $key = "$data[1]/$data[0]";
165 $pkg{$key} ||= new Packages::Page( $pkg );
166 if ($data[2] ne 'virtual') {
167 $pkg{$key}->merge_package( { package => $pkg,
170 architecture => $data[2],
172 subsection => $data[4],
173 priority => $data[5],
175 description => $data[7] } );
177 $pkg{$key}->add_provided_by([split /\s+/, $data[7]]);
180 while (my ($key, $entry) = each %pkg) {
181 if (my $provided_by = $entry->{provided_by}) {
182 my $str = "<dt><a href=\"$pkg\">$pkg</a> ".
183 "</dt>\n <dd>virtual package provided by ".
184 join( ', ',map { "<a href=\"../$_\">$_</a>" } @$provided_by)."</dd>\n";
185 my $txt_str = "$pkg\tvirtual package provided by ".join(', ', @$provided_by)."\n";
186 print {$pages{$key}{virtual}{fh}} $str
187 or die "couldn't write to output file: $!";
189 next if $entry->is_virtual;
190 my (undef, $v_str) = $entry->get_version_string;
191 my $subsection = $entry->get_newest( 'subsection' );
192 my $section = $entry->get_newest( 'section' );
193 my $archive = $entry->get_newest( 'archive' );
194 my $short_desc_txt = $entry->get_newest( 'description' );
195 my $short_desc = encode_entities( $short_desc_txt, "<>&\"" );
196 my $priority = $entry->get_newest( 'priority' );
198 my $str = "<dt><a href=\"$pkg\">$pkg</a> ($v_str) ";
199 my $txt_str = "$pkg ($v_str)";
200 if ($section ne 'main') {
201 $str .= marker( $section );
202 $txt_str .= " [$section]";
204 if ($archive ne 'us') {
205 $str .= marker( $archive );
206 $txt_str .= " [$archive]";
208 $str .= "</dt>\n <dd>$short_desc</dd>\n";
209 $txt_str .= " $short_desc_txt\n";
210 print {$pages{$key}{fh}} $str
211 or die "couldn't write to output file: $!";
212 print {$pages{$key}{$section}{fh}} $str
213 or die "couldn't write to output file: $!";
214 if ($subsection ne '-') {
215 print {$pages{$key}{$subsection}{fh}} $str
216 or die "couldn't write to output file: $!";
218 if ($priority ne '-') {
219 print {$pages{$key}{$priority}{fh}} $str
220 or die "couldn't write to output file: $!";
225 print "closing files ...\n";
226 foreach my $s (@SUITES) {
227 foreach my $a (@ARCHIVES) {
228 next if $a eq 'security';
229 next if $a eq 'non-US';
230 my $key = ($a eq 'us') ? $s : "$s/$a";
231 my $root = ($a eq 'us') ? '' : '../';
232 print {$pages{$key}{fh}} '</dl>', trailer( "$root../" );
233 close $pages{$key}{fh} or
234 warn "can't close index file $wwwdir/$key/allpackages.en.html.new: $!";
235 rename( "$wwwdir/$key/allpackages.en.html.new",
236 "$wwwdir/$key/allpackages.en.html" );
237 foreach my $sec (keys %{$sections->{$s}{$a}}) {
238 print {$pages{$key}{$sec}{fh}} '</dl>', trailer( "$root../../" );
239 close $pages{$key}{$sec}{fh} or
240 warn "can't close index file $wwwdir/$key/$sec/index.en.html.new: $!";
241 rename( "$wwwdir/$key/$sec/index.en.html.new",
242 "$wwwdir/$key/$sec/index.en.html" );
244 foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) {
245 next if $ssec eq '-';
246 print {$pages{$key}{$ssec}{fh}} '</dl>', trailer( "$root../../" );
247 close $pages{$key}{$ssec}{fh} or
248 warn "can't close index file $wwwdir/$key/$ssec/index.en.html.new: $!";
249 rename( "$wwwdir/$key/$ssec/index.en.html.new",
250 "$wwwdir/$key/$ssec/index.en.html" );
252 foreach my $prio (keys %{$priorities->{$s}{$a}}) {
253 next if $prio eq '-';
254 print {$pages{$key}{$prio}{fh}} '</dl>', trailer( "$root../../" );
255 close $pages{$key}{$prio}{fh} or
256 warn "can't close index file $wwwdir/$key/$prio/index.en.html.new: $!";
257 rename( "$wwwdir/$key/$prio/index.en.html.new",
258 "$wwwdir/$key/$prio/index.en.html" );