From a306da18faa68ba090ac200af8cf9d6075deacfc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 29 Aug 2014 02:16:47 +0000 Subject: [PATCH] Use git workflow. --- script/bootstrap | 26 +++++++++++++++++++++++++- script/update | 23 ++++++++++++----------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index f0051147..4996bbc0 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,14 +1,19 @@ #!/usr/bin/env python +import errno import os +import shutil import subprocess import sys SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -DEPOT_TOOLS_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools') +VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor') +DEPOT_TOOLS_DIR = os.path.join(VENDOR_DIR, 'depot_tools') DEPOT_TOOLS_URL = \ 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' +CHROMIUM_DIR = os.path.join(VENDOR_DIR, 'chromium') +SRC_DIR = os.path.join(CHROMIUM_DIR, 'src') def main(): @@ -32,9 +37,28 @@ def main(): if result: return result + # Clean out old svn checkout. + if os.path.isdir(os.path.join(SRC_DIR, '.svn')): + rm_rf(SRC_DIR) + + if not os.path.isdir(SRC_DIR): + os.chdir(CHROMIUM_DIR) + fetch = os.path.join(DEPOT_TOOLS_DIR, 'fetch.py') + result = subprocess.call([fetch, 'chromium']) + if result: + return result; + update = os.path.join(SOURCE_ROOT, 'script', 'update') return subprocess.call([sys.executable, update]) +def rm_rf(path): + try: + shutil.rmtree(path) + except OSError as e: + if e.errno != errno.ENOENT: + raise + + if __name__ == '__main__': sys.exit(main()) diff --git a/script/update b/script/update index 9b5b6bbb..2f6c6795 100755 --- a/script/update +++ b/script/update @@ -16,7 +16,7 @@ CHROMIUMCONTENT_DESTINATION_DIR = os.path.join(SRC_DIR, 'chromiumcontent') def main(): - return (write_dot_gclient() or + return (checkout_version() or gclient_sync() or apply_patches() or copy_chromiumcontent_files() or @@ -24,21 +24,22 @@ def main(): install_win_tool_wrapper()) -def write_dot_gclient(): - template = os.path.join(CHROMIUM_DIR, '.gclient.in') - destination = os.path.join(CHROMIUM_DIR, '.gclient') - version = chromium_version() - with open(template) as t: - with open(destination, 'w') as d: - for line in t: - d.write(line.replace('{{VERSION}}', version)) - - def chromium_version(): with open(os.path.join(SOURCE_ROOT, 'VERSION')) as f: return f.readline().strip() +def checkout_version(): + os.chdir(SRC_DIR) + result = subprocess.call(['git', 'fetch', '--tags']) + if result: + return result + result = subprocess.call(['git', 'checkout', + 'refs/tags/{0}'.format(chromium_version())]) + if result: + return result + + def gclient_sync(): gclient = os.path.join(DEPOT_TOOLS_DIR, 'gclient.py') os.chdir(CHROMIUM_DIR)