blob: 4c638f552cd2926048b90b847101e289049229aa [file] [log] [blame]
Primiano Tucci5df05572021-10-05 11:15:51 +01001#!/usr/bin/env python3
2# Copyright (C) 2021 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Primiano Tucci5df05572021-10-05 11:15:51 +010015"""Pulls LUCI-generated binaries and generates .zip files for GitHub releases.
16
17Usage: ./tools/package_prebuilts_for_github_release v20.0
18
19This will generate one .zip file for every os-arch combo (e.g. android-arm.zip)
20into /tmp/perfetto-prebuilts-v20.0/ .
21"""
22
23import argparse
24import subprocess
25import os
26import sys
27
28
29def exec(*args):
30 print(' '.join(args))
31 subprocess.check_call(args)
32
33
34def main():
35 parser = argparse.ArgumentParser(epilog='Example %s v19.0' % __file__)
36 parser.add_argument('version')
37
38 args = parser.parse_args()
39 tmpdir = '/tmp/perfetto-prebuilts-' + args.version
40 src = 'gs://perfetto-luci-artifacts/%s/' % args.version
41 os.makedirs(tmpdir, exist_ok=True)
42 os.chdir(tmpdir)
43 exec('gsutil', '-m', 'rsync', '-rc', src, tmpdir + '/')
44 zips = []
45 for arch in os.listdir(tmpdir):
46 if not os.path.isdir(arch):
47 continue
48 exec('zip', '-9r', '%s.zip' % arch, arch)
49 zips.append(arch + '.zip')
50 print('')
51 print('%d zip files saved in %s (%s)' % (len(zips), tmpdir, ','.join(zips)))
52
Hector Dearmanb1989b02022-07-05 20:11:07 +010053
Primiano Tucci5df05572021-10-05 11:15:51 +010054if __name__ == '__main__':
55 sys.exit(main())