2013-05-13 22:53:23 +00:00
|
|
|
#!/usr/bin/env python
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2013-05-13 22:53:23 +00:00
|
|
|
import argparse
|
|
|
|
import errno
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
|
2013-05-13 22:53:23 +00:00
|
|
|
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')
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
|
2013-05-13 22:53:23 +00:00
|
|
|
def main():
|
2015-04-02 06:05:43 +00:00
|
|
|
args = parse_args()
|
|
|
|
return (update_submodules() or
|
|
|
|
download_libchromiumcontent(args.commit, args.url))
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
|
2013-05-13 22:53:23 +00:00
|
|
|
def parse_args():
|
2015-04-02 06:05:43 +00:00
|
|
|
parser = argparse.ArgumentParser(description='Bootstrap this project')
|
|
|
|
parser.add_argument('-c', '--commit', nargs='?', default='HEAD',
|
|
|
|
help='The commit of libchromiumcontent to download.')
|
|
|
|
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()
|
2013-05-13 22:53:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def update_submodules():
|
2015-04-02 06:05:43 +00:00
|
|
|
return
|
|
|
|
return (subprocess.call(['git', 'submodule', 'sync', '--quiet']) or
|
|
|
|
subprocess.call(['git', 'submodule', 'update', '--init',
|
|
|
|
'--recursive']))
|
2013-05-13 22:53:23 +00:00
|
|
|
|
|
|
|
|
2014-01-30 14:01:22 +00:00
|
|
|
def download_libchromiumcontent(commit, url):
|
2015-04-02 06:05:43 +00:00
|
|
|
mkdir_p(DOWNLOAD_DIR)
|
|
|
|
download = os.path.join(VENDOR_DIR, 'libchromiumcontent', 'script',
|
|
|
|
'download')
|
|
|
|
return subprocess.call([sys.executable, download, '-f', '-c', commit, url,
|
|
|
|
os.path.join(DOWNLOAD_DIR, 'libchromiumcontent')])
|
2013-05-13 22:53:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def mkdir_p(path):
|
2015-04-02 06:05:43 +00:00
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EEXIST:
|
|
|
|
raise
|
2013-05-13 22:53:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-04-02 06:05:43 +00:00
|
|
|
sys.exit(main())
|