1 package Packages::DoIndex;
7 use POSIX qw( strftime );
11 use Packages::Config qw( $TOPDIR );
14 our @ISA = qw( Exporter );
15 our @EXPORT = qw( do_index do_allpackages );
18 return send_file( 'index', @_ );
21 return send_file( 'allpackages', @_ );
28 my ($file, $params, $opts) = @_;
29 my $cat = $opts->{cat};
31 if ($params->{errors}{suite}) {
32 fatal_error( $cat->g( "suite not valid or not specified" ) );
34 if (@{$opts->{suite}} > 1) {
35 fatal_error( $cat->g( "more than one suite specified for show_static (%s)",
36 "@{$opts->{suite}}" ) );
38 if (@{$opts->{subsection}} > 1) {
39 fatal_error( $cat->g( "more than one subsection specified for show_static (%s)",
40 "@{$opts->{suite}}" ) );
43 if ($opts->{format} eq 'txt.gz') {
44 $opts->{po_lang} = 'en';
46 my $wwwdir = "$TOPDIR/www";
48 $path .= "source/" if $opts->{source};
49 $path .= "$opts->{suite}[0]/";
50 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
51 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
52 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
53 $path .= "$file.$opts->{po_lang}.$opts->{format}";
55 unless (@Packages::CGI::fatal_errors) {
57 if (open( INDEX, '<', "$wwwdir/$path" )) {
59 $headers{'-charset'} = 'UTF-8';
60 $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' );
61 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
62 my ($size,$mtime) = (stat("$wwwdir/$path"))[7,9];
63 $headers{'-content-length'} = $size;
64 $headers{'-vary'} = 'negotiate,accept-language';
65 $headers{'-last-modified'} = strftime("%a, %d %b %Y %T %z", localtime($mtime));
66 print header( %headers );
69 while (read INDEX, $buffer, 4096) {
75 fatal_error( $cat->g( "couldn't read index file %s: %s",