1 package Packages::Config;
9 our @ISA = qw( Exporter );
11 our ( $TOPDIR, $DBDIR, $ROOT, $HOSTNAME, $HOME, $CONTACT_MAIL, $WEBMASTER_MAIL,
12 $SEARCH_PAGE, $SEARCH_URL, @LANGUAGES, $LOCALES,
13 $SRC_SEARCH_URL, $CONTENTS_SEARCH_CGI,
14 $CN_HELP_URL, $BUG_URL, $SRC_BUG_URL, $QA_URL, $DDPO_URL,
15 @SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES,
17 our @EXPORT_OK = qw( $TOPDIR $DBDIR $ROOT $HOSTNAME $HOME $CONTACT_MAIL
18 $WEBMASTER_MAIL @LANGUAGES $LOCALES
19 $SEARCH_PAGE $SEARCH_URL
20 $SRC_SEARCH_URL $CONTENTS_SEARCH_CGI
21 $CN_HELP_URL $BUG_URL $SRC_BUG_URL $QA_URL $DDPO_URL
22 @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES
24 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
26 our $config_read_time;
30 my $modtime = (stat( "$dir/config.sh" ))[9] || 0;
31 $config_read_time ||= 0;
32 if ($modtime >= $config_read_time) {
33 if (!open (C, '<', "$dir/config.sh")) {
34 error( "Internal: Cannot open configuration file." );
39 $TOPDIR = $1 if /^\s*topdir="?([^\"]*)"?\s*$/o;
40 $ROOT = $1 if /^\s*root="?([^\"]*)"?\s*$/o;
41 $HOSTNAME = $1 if /^\s*hostname="?([^\"]*)"?\s*$/o;
42 $HOME = $1 if /^\s*home="?([^\"]*)"?\s*$/o;
43 $LOCALES = $1 if /^\s*localedir="?([^\"]*)"?\s*$/o;
44 # $SEARCH_CGI = $1 if /^\s*search_cgi="?([^\"]*)"?\s*$/o;
45 $SEARCH_PAGE = $1 if /^\s*search_page="?([^\"]*)"?\s*$/o;
46 $SEARCH_URL = $1 if /^\s*search_url="?([^\"]*)"?\s*$/o;
47 $SRC_SEARCH_URL = $1 if /^\s*search_src_url="?([^\"]*)"?\s*$/o;
48 $WEBMASTER_MAIL = $1 if /^\s*webmaster="?([^\"]*)"?\s*$/o;
49 $CONTACT_MAIL = $1 if /^\s*contact="?([^\"]*)"?\s*$/o;
50 $BUG_URL = $1 if /^\s*bug_url="?([^\"]*)"?\s*$/o;
51 $SRC_BUG_URL = $1 if /^\s*src_bug_url="?([^\"]*)"?\s*$/o;
52 $QA_URL = $1 if /^\s*qa_url="?([^\"]*)"?\s*$/o;
53 $DDPO_URL = $1 if /^\s*ddpo_url="?([^\"]*)"?\s*$/o;
54 $CN_HELP_URL = $1 if /^\s*cn_help_url="?([^\"]*)"?\s*$/o;
55 $FTP_SITES{us} = $1 if /^\s*ftpsite="?([^\"]*)"?\s*$/o;
56 $FTP_SITES{$1} = $2 if /^\s*(\w+)_ftpsite="?([^\"]*)"?\s*$/o;
57 @LANGUAGES = split(/\s+/, $1) if /^\s*polangs="?([^\"]*)"?\s*$/o;
58 @SUITES = split(/\s+/, $1) if /^\s*suites="?([^\"]*)"?\s*$/o;
59 @SECTIONS = split(/\s+/, $1) if /^\s*sections="?([^\"]*)"?\s*$/o;
60 @ARCHIVES = split(/\s+/, $1) if /^\s*archives="?([^\"]*)"?\s*$/o;
61 @ARCHITECTURES = split(/\s+/, $1) if /^\s*architectures="?([^\"]*)"?\s*$/o;
64 debug( "read config ($modtime > $config_read_time)" ) if DEBUG;
65 $config_read_time = $modtime;
67 $DBDIR = "$TOPDIR/files/db";
68 unshift @LANGUAGES, 'en';