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 my $wwwdir = "$TOPDIR/www";
44 $path .= "source/" if $opts->{source};
45 $path .= "$opts->{suite}[0]/";
46 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
47 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
48 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
51 if ($opts->{lang} ne 'en' and !-f "$wwwdir/$path$file.$opts->{lang}.$opts->{format}") {
54 $path .= "$file.$opts->{lang}.$opts->{format}";
56 unless (@Packages::CGI::fatal_errors) {
58 if (open( INDEX, '<', "$wwwdir/$path" )) {
60 $headers{'-charset'} = 'UTF-8';
61 $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' );
62 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
63 my ($size,$mtime) = (stat("$wwwdir/$path"))[7,9];
64 $headers{'-content-length'} = $size;
65 $headers{'-last-modified'} = gmtime($mtime);
66 print header( %headers );
69 while (read INDEX, $buffer, 4096) {
75 fatal_error( $cat->g( "couldn't read index file %s: %s",