| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import urllib | 10 import urllib |
| 11 | 11 |
| 12 IS_WIN = sys.platform.startswith('win') | 12 IS_WIN = sys.platform.startswith('win') |
| 13 BASE_URL = 'http://src.chromium.org/svn/trunk/tools/buildbot/scripts/' | 13 BASE_URL = 'http://src.chromium.org/svn/trunk/tools/buildbot/scripts/' |
| 14 COMPILE_URL = BASE_URL + 'slave/compile.py' | 14 COMPILE_URL = BASE_URL + 'slave/compile.py' |
| 15 UTILS_URL = BASE_URL + 'common/chromium_utils.py' | 15 UTILS_URL = BASE_URL + 'common/chromium_utils.py' |
| 16 | 16 |
| 17 | 17 |
| 18 def Fetch(url, file): | 18 def Fetch(url, filename): |
| 19 if not os.path.exists(file): | 19 if not os.path.exists(filename): |
| 20 urllib.urlretrieve(url, file) | 20 urllib.urlretrieve(url, filename) |
| 21 | 21 |
| 22 | 22 |
| 23 def GetLastestRevision(): | 23 def GetLastestRevision(): |
| 24 """Returns the revision number of the last build that was archived, or | 24 """Returns the revision number of the last build that was archived, or |
| 25 None on failure.""" | 25 None on failure.""" |
| 26 url = 'http://build.chromium.org/buildbot/continuous/' | 26 url = 'http://build.chromium.org/buildbot/continuous/' |
| 27 if sys.platform.startswith('win'): | 27 if sys.platform.startswith('win'): |
| 28 url += 'win/' | 28 url += 'win/' |
| 29 elif sys.platform.startswith('linux'): | 29 elif sys.platform.startswith('linux'): |
| 30 url += 'linux/' | 30 url += 'linux/' |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 """gclient sync to the latest build.""" | 46 """gclient sync to the latest build.""" |
| 47 cmd = ["gclient", "sync"] | 47 cmd = ["gclient", "sync"] |
| 48 rev = GetLastestRevision() | 48 rev = GetLastestRevision() |
| 49 if rev: | 49 if rev: |
| 50 cmd.extend(['--revision', 'src@%d' % rev]) | 50 cmd.extend(['--revision', 'src@%d' % rev]) |
| 51 return subprocess.call(cmd, cwd=chrome_root, shell=IS_WIN) | 51 return subprocess.call(cmd, cwd=chrome_root, shell=IS_WIN) |
| 52 | 52 |
| 53 | 53 |
| 54 def DoBuild(chrome_root, args): | 54 def DoBuild(chrome_root, args): |
| 55 """Download compile.py and run it.""" | 55 """Download compile.py and run it.""" |
| 56 compile = os.path.join(chrome_root, 'compile.py') | 56 compile_path = os.path.join(chrome_root, 'compile.py') |
| 57 Fetch(COMPILE_URL, compile) | 57 Fetch(COMPILE_URL, compile_path) |
| 58 Fetch(UTILS_URL, os.path.join(chrome_root, 'chromium_utils.py')) | 58 Fetch(UTILS_URL, os.path.join(chrome_root, 'chromium_utils.py')) |
| 59 cmd = ['python', compile] + args | 59 cmd = ['python', compile_path] + args |
| 60 return subprocess.call(cmd, cwd=chrome_root, shell=IS_WIN) | 60 return subprocess.call(cmd, cwd=chrome_root, shell=IS_WIN) |
| 61 | 61 |
| 62 | 62 |
| 63 def Main(args): | 63 def Main(args): |
| 64 if len(args) < 3: | 64 if len(args) < 3: |
| 65 print('Usage: chrome-update.py <path> [options]') | 65 print('Usage: chrome-update.py <path> [options]') |
| 66 print('See options from compile.py at') | 66 print('See options from compile.py at') |
| 67 print(' %s' % COMPILE_URL) | 67 print(' %s' % COMPILE_URL) |
| 68 print('\nFor more example, see the compile steps on the waterfall') | 68 print('\nFor more example, see the compile steps on the waterfall') |
| 69 return 1 | 69 return 1 |
| 70 | 70 |
| 71 chrome_root = args[1] | 71 chrome_root = args[1] |
| 72 if not os.path.isdir(chrome_root): | 72 if not os.path.isdir(chrome_root): |
| 73 print('Path to chrome root (%s) not found.' % chrome_root) | 73 print('Path to chrome root (%s) not found.' % chrome_root) |
| 74 return 1 | 74 return 1 |
| 75 | 75 |
| 76 rv = DoUpdate(chrome_root) | 76 rv = DoUpdate(chrome_root) |
| 77 if rv != 0: | 77 if rv != 0: |
| 78 print('Update Failed. Bailing.') | 78 print('Update Failed. Bailing.') |
| 79 return rv | 79 return rv |
| 80 | 80 |
| 81 DoBuild(chrome_root, args[2:]) | 81 DoBuild(chrome_root, args[2:]) |
| 82 print('Success!') | 82 print('Success!') |
| 83 return 0 | 83 return 0 |
| 84 | 84 |
| 85 | 85 |
| 86 if __name__ == "__main__": | 86 if __name__ == "__main__": |
| 87 sys.exit(Main(sys.argv)) | 87 sys.exit(Main(sys.argv)) |
| OLD | NEW |