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 import urllib2 |
29 | 29 |
30 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 30 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
31 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR))) | 31 sys.path.append(os.path.dirname(os.path.dirname(SCRIPT_DIR))) |
32 import detect_host_arch | 32 import detect_host_arch |
33 import gyp_chromium | 33 import gyp_chromium |
34 import gyp_environment | 34 import gyp_environment |
35 | 35 |
36 | 36 |
37 URL_PREFIX = 'https://commondatastorage.googleapis.com' | 37 URL_PREFIX = 'https://commondatastorage.googleapis.com' |
38 URL_PATH = 'chrome-linux-sysroot/toolchain' | 38 URL_PATH = 'chrome-linux-sysroot/toolchain' |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 (target_platform, target_arch, sysroot) | 241 (target_platform, target_arch, sysroot) |
242 if os.path.isdir(sysroot): | 242 if os.path.isdir(sysroot): |
243 shutil.rmtree(sysroot) | 243 shutil.rmtree(sysroot) |
244 os.mkdir(sysroot) | 244 os.mkdir(sysroot) |
245 tarball = os.path.join(sysroot, tarball_filename) | 245 tarball = os.path.join(sysroot, tarball_filename) |
246 print 'Downloading %s' % url | 246 print 'Downloading %s' % url |
247 sys.stdout.flush() | 247 sys.stdout.flush() |
248 sys.stderr.flush() | 248 sys.stderr.flush() |
249 for _ in range(3): | 249 for _ in range(3): |
250 try: | 250 try: |
251 urllib.urlretrieve(url, tarball) | 251 response = urllib2.urlopen(url) |
| 252 with open(tarball, "wb") as f: |
| 253 f.write(response.read()) |
252 break | 254 break |
253 except: | 255 except: |
254 pass | 256 pass |
255 else: | 257 else: |
256 raise Error('Failed to download %s' % url) | 258 raise Error('Failed to download %s' % url) |
257 sha1sum = GetSha1(tarball) | 259 sha1sum = GetSha1(tarball) |
258 if sha1sum != tarball_sha1sum: | 260 if sha1sum != tarball_sha1sum: |
259 raise Error('Tarball sha1sum is wrong.' | 261 raise Error('Tarball sha1sum is wrong.' |
260 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) | 262 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) |
261 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 263 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
262 os.remove(tarball) | 264 os.remove(tarball) |
263 | 265 |
264 with open(stamp, 'w') as s: | 266 with open(stamp, 'w') as s: |
265 s.write(url) | 267 s.write(url) |
266 | 268 |
267 | 269 |
268 if __name__ == '__main__': | 270 if __name__ == '__main__': |
269 try: | 271 try: |
270 sys.exit(main(sys.argv[1:])) | 272 sys.exit(main(sys.argv[1:])) |
271 except Error as e: | 273 except Error as e: |
272 sys.stderr.write(str(e) + '\n') | 274 sys.stderr.write(str(e) + '\n') |
273 sys.exit(1) | 275 sys.exit(1) |
OLD | NEW |