2013-06-19 06:32:41 +00:00
|
|
|
#!/usr/bin/env python
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
import argparse
|
|
|
|
import errno
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-07-01 07:21:27 +00:00
|
|
|
from lib.util import *
|
|
|
|
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
|
|
|
|
BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'
|
2013-07-01 07:21:27 +00:00
|
|
|
PYTHON_26_URL = 'https://chromium.googlesource.com/chromium/deps/python_26'
|
2013-04-12 01:46:58 +00:00
|
|
|
|
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
def main():
|
|
|
|
os.chdir(SOURCE_ROOT)
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
args = parse_args()
|
2013-07-01 08:12:31 +00:00
|
|
|
if not args.skip_network:
|
2013-07-02 01:16:56 +00:00
|
|
|
update_submodules()
|
2013-08-03 08:39:54 +00:00
|
|
|
update_apm()
|
2013-07-01 08:12:31 +00:00
|
|
|
update_node_modules()
|
2013-07-02 01:16:56 +00:00
|
|
|
bootstrap_brightray(args.url)
|
2013-08-06 12:44:18 +00:00
|
|
|
if sys.platform == 'cygwin':
|
2013-07-01 08:12:31 +00:00
|
|
|
update_win32_python()
|
|
|
|
|
2013-07-02 01:16:56 +00:00
|
|
|
touch_config_gypi()
|
2013-06-19 06:32:41 +00:00
|
|
|
update_atom_shell()
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-04-14 14:48:35 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Bootstrap this project')
|
2013-07-01 08:12:31 +00:00
|
|
|
parser.add_argument('-u', '--url',
|
2013-06-19 06:32:41 +00:00
|
|
|
help='The base URL from which to download '
|
|
|
|
'libchromiumcontent (i.e., the URL you passed to '
|
|
|
|
'libchromiumcontent\'s script/upload script',
|
|
|
|
default=BASE_URL,
|
|
|
|
required=False)
|
2013-07-01 08:12:31 +00:00
|
|
|
parser.add_argument('-s', '--skip-network',
|
|
|
|
help='Skip operations require networking',
|
|
|
|
action='store_true')
|
2013-06-19 06:32:41 +00:00
|
|
|
return parser.parse_args()
|
2013-04-12 01:46:58 +00:00
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
|
|
|
|
def update_submodules():
|
|
|
|
subprocess.check_call(['git', 'submodule', 'sync', '--quiet'])
|
|
|
|
subprocess.check_call(['git', 'submodule', 'update', '--init',
|
|
|
|
'--recursive'])
|
|
|
|
|
|
|
|
|
|
|
|
def bootstrap_brightray(url):
|
|
|
|
bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap')
|
|
|
|
subprocess.check_call([sys.executable, bootstrap, url])
|
|
|
|
|
|
|
|
|
2013-08-03 08:39:54 +00:00
|
|
|
def update_apm():
|
|
|
|
with scoped_cwd(os.path.join('vendor', 'apm')):
|
|
|
|
subprocess.check_call(['npm', 'install', '.'])
|
|
|
|
|
|
|
|
|
2013-07-01 08:06:37 +00:00
|
|
|
def update_node_modules():
|
2013-07-17 08:29:40 +00:00
|
|
|
for dirname in ['.', 'browser/default_app', 'spec']:
|
|
|
|
update_node_modules_for_dir(dirname);
|
|
|
|
|
|
|
|
|
|
|
|
def update_node_modules_for_dir(dirname):
|
|
|
|
with scoped_cwd(dirname):
|
2013-08-03 08:39:54 +00:00
|
|
|
apm = os.path.join(SOURCE_ROOT, 'vendor', 'apm', 'bin', 'apm')
|
2013-08-06 12:14:28 +00:00
|
|
|
subprocess.check_call(['node', os.path.relpath(apm), 'install'])
|
2013-07-01 08:06:37 +00:00
|
|
|
|
|
|
|
|
2013-07-01 07:21:27 +00:00
|
|
|
def update_win32_python():
|
|
|
|
with scoped_cwd(VENDOR_DIR):
|
|
|
|
if not os.path.exists('python_26'):
|
|
|
|
subprocess.check_call(['git', 'clone', PYTHON_26_URL])
|
|
|
|
else:
|
|
|
|
with scoped_cwd('python_26'):
|
2013-07-24 10:33:49 +00:00
|
|
|
subprocess.check_call(['git', 'pull', '--rebase', 'origin', 'master'])
|
2013-07-01 07:21:27 +00:00
|
|
|
|
|
|
|
|
2013-07-02 01:16:56 +00:00
|
|
|
def touch_config_gypi():
|
|
|
|
config_gypi = os.path.join(SOURCE_ROOT, 'vendor', 'node', 'config.gypi')
|
2013-07-02 14:32:14 +00:00
|
|
|
with open(config_gypi, 'w+') as f:
|
|
|
|
content = '\n{}'
|
|
|
|
if f.read() != content:
|
|
|
|
f.write(content)
|
2013-07-02 01:16:56 +00:00
|
|
|
|
|
|
|
|
2013-06-19 06:32:41 +00:00
|
|
|
def update_atom_shell():
|
2013-06-24 07:24:30 +00:00
|
|
|
update = os.path.join(SOURCE_ROOT, 'script', 'update.py')
|
|
|
|
subprocess.check_call([sys.executable, update])
|
2013-06-19 06:32:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|