/
bootstrap
executable file
·52 lines (37 loc) · 1.42 KB
/
bootstrap
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
#!/usr/bin/env python
import argparse
import errno
import os
import subprocess
import sys
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
DOWNLOAD_DIR = os.path.join(VENDOR_DIR, 'download')
def main():
args = parse_args()
return (update_submodules() or
download_libchromiumcontent(args.url))
def parse_args():
parser = argparse.ArgumentParser(description='Bootstrap this project')
parser.add_argument('url', help='The base URL from which to download '
'libchromiumcontent (i.e., the URL you passed to '
'libchromiumcontent\'s script/upload script')
return parser.parse_args()
def update_submodules():
return (subprocess.call(['git', 'submodule', 'sync', '--quiet']) or
subprocess.call(['git', 'submodule', 'update', '--init',
'--recursive']))
def download_libchromiumcontent(url):
mkdir_p(DOWNLOAD_DIR)
download = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'script',
'download')
return subprocess.call([sys.executable, download, '-f', url,
os.path.join(DOWNLOAD_DIR, 'libchromiumcontent')])
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
if __name__ == '__main__':
sys.exit(main())