Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
create.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright 2022 Google LLC
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8
9"""Create the asset."""
10
11
12import argparse
13import glob
14import os
15import shutil
16import subprocess
17import sys
18
19FILE_DIR = os.path.dirname(os.path.abspath(__file__))
20INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
21sys.path.insert(0, INFRA_BOTS_DIR)
22import utils
23
24# https://packages.debian.org/buster/amd64/binutils-x86-64-linux-gnu/download
25# The older version from buster has fewer dynamic library dependencies.
26URL = 'https://ftp.debian.org/debian/pool/main/b/binutils/binutils-x86-64-linux-gnu_2.31.1-16_amd64.deb'
27SHA256 = 'c1da1cffff8a024b5eca0a6795558d9e0ec88fbd24fe059490dc665dc5cac92f'
28
29# https://packages.debian.org/buster/amd64/binutils-x86-64-linux-gnu/filelist
30to_copy = {
31 # If we need other files, we can add them to this mapping.
32 'x86_64-linux-gnu-strip': 'strip',
33}
34
35
36def create_asset(target_dir):
37 with utils.tmp_dir():
38 subprocess.check_call(['wget', '--output-document=binutils.deb', '--quiet', URL])
39 output = subprocess.check_output(['sha256sum', 'binutils.deb'], encoding='utf-8')
40 actual_hash = output.split(' ')[0]
41 if actual_hash != SHA256:
42 raise Exception('SHA256 does not match (%s != %s)' % (actual_hash, SHA256))
43 # A .deb file is just a re-named .ar file...
44 subprocess.check_call(['ar', 'x', 'binutils.deb'])
45 # with a control.tar.xz and a data.tar.xz in it. The binaries are in the data one.
46 subprocess.check_call(['tar', '-xf', 'data.tar.xz'])
47 for (orig, copy) in to_copy.items():
48 shutil.copy(os.path.join('usr', 'bin', orig), os.path.join(target_dir, copy))
49
50
51def main():
52 parser = argparse.ArgumentParser()
53 parser.add_argument('--target_dir', '-t', required=True)
54 args = parser.parse_args()
55 create_asset(args.target_dir)
56
57
58if __name__ == '__main__':
59 main()
60
create_asset(target_dir)
Definition create.py:32
main()
Definition create.py:69
Definition main.py:1