forked from mongodb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.py
61 lines (45 loc) · 1.66 KB
/
bootstrap.py
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
import os
import subprocess
import argparse
import yaml
import sys
project_root = os.path.abspath(os.path.dirname(__file__))
master_conf = os.path.join(project_root, 'bin', 'docs_meta.yaml')
with open(master_conf, 'r') as f:
conf = yaml.safe_load(f)
buildsystem = conf['build']['paths']['buildsystem']
sys.path.append(os.path.join(buildsystem, 'bin'))
def bootstrap():
repo = 'git://github.com/{0}.git'.format(conf['git']['remote']['tools'])
if os.path.exists(buildsystem):
import bootstrap_helper
cmd = []
cmd.append(['git', 'reset', '--quiet', '--hard', bootstrap_helper.reset_ref])
cmd.append(['git', 'pull', '--quiet', 'origin', 'master'])
for c in cmd:
p = subprocess.Popen(c, cwd=buildsystem)
p.wait()
print('[bootstrap]: updated git repository.')
else:
p = subprocess.Popen([ 'git', 'clone', repo, buildsystem])
p.wait()
import bootstrap_helper
print('[bootstrap]: created buildsystem directory.')
bootstrap_helper.init_fabric(buildsystem, master_conf)
bootstrap_helper.bootstrap()
p = subprocess.Popen(['make', 'noop', '--silent', '-i'])
p.wait()
def main():
parser = argparse.ArgumentParser()
parser.add_argument('op', nargs='?', choices=['clean', 'setup'], default='setup')
ui = parser.parse_args()
if ui.op == 'clean':
try:
import bootstrap_helper
bootstrap_helper.clean_buildsystem(buildsystem, conf['build']['paths']['output'])
except ImportError:
exit('[bootstrap]: Buildsystem not installed.')
else:
bootstrap()
if __name__ == '__main__':
main()