OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Install Debian sysroots for building chromium. | 6 """Install Debian sysroots for building chromium. |
7 """ | 7 """ |
8 | 8 |
9 # The sysroot is needed to ensure that binaries will run on Debian Wheezy, | 9 # The sysroot is needed to ensure that binaries will run on Debian Wheezy, |
10 # the oldest supported linux distribution. For ARM64 linux, we have Debian | 10 # the oldest supported linux distribution. For ARM64 linux, we have Debian |
11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script | 11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script |
12 # can be run manually but is more often run as part of gclient hooks. When run | 12 # can be run manually but is more often run as part of gclient hooks. When run |
13 # from hooks this script is a no-op on non-linux platforms. | 13 # from hooks this script is a no-op on non-linux platforms. |
14 | 14 |
15 # The sysroot image could be constructed from scratch based on the current | 15 # The sysroot image could be constructed from scratch based on the current |
16 # state or Debian Wheezy/Jessie but for consistency we currently use a | 16 # state or Debian Wheezy/Jessie but for consistency we currently use a |
17 # pre-built root image. The image will normally need to be rebuilt every time | 17 # pre-built root image. The image will normally need to be rebuilt every time |
18 # chrome's build dependencies are changed. | 18 # chrome's build dependencies are changed. |
19 | 19 |
20 import hashlib | 20 import hashlib |
21 import platform | 21 import platform |
22 import optparse | 22 import optparse |
23 import os | 23 import os |
24 import re | 24 import re |
25 import shutil | 25 import shutil |
26 import subprocess | 26 import subprocess |
27 import sys | 27 import sys |
| 28 import urllib |
28 | 29 |
29 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 30 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
30 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR))) | 31 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR))) |
31 import detect_host_arch | 32 import detect_host_arch |
32 import gyp_chromium | 33 import gyp_chromium |
33 import gyp_environment | 34 import gyp_environment |
34 | 35 |
35 | 36 |
36 URL_PREFIX = 'https://commondatastorage.googleapis.com' | 37 URL_PREFIX = 'https://commondatastorage.googleapis.com' |
37 URL_PATH = 'chrome-linux-sysroot/toolchain' | 38 URL_PATH = 'chrome-linux-sysroot/toolchain' |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 239 |
239 print 'Installing Debian %s %s root image: %s' % \ | 240 print 'Installing Debian %s %s root image: %s' % \ |
240 (target_platform, target_arch, sysroot) | 241 (target_platform, target_arch, sysroot) |
241 if os.path.isdir(sysroot): | 242 if os.path.isdir(sysroot): |
242 shutil.rmtree(sysroot) | 243 shutil.rmtree(sysroot) |
243 os.mkdir(sysroot) | 244 os.mkdir(sysroot) |
244 tarball = os.path.join(sysroot, tarball_filename) | 245 tarball = os.path.join(sysroot, tarball_filename) |
245 print 'Downloading %s' % url | 246 print 'Downloading %s' % url |
246 sys.stdout.flush() | 247 sys.stdout.flush() |
247 sys.stderr.flush() | 248 sys.stderr.flush() |
248 subprocess.check_call( | 249 for _ in range(3): |
249 ['wget', '--quiet', '-t', '3', '-O', tarball, url]) | 250 try: |
| 251 urllib.urlretrieve(url, tarball) |
| 252 break |
| 253 except: |
| 254 pass |
| 255 else: |
| 256 raise Error('Failed to download %s' % url) |
250 sha1sum = GetSha1(tarball) | 257 sha1sum = GetSha1(tarball) |
251 if sha1sum != tarball_sha1sum: | 258 if sha1sum != tarball_sha1sum: |
252 raise Error('Tarball sha1sum is wrong.' | 259 raise Error('Tarball sha1sum is wrong.' |
253 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) | 260 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) |
254 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 261 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
255 os.remove(tarball) | 262 os.remove(tarball) |
256 | 263 |
257 with open(stamp, 'w') as s: | 264 with open(stamp, 'w') as s: |
258 s.write(url) | 265 s.write(url) |
259 | 266 |
260 | 267 |
261 if __name__ == '__main__': | 268 if __name__ == '__main__': |
262 try: | 269 try: |
263 sys.exit(main(sys.argv[1:])) | 270 sys.exit(main(sys.argv[1:])) |
264 except Error as e: | 271 except Error as e: |
265 sys.stderr.write(str(e) + '\n') | 272 sys.stderr.write(str(e) + '\n') |
266 sys.exit(1) | 273 sys.exit(1) |
OLD | NEW |