1 package Packages::Config;
7 use Packages::CGI qw( :DEFAULT error );
9 our @ISA = qw( Exporter );
11 our ( $TOPDIR, $DBDIR, $TEMPLATEDIR, $CACHEDIR, $ROOT, $SEARCH_URL,
12 @LANGUAGES, @DDTP_LANGUAGES,
13 @SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES,
14 @PRIORITIES, %FTP_SITES );
15 our @EXPORT_OK = qw( $TOPDIR $DBDIR $TEMPLATEDIR $CACHEDIR $ROOT $SEARCH_URL
16 @LANGUAGES @DDTP_LANGUAGES
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 $SEARCH_URL = $1 if /^\s*search_url="?([^\"]*)"?\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)) {
50 s/\$\{?topdir\}?/$TOPDIR/g;
53 unshift @LANGUAGES, 'en';
54 unshift @DDTP_LANGUAGES, 'en';
55 debug( "read config ($modtime > $config_read_time)" ) if DEBUG;
56 $config_read_time = $modtime;
58 $DBDIR = "$TOPDIR/files/db";