OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Script to install ARM root image for cross building of ARM chrome on linux. | 6 """Script to install ARM root image for cross building of ARM chrome on linux. |
7 This script can be run manually but is more often run as part of gclient | 7 This script can be run manually but is more often run as part of gclient |
8 hooks. When run from hooks this script should be a no-op on non-linux | 8 hooks. When run from hooks this script should be a no-op on non-linux |
9 platforms. | 9 platforms. |
10 | 10 |
11 The sysroot image could be constructed from scratch based on the current | 11 The sysroot image could be constructed from scratch based on the current |
12 state or precise/arm but for consistency we currently use a pre-built root | 12 state or precise/arm but for consistency we currently use a pre-built root |
13 image which was originally designed for building trusted NaCl code. The image | 13 image which was originally designed for building trusted NaCl code. The image |
14 will normally need to be rebuilt every time chrome's build dependancies are | 14 will normally need to be rebuilt every time chrome's build dependancies are |
15 changed. | 15 changed. |
16 | 16 |
17 Steps to rebuild the arm sysroot image: | 17 Steps to rebuild the arm sysroot image: |
18 | 18 |
19 - cd $SRC/native_client | 19 - cd $SRC/native_client |
20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ | 20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ |
21 UpdatePackageLists | 21 UpdatePackageLists |
22 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ | 22 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \ |
23 BuildJail $SRC/out/arm-sysroot.tar.gz | 23 BuildJail $SRC/out/arm-sysroot.tar.gz |
24 - gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \ | 24 - gsutil cp -a public-read $SRC/out/arm-sysroot.tar.gz \ |
25 nativeclient-archive2/toolchain/$NACL_REV/sysroot-arm-trusted.tgz | 25 nativeclient-archive2/toolchain/$NACL_REV/sysroot-arm-trusted.tgz |
26 """ | 26 """ |
27 | 27 |
| 28 # TODO(sbc): merge this script into: |
| 29 # chrome/installer/linux/sysroot_scripts/install-debian.wheezy.sysroot.py |
| 30 |
| 31 import hashlib |
28 import os | 32 import os |
29 import shutil | 33 import shutil |
30 import subprocess | 34 import subprocess |
31 import sys | 35 import sys |
32 | 36 |
33 | 37 |
34 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 38 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
35 URL_PREFIX = 'https://storage.googleapis.com' | 39 URL_PREFIX = 'https://storage.googleapis.com' |
36 URL_PATH = 'nativeclient-archive2/toolchain' | 40 URL_PATH = 'chrome-linux-sysroot/toolchain' |
37 REVISION = 13035 | 41 REVISION = 285950 |
38 TARBALL = 'sysroot-arm-trusted.tgz' | 42 TARBALL = 'debian_wheezy_arm_sysroot.tgz' |
| 43 TARBALL_SHA1SUM = 'fc2f54db168887c5190c4c6686c869bedf668b4e' |
| 44 |
| 45 |
| 46 def get_sha1(filename): |
| 47 sha1 = hashlib.sha1() |
| 48 with open(filename, 'rb') as f: |
| 49 while True: |
| 50 # Read in 1mb chunks, so it doesn't all have to be loaded into memory. |
| 51 chunk = f.read(1024*1024) |
| 52 if not chunk: |
| 53 break |
| 54 sha1.update(chunk) |
| 55 return sha1.hexdigest() |
| 56 |
39 | 57 |
40 def main(args): | 58 def main(args): |
41 if '--linux-only' in args: | 59 if '--linux-only' in args: |
42 # This argument is passed when run from the gclient hooks. | 60 # This argument is passed when run from the gclient hooks. |
43 # In this case we return early on non-linux platforms | 61 # In this case we return early on non-linux platforms |
44 # or if GYP_DEFINES doesn't include target_arch=arm | 62 # or if GYP_DEFINES doesn't include target_arch=arm |
45 if not sys.platform.startswith('linux'): | 63 if not sys.platform.startswith('linux'): |
46 return 0 | 64 return 0 |
47 | 65 |
48 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): | 66 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''): |
(...skipping 14 matching lines...) Expand all Loading... |
63 if os.path.isdir(sysroot): | 81 if os.path.isdir(sysroot): |
64 shutil.rmtree(sysroot) | 82 shutil.rmtree(sysroot) |
65 os.mkdir(sysroot) | 83 os.mkdir(sysroot) |
66 tarball = os.path.join(sysroot, TARBALL) | 84 tarball = os.path.join(sysroot, TARBALL) |
67 curl = ['curl', '--fail', '-L', url, '-o', tarball] | 85 curl = ['curl', '--fail', '-L', url, '-o', tarball] |
68 if os.isatty(sys.stdout.fileno()): | 86 if os.isatty(sys.stdout.fileno()): |
69 curl.append('--progress') | 87 curl.append('--progress') |
70 else: | 88 else: |
71 curl.append('--silent') | 89 curl.append('--silent') |
72 subprocess.check_call(curl) | 90 subprocess.check_call(curl) |
| 91 sha1sum = get_sha1(tarball) |
| 92 if sha1sum != TARBALL_SHA1SUM: |
| 93 print 'Tarball sha1sum is wrong.' |
| 94 print 'Expected %s, actual: %s' % (TARBALL_SHA1SUM, sha1sum) |
| 95 return 1 |
73 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 96 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
74 os.remove(tarball) | 97 os.remove(tarball) |
75 | 98 |
76 with open(stamp, 'w') as s: | 99 with open(stamp, 'w') as s: |
77 s.write(url) | 100 s.write(url) |
78 return 0 | 101 return 0 |
79 | 102 |
80 | 103 |
81 if __name__ == '__main__': | 104 if __name__ == '__main__': |
82 sys.exit(main(sys.argv[1:])) | 105 sys.exit(main(sys.argv[1:])) |
OLD | NEW |