1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# vim: set sw=4 sts=4 et :
# Copyright: 2008 Gentoo Foundation
# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
# License: GPL-2
#
# Immortal lh!
#
"""
Default configuration, overriden by /etc/autotua/slave.cfg
"""
import os, ConfigParser, const
VERBOSE = False
FULL_CLEAN = False
IGNORE_PROXY = False
LOGFILE = '/var/log/autotua/slave.log'
TMPDIR = '/var/tmp/autotua'
AUTOTUA_MASTER = ''
JOBTAGE_URI = 'git://git.overlays.gentoo.org/proj/jobtage.git'
# Bind mounted inside the chroots for use if defined
PORTAGE_DIR = '/usr/portage'
DISTFILES_DIR = '/usr/portage/distfiles'
# Read settings from slave.cfg which override the above
if os.path.exists('%s/slave.cfg' % const.CONFIG_PATH):
options = locals().copy()
cfg = ConfigParser.ConfigParser()
cfg.readfp(open('%s/slave.cfg' % const.CONFIG_PATH))
for option, value in options.iteritems():
if not isinstance(value, (str, int, bool)):
continue
if cfg.has_option('global', option.lower()):
if isinstance(value, str):
if not option.startswith('__'):
exec('%s = %s' % (option, cfg.get('global', option.lower())))
elif isinstance(value, bool):
exec('%s = %s' % (option, cfg.getboolean('global', option.lower())))
elif isinstance(value, int):
exec('%s = %s' % (option, cfg.getint('global', option.lower())))
if not AUTOTUA_MASTER:
raise Exception('You need to set the autotua_master variable in slave.cfg (or AUTOTUA_MASTER in config.py)')
# Import all the constants now
from const import *
# Derivative variables
TARBALL_DIR = TMPDIR+'/tarballs'
STAGE_DIR = TARBALL_DIR+'/stages'
JOBFILE_DIR = TARBALL_DIR+'/jobfiles'
CHROOT_DIR = TMPDIR+'/chroots/pristine'
SAVED_CHROOT_DIR = TMPDIR+'/chroots/saved'
WORKDIR = TMPDIR+'/work'
JOBTAGE_DIR = TMPDIR+'/jobtage'
# If using http_proxy, enable git proxy support
if not IGNORE_PROXY and os.environ.has_key('http_proxy'):
prefix = AUTOTUA_DIR+'/../scripts/'
# If git-proxy-cmd.sh is in PATH, use that
for path in os.environ['PATH'].split(':'):
if os.access(path+"/git-proxy-cmd.sh", os.X_OK):
prefix = ''
os.environ['GIT_PROXY_COMMAND'] = prefix+'git-proxy-cmd.sh'
# Create autotua directories if they don't exist
if not os.path.isdir(os.path.dirname(LOGFILE)):
os.makedirs(os.path.dirname(LOGFILE))
for dir in [TMPDIR, TARBALL_DIR, STAGE_DIR, JOBFILE_DIR, CHROOT_DIR, SAVED_CHROOT_DIR, WORKDIR, JOBTAGE_DIR]:
if not os.path.isdir(dir):
os.makedirs(dir)
|