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