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
|
#!/usr/bin/env python
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
from shelltoolbox import (
apt_get_install,
DictDiffer,
install_extra_repositories,
)
import subprocess
from helpers import (
get_config,
log,
log_entry,
log_exit,
)
from local import (
config_json,
create_slave,
)
def main():
config = get_config()
prev_config = config_json.get()
diff = DictDiffer(config, prev_config)
log("Differences:")
log(str(diff))
buildbot_pkg = config.get('buildbot-pkg')
extra_repo = config.get('extra-repository')
buildbot_dir = config.get('installdir')
if extra_repo and 'extra-repository' in diff.added_or_changed:
try:
install_extra_repositories(extra_repo)
except subprocess.CalledProcessError as e:
log('Error adding repository: ' + extra_repo)
log(e)
raise
if buildbot_pkg and 'buildbot-pkg' in diff.added_or_changed:
log('Installing ' + buildbot_pkg)
apt_get_install(buildbot_pkg)
log('Creating initial buildbot slave in ' + buildbot_dir)
create_slave('temporary', 'temporary', buildbot_dir=buildbot_dir)
config_json.set(config)
if __name__ == '__main__':
log_entry()
try:
main()
finally:
log_exit()
|