1 package Packages::Config;
7 use Packages::CGI qw( :DEFAULT error );
9 our @ISA = qw( Exporter );
11 our ( $TOPDIR, $DBDIR, $TEMPLATEDIR, $CACHEDIR, $ROOT,
12 @LANGUAGES, @DDTP_LANGUAGES, $LOCALES,
13 @SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES,
14 @PRIORITIES, %FTP_SITES );
15 our @EXPORT_OK = qw( $TOPDIR $DBDIR $TEMPLATEDIR $CACHEDIR $ROOT
16 @LANGUAGES @DDTP_LANGUAGES $LOCALES
17 @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES
18 @PRIORITIES %FTP_SITES );
19 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
21 our $config_read_time;
25 my $modtime = (stat( "$dir/config.sh" ))[9] || 0;
26 $config_read_time ||= 0;
27 if ($modtime >= $config_read_time) {
28 if (!open (C, '<', "$dir/config.sh")) {
29 error( "Internal: Cannot open configuration file." );
34 $TOPDIR = $1 if /^\s*topdir="?([^\"]*)"?\s*$/o;
35 $TEMPLATEDIR = $1 if /^\s*templatedir="?([^\"]*)"?\s*$/o;
36 $CACHEDIR = $1 if /^\s*cachedir="?([^\"]*)"?\s*$/o;
37 $ROOT = $1 if /^\s*root="?([^\"]*)"?\s*$/o;
38 $LOCALES = $1 if /^\s*localedir="?([^\"]*)"?\s*$/o;
39 $FTP_SITES{us} = $1 if /^\s*ftpsite="?([^\"]*)"?\s*$/o;
40 $FTP_SITES{$1} = $2 if /^\s*(\w+)_ftpsite="?([^\"]*)"?\s*$/o;
41 @LANGUAGES = split(/\s+/, $1) if /^\s*polangs="?([^\"]*)"?\s*$/o;
42 @DDTP_LANGUAGES = split(/\s+/, $1) if /^\s*ddtplangs="?([^\"]*)"?\s*$/o;
43 @SUITES = split(/\s+/, $1) if /^\s*suites="?([^\"]*)"?\s*$/o;
44 @SECTIONS = split(/\s+/, $1) if /^\s*sections="?([^\"]*)"?\s*$/o;
45 @ARCHIVES = split(/\s+/, $1) if /^\s*archives="?([^\"]*)"?\s*$/o;
46 @ARCHITECTURES = split(/\s+/, $1) if /^\s*architectures="?([^\"]*)"?\s*$/o;
47 @PRIORITIES = split(/\s+/, $1) if /^\s*priorities="?([^\"]*)"?\s*$/o;
49 foreach (($TEMPLATEDIR, $CACHEDIR, $LOCALES)) {
50 s/\$\{?topdir\}?/$TOPDIR/g;
53 debug( "read config ($modtime > $config_read_time)" ) if DEBUG;
54 $config_read_time = $modtime;
56 $DBDIR = "$TOPDIR/files/db";
57 unshift @LANGUAGES, 'en';