41
46
def wget(source, path):
42
47
target = os.path.join('/tmp', path)
43
command('wget', '-O', target, source)
48
run('wget', '-O', target, source)
47
52
def hg_fetch(source, path):
48
53
apt_get_install('mercurial')
49
54
target = tempfile.mktemp()
50
command('hg', 'clone', source, target)
55
run('hg', 'clone', source, target)
51
56
return os.path.join(target, path)
54
59
def git_fetch(source, path):
55
60
apt_get_install('git')
56
61
target = tempfile.mktemp()
57
command('git', 'clone', source, target)
62
run('git', 'clone', source, target)
58
63
return os.path.join(target, path)
81
86
method = config.get('script-retrieval-method')
82
87
url = config.get('script-url')
83
88
path = config.get('script-path')
84
args = config.get('script-args')
89
# This is a naive substitution. We can make it more sophisticated
90
# if we discover we need it. For now, simplicity wins.
91
args = config.get('script-args', '').format(**config)
92
buildbot_pkg = config.get('buildbot-pkg')
93
extra_repo = config.get('extra-repository')
94
buildbot_dir = config.get('installdir')
97
install_extra_repository(extra_repo)
100
log('Installing ' + buildbot_pkg)
101
apt_get_install(buildbot_pkg)
102
log('Creating initial buildbot slave in ' + buildbot_dir)
103
create_slave('temporary', 'temporary', buildbot_dir=buildbot_dir)
105
config_json.set(config)
85
107
retrieve = METHODS.get(method)
86
108
if retrieve and url and path:
109
# Make buildbot user have a shell by editing /etc/passwd.
110
# Otherwise you cannot ssh as this user, which some scripts
111
# need (e.g. those that create lxc containers). We choose sh as
112
# a standard and basic "system" shell.
113
run('usermod', '-s', '/bin/sh', 'buildbot')
87
114
sys.exit(handle_script(retrieve, url, path, args))