]> git.deb.at Git - deb/packages.git/blob - lib/Packages/DoFilelist.pm
714171bc9c2213c2faa115ac5adec46be2f8d56d
[deb/packages.git] / lib / Packages / DoFilelist.pm
1 package Packages::DoFilelist;
2
3 use strict;
4 use warnings;
5
6 use POSIX;
7 use URI::Escape;
8 use HTML::Entities;
9 use DB_File;
10 use Benchmark ':hireswallclock';
11 use Exporter;
12
13 use Deb::Versions;
14 use Packages::Config qw( $DBDIR $ROOT @SUITES @ARCHIVES @SECTIONS
15                          @ARCHITECTURES %FTP_SITES );
16 use Packages::CGI;
17 use Packages::DB;
18 use Packages::Search qw( :all );
19 use Packages::HTML;
20 use Packages::Page ();
21 use Packages::SrcPage ();
22
23 our @ISA = qw( Exporter );
24 our @EXPORT = qw( do_filelist );
25
26 sub do_filelist {
27     my ($params, $opts, $html_header, $menu, $page_content) = @_;
28
29     if ($params->{errors}{package}) {
30         fatal_error( "package not valid or not specified" );
31     }
32     if ($params->{errors}{suite}) {
33         fatal_error( "suite not valid or not specified" );
34     }
35     if ($params->{errors}{arch}) {
36         fatal_error( "arch not valid or not specified" );
37     }
38
39     $$menu = '';
40     my $pkg = $opts->{package};
41     my $suite = $opts->{suite}[0];
42     my $arch = $opts->{arch}[0] ||'';
43
44     %$html_header = ( title => "Filelist of package <em>$pkg</em> in <em>$suite</em> of arch <em>$arch</em>",
45                       title_tag => "Filelist of of package $pkg/$suite/$arch",
46                       lang => 'en',
47                       keywords => "debian, $suite, $arch, filelist",
48                       print_title => 1,
49                       );
50
51     unless (@Packages::CGI::fatal_errors) {
52         if (tie my %contents, 'DB_File', "$DBDIR/contents/filelists_${suite}_${arch}.db",
53             O_RDONLY, 0666, $DB_BTREE) {
54
55             unless (exists $contents{$pkg}) {
56                 fatal_error( "No such package in this suite on this arch" );
57             } else {
58                 my @files = unpack "L/(CC/a)", $contents{$pkg};
59                 my $file = "";
60                 $$page_content .= '<div id="pfilelist"><pre>';
61                 for (my $i=0; $i<scalar @files;) {
62                     $file = substr($file, 0, $files[$i++]).$files[$i++];
63                     $$page_content .= "$file\n";
64                 }
65                 $$page_content .= '</pre></div>';
66             }
67         } else {
68             fatal_error( "Invalid suite/arch combination" );
69         }
70     }
71 }
72
73 1;