2021-04-28 08:46:51 -07:00
|
|
|
#!/usr/bin/env python3
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2022-09-06 19:14:07 -04:00
|
|
|
# Copyright 2018 The Crashpad Authors
|
2018-02-23 20:27:50 -08:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
# Various code adapted from:
|
|
|
|
# https://cs.chromium.org/chromium/src/build/linux/sysroot_scripts/install-sysroot.py
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2021-04-28 08:46:51 -07:00
|
|
|
import urllib.request
|
2018-02-23 20:27:50 -08:00
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
# Sysroot revision from:
|
|
|
|
# https://cs.chromium.org/chromium/src/build/linux/sysroot_scripts/sysroots.json
|
|
|
|
SERVER = 'https://commondatastorage.googleapis.com'
|
|
|
|
PATH = 'chrome-linux-sysroot/toolchain'
|
2021-04-06 10:55:41 -07:00
|
|
|
REVISION = '43a87bbebccad99325fdcf34166295b121ee15c7'
|
|
|
|
FILENAME = 'debian_sid_amd64_sysroot.tar.xz'
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
|
2018-02-23 20:27:50 -08:00
|
|
|
def main():
|
2020-04-27 09:43:35 -04:00
|
|
|
url = '%s/%s/%s/%s' % (SERVER, PATH, REVISION, FILENAME)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
sysroot = os.path.join(SCRIPT_DIR, os.pardir, 'third_party', 'linux',
|
|
|
|
'sysroot')
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
stamp = os.path.join(sysroot, '.stamp')
|
|
|
|
if os.path.exists(stamp):
|
|
|
|
with open(stamp) as s:
|
|
|
|
if s.read() == url:
|
|
|
|
return
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2021-04-28 08:46:51 -07:00
|
|
|
print('Installing Debian root image from %s' % url)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
if os.path.isdir(sysroot):
|
|
|
|
shutil.rmtree(sysroot)
|
|
|
|
os.mkdir(sysroot)
|
|
|
|
tarball = os.path.join(sysroot, FILENAME)
|
2021-04-28 08:46:51 -07:00
|
|
|
print('Downloading %s' % url)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
for _ in range(3):
|
2021-04-28 08:46:51 -07:00
|
|
|
response = urllib.request.urlopen(url)
|
2020-04-27 09:43:35 -04:00
|
|
|
with open(tarball, 'wb') as f:
|
|
|
|
f.write(response.read())
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception('Failed to download %s' % url)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
subprocess.check_call(['tar', 'xf', tarball, '-C', sysroot])
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
os.remove(tarball)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
2020-04-27 09:43:35 -04:00
|
|
|
with open(stamp, 'w') as s:
|
|
|
|
s.write(url)
|
2018-02-23 20:27:50 -08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-04-27 09:43:35 -04:00
|
|
|
main()
|
|
|
|
sys.exit(0)
|