OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Downloads the appengine SDK from WebRTC storage and unpacks it. | |
7 | |
8 Requires that depot_tools is installed and in the PATH. This script expects | |
9 to run with Chrome's base dir as the working directory, e.g. where the .gclient | |
10 file is. This is what should happen if this script is invoked as a hook action. | |
11 """ | |
12 | |
13 import glob | |
14 import os | |
15 import sys | |
16 import subprocess | |
17 | |
18 import utils | |
19 | |
20 def _DownloadResources(webrtc_deps_path): | |
21 print 'Downloading files in %s...' % webrtc_deps_path | |
22 | |
23 extension = 'bat' if 'win32' in sys.platform else 'py' | |
24 cmd = ['download_from_google_storage.%s' % extension, | |
25 '--bucket=chromium-webrtc-resources', | |
26 '--directory', webrtc_deps_path] | |
27 subprocess.check_call(cmd) | |
28 | |
29 | |
30 def _StripVersionNumberFromMercurialFolder(): | |
31 unpacked_name = glob.glob('mercurial*') | |
32 assert len(unpacked_name) == 1, 'Should have precisely one mercurial!' | |
33 os.rename(unpacked_name[0], 'mercurial') | |
34 | |
35 | |
36 def main(argv): | |
37 if len(argv) == 1: | |
38 return 'Usage: %s <path to webrtc.DEPS>' % argv[0] | |
39 | |
40 webrtc_deps_path = argv[1] | |
41 appengine_zip_path = os.path.join(webrtc_deps_path, 'google-appengine.zip') | |
42 old_appengine_sha1 = utils.ComputeSHA1(appengine_zip_path) | |
43 | |
44 mercurial_tar_path = os.path.join(webrtc_deps_path, 'mercurial-src.tar.gz') | |
45 old_mercurial_sha1 = utils.ComputeSHA1(mercurial_tar_path) | |
46 | |
47 _DownloadResources(webrtc_deps_path) | |
48 | |
49 if old_appengine_sha1 != utils.ComputeSHA1(appengine_zip_path): | |
50 utils.DeleteDirNextToGclient('google_appengine') | |
51 utils.UnpackToWorkingDir(appengine_zip_path) | |
52 | |
53 if old_mercurial_sha1 != utils.ComputeSHA1(mercurial_tar_path): | |
54 utils.DeleteDirNextToGclient('mercurial') | |
55 utils.UnpackToWorkingDir(mercurial_tar_path) | |
56 _StripVersionNumberFromMercurialFolder() | |
57 | |
58 if __name__ == '__main__': | |
59 sys.exit(main(sys.argv)) | |
OLD | NEW |