1 package Packages::DoIndex;
10 use Packages::Config qw( $TOPDIR );
13 our @ISA = qw( Exporter );
14 our @EXPORT = qw( do_index do_allpackages );
17 return send_file( 'index', @_ );
20 return send_file( 'allpackages', @_ );
27 my ($file, $params, $opts) = @_;
28 my $cat = $opts->{cat};
30 if ($params->{errors}{suite}) {
31 fatal_error( $cat->g( "suite not valid or not specified" ) );
33 if (@{$opts->{suite}} > 1) {
34 fatal_error( $cat->g( "more than one suite specified for show_static (%s)",
35 "@{$opts->{suite}}" ) );
37 if (@{$opts->{subsection}} > 1) {
38 fatal_error( $cat->g( "more than one subsection specified for show_static (%s)",
39 "@{$opts->{suite}}" ) );
42 if ($opts->{format} eq 'txt.gz') {
43 $opts->{po_lang} = 'en';
45 my $wwwdir = "$TOPDIR/www";
47 $path .= "source/" if $opts->{source};
48 $path .= "$opts->{suite}[0]/";
49 # $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
50 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
51 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
52 $path .= "$file.$opts->{po_lang}.$opts->{format}";
54 unless (@Packages::CGI::fatal_errors) {
56 if (open( INDEX, '<', "$wwwdir/$path" )) {
58 $headers{'-charset'} = 'UTF-8';
59 $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' );
60 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
61 my ($size,$mtime) = (stat("$wwwdir/$path"))[7,9];
62 $headers{'-content-length'} = $size;
63 $headers{'-last-modified'} = gmtime($mtime);
64 print header( %headers );
67 while (read INDEX, $buffer, 4096) {
73 fatal_error( $cat->g( "couldn't read index file %s: %s",