blob: d7a9414d2d5ffee47c4064a6b5a878f132c0c1f7 [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.
15
16"""Pulls LUCI-generated binaries and generates .zip files for GitHub releases.
17
18Usage: ./tools/package_prebuilts_for_github_release v20.0
19
20This will generate one .zip file for every os-arch combo (e.g. android-arm.zip)
21into /tmp/perfetto-prebuilts-v20.0/ .
22"""
23
24import argparse
25import subprocess
26import os
27import sys
28
29
30def exec(*args):
31 print(' '.join(args))
32 subprocess.check_call(args)
33
34
35def main():
36 parser = argparse.ArgumentParser(epilog='Example %s v19.0' % __file__)
37 parser.add_argument('version')
38
39 args = parser.parse_args()
40 tmpdir = '/tmp/perfetto-prebuilts-' + args.version
41 src = 'gs://perfetto-luci-artifacts/%s/' % args.version
42 os.makedirs(tmpdir, exist_ok=True)
43 os.chdir(tmpdir)
44 exec('gsutil', '-m', 'rsync', '-rc', src, tmpdir + '/')
45 zips = []
46 for arch in os.listdir(tmpdir):
47 if not os.path.isdir(arch):
48 continue
49 exec('zip', '-9r', '%s.zip' % arch, arch)
50 zips.append(arch + '.zip')
51 print('')
52 print('%d zip files saved in %s (%s)' % (len(zips), tmpdir, ','.join(zips)))
53
54if __name__ == '__main__':
55 sys.exit(main())