| 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 Wheezy 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. This script can be run manually but | 10 # the oldest supported linux distribution. For ARM64 linux, we have Debian |
| 11 # is more often run as part of gclient hooks. When run from hooks this script | 11 # Jessie sysroot as Jessie is the first version with ARM64 support. This script |
| 12 # in a no-op on non-linux platforms. | 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 | 14 |
| 14 # 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 |
| 15 # state or Debian Wheezy but for consistency we currently use a pre-built root | 16 # state or Debian Wheezy/Jessie but for consistency we currently use a |
| 16 # image. The image will normally need to be rebuilt every time chrome's build | 17 # pre-built root image. The image will normally need to be rebuilt every time |
| 17 # dependencies are changed. | 18 # chrome's build dependencies are changed. |
| 18 | 19 |
| 19 import hashlib | 20 import hashlib |
| 20 import platform | 21 import platform |
| 21 import optparse | 22 import optparse |
| 22 import os | 23 import os |
| 23 import re | 24 import re |
| 24 import shutil | 25 import shutil |
| 25 import subprocess | 26 import subprocess |
| 26 import sys | 27 import sys |
| 27 | 28 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 InstallSysroot(options.arch) | 158 InstallSysroot(options.arch) |
| 158 | 159 |
| 159 return 0 | 160 return 0 |
| 160 | 161 |
| 161 | 162 |
| 162 def InstallSysroot(target_arch): | 163 def InstallSysroot(target_arch): |
| 163 # The sysroot directory should match the one specified in build/common.gypi. | 164 # The sysroot directory should match the one specified in build/common.gypi. |
| 164 # TODO(thestig) Consider putting this else where to avoid having to recreate | 165 # TODO(thestig) Consider putting this else where to avoid having to recreate |
| 165 # it on every build. | 166 # it on every build. |
| 166 linux_dir = os.path.dirname(SCRIPT_DIR) | 167 linux_dir = os.path.dirname(SCRIPT_DIR) |
| 168 debian_release = 'Wheezy' |
| 167 if target_arch == 'amd64': | 169 if target_arch == 'amd64': |
| 168 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) | 170 sysroot = os.path.join(linux_dir, SYSROOT_DIR_AMD64) |
| 169 tarball_filename = TARBALL_AMD64 | 171 tarball_filename = TARBALL_AMD64 |
| 170 tarball_sha1sum = TARBALL_AMD64_SHA1SUM | 172 tarball_sha1sum = TARBALL_AMD64_SHA1SUM |
| 171 revision = REVISION_AMD64 | 173 revision = REVISION_AMD64 |
| 172 elif target_arch == 'arm': | 174 elif target_arch == 'arm': |
| 173 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM) | 175 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM) |
| 174 tarball_filename = TARBALL_ARM | 176 tarball_filename = TARBALL_ARM |
| 175 tarball_sha1sum = TARBALL_ARM_SHA1SUM | 177 tarball_sha1sum = TARBALL_ARM_SHA1SUM |
| 176 revision = REVISION_ARM | 178 revision = REVISION_ARM |
| 177 elif target_arch == 'arm64': | 179 elif target_arch == 'arm64': |
| 180 debian_release = 'Jessie' |
| 178 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM64) | 181 sysroot = os.path.join(linux_dir, SYSROOT_DIR_ARM64) |
| 179 tarball_filename = TARBALL_ARM64 | 182 tarball_filename = TARBALL_ARM64 |
| 180 tarball_sha1sum = TARBALL_ARM64_SHA1SUM | 183 tarball_sha1sum = TARBALL_ARM64_SHA1SUM |
| 181 revision = REVISION_ARM64 | 184 revision = REVISION_ARM64 |
| 182 elif target_arch == 'i386': | 185 elif target_arch == 'i386': |
| 183 sysroot = os.path.join(linux_dir, SYSROOT_DIR_I386) | 186 sysroot = os.path.join(linux_dir, SYSROOT_DIR_I386) |
| 184 tarball_filename = TARBALL_I386 | 187 tarball_filename = TARBALL_I386 |
| 185 tarball_sha1sum = TARBALL_I386_SHA1SUM | 188 tarball_sha1sum = TARBALL_I386_SHA1SUM |
| 186 revision = REVISION_I386 | 189 revision = REVISION_I386 |
| 187 elif target_arch == 'mips': | 190 elif target_arch == 'mips': |
| 188 sysroot = os.path.join(linux_dir, SYSROOT_DIR_MIPS) | 191 sysroot = os.path.join(linux_dir, SYSROOT_DIR_MIPS) |
| 189 tarball_filename = TARBALL_MIPS | 192 tarball_filename = TARBALL_MIPS |
| 190 tarball_sha1sum = TARBALL_MIPS_SHA1SUM | 193 tarball_sha1sum = TARBALL_MIPS_SHA1SUM |
| 191 revision = REVISION_MIPS | 194 revision = REVISION_MIPS |
| 192 else: | 195 else: |
| 193 raise Error('Unknown architecture: %s' % target_arch) | 196 raise Error('Unknown architecture: %s' % target_arch) |
| 194 | 197 |
| 195 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename) | 198 url = '%s/%s/%s/%s' % (URL_PREFIX, URL_PATH, revision, tarball_filename) |
| 196 | 199 |
| 197 stamp = os.path.join(sysroot, '.stamp') | 200 stamp = os.path.join(sysroot, '.stamp') |
| 198 if os.path.exists(stamp): | 201 if os.path.exists(stamp): |
| 199 with open(stamp) as s: | 202 with open(stamp) as s: |
| 200 if s.read() == url: | 203 if s.read() == url: |
| 201 print 'Debian Wheezy %s root image already up to date: %s' % \ | 204 print 'Debian %s %s root image already up to date: %s' % \ |
| 202 (target_arch, sysroot) | 205 (debian_release, target_arch, sysroot) |
| 203 return | 206 return |
| 204 | 207 |
| 205 print 'Installing Debian Wheezy %s root image: %s' % (target_arch, sysroot) | 208 print 'Installing Debian %s %s root image: %s' % \ |
| 209 (debian_release, target_arch, sysroot) |
| 206 if os.path.isdir(sysroot): | 210 if os.path.isdir(sysroot): |
| 207 shutil.rmtree(sysroot) | 211 shutil.rmtree(sysroot) |
| 208 os.mkdir(sysroot) | 212 os.mkdir(sysroot) |
| 209 tarball = os.path.join(sysroot, tarball_filename) | 213 tarball = os.path.join(sysroot, tarball_filename) |
| 210 print 'Downloading %s' % url | 214 print 'Downloading %s' % url |
| 211 sys.stdout.flush() | 215 sys.stdout.flush() |
| 212 sys.stderr.flush() | 216 sys.stderr.flush() |
| 213 subprocess.check_call( | 217 subprocess.check_call( |
| 214 ['curl', '--fail', '--retry', '3', '-L', url, '-o', tarball]) | 218 ['curl', '--fail', '--retry', '3', '-L', url, '-o', tarball]) |
| 215 sha1sum = GetSha1(tarball) | 219 sha1sum = GetSha1(tarball) |
| 216 if sha1sum != tarball_sha1sum: | 220 if sha1sum != tarball_sha1sum: |
| 217 raise Error('Tarball sha1sum is wrong.' | 221 raise Error('Tarball sha1sum is wrong.' |
| 218 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) | 222 'Expected %s, actual: %s' % (tarball_sha1sum, sha1sum)) |
| 219 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) | 223 subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot]) |
| 220 os.remove(tarball) | 224 os.remove(tarball) |
| 221 | 225 |
| 222 with open(stamp, 'w') as s: | 226 with open(stamp, 'w') as s: |
| 223 s.write(url) | 227 s.write(url) |
| 224 | 228 |
| 225 | 229 |
| 226 if __name__ == '__main__': | 230 if __name__ == '__main__': |
| 227 try: | 231 try: |
| 228 sys.exit(main(sys.argv[1:])) | 232 sys.exit(main(sys.argv[1:])) |
| 229 except Error as e: | 233 except Error as e: |
| 230 sys.stderr.write(str(e) + '\n') | 234 sys.stderr.write(str(e) + '\n') |
| 231 sys.exit(1) | 235 sys.exit(1) |
| OLD | NEW |