Increase safebrowsing download check timeout.
[chromium-blink-merge.git] / build / linux / install-arm-sysroot.py
blob5c278ea652e531958f53a5dd709750e7d9543ea4
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
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
8 hooks. When run from hooks this script should be a no-op on non-linux
9 platforms.
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
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
15 changed.
17 Steps to rebuild the arm sysroot image:
19 - cd $SRC/native_client
20 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
21 UpdatePackageLists
22 - ./tools/trusted_cross_toolchains/trusted-toolchain-creator.armel.precise.sh \
23 BuildJail $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
26 """
28 import os
29 import shutil
30 import subprocess
31 import sys
34 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
35 URL_PREFIX = 'https://storage.googleapis.com'
36 URL_PATH = 'nativeclient-archive2/toolchain'
37 REVISION = 13035
38 TARBALL = 'sysroot-arm-trusted.tgz'
40 def main(args):
41 if '--linux-only' in args:
42 # This argument is passed when run from the gclient hooks.
43 # In this case we return early on non-linux platforms
44 # or if GYP_DEFINES doesn't include target_arch=arm
45 if not sys.platform.startswith('linux'):
46 return 0
48 if "target_arch=arm" not in os.environ.get('GYP_DEFINES', ''):
49 return 0
51 src_root = os.path.dirname(os.path.dirname(SCRIPT_DIR))
52 sysroot = os.path.join(src_root, 'arm-sysroot')
53 url = "%s/%s/%s/%s" % (URL_PREFIX, URL_PATH, REVISION, TARBALL)
55 stamp = os.path.join(sysroot, ".stamp")
56 if os.path.exists(stamp):
57 with open(stamp) as s:
58 if s.read() == url:
59 print "ARM root image already up-to-date: %s" % sysroot
60 return 0
62 print "Installing ARM root image: %s" % sysroot
63 if os.path.isdir(sysroot):
64 shutil.rmtree(sysroot)
65 os.mkdir(sysroot)
66 tarball = os.path.join(sysroot, TARBALL)
67 curl = ['curl', '--fail', '-L', url, '-o', tarball]
68 if os.isatty(sys.stdout.fileno()):
69 curl.append('--progress')
70 else:
71 curl.append('--silent')
72 subprocess.check_call(curl)
73 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot])
74 os.remove(tarball)
76 with open(stamp, 'w') as s:
77 s.write(url)
78 return 0
81 if __name__ == '__main__':
82 sys.exit(main(sys.argv[1:]))