blob: 6c326cdc6f3d124bbbf469c3193020d458a06df8 [file] [log] [blame]
Fergus Dall1cf37202020-10-09 16:09:59 +11001#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2020 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Uprev crostini tast data dependencies"""
8
9import argparse
10import subprocess
11import shlex
12import json
13import os
14
15def update_data_file(url, filepath):
16 result = {'url': url}
17 ls = subprocess.check_output(['gsutil.py', 'ls', '-l', url])
18 result['size'] = int(ls.decode().split()[0])
19
20 sha256sum = subprocess.check_output(
21 f'gsutil.py cp {shlex.quote(url)} - | sha256sum'
22 , shell=True)
23 result['sha256sum'] = sha256sum.decode().split()[0]
24
25 print(f'Updated {os.path.basename(filepath)}')
26 with open(filepath, 'w') as f:
27 json.dump(result, f, indent=4, sort_keys=True)
28
29def main():
30 parser = argparse.ArgumentParser(description=__doc__)
31 parser.add_argument(
32 'milestone', help='milestone number, e.g. 78')
33 args = parser.parse_args()
34 milestone = args.milestone
35
36 tast_tests = subprocess.check_output(
37 ['repo', 'list', '-pf', 'chromiumos/platform/tast-tests']
38 ).decode().strip()
39 data_dir = os.path.join(tast_tests,
40 'src/chromiumos/tast/local/crostini/data')
41
42 latest_container = subprocess.check_output(
43 ['gsutil.py', 'ls', f'gs://cros-containers-staging/{milestone}'
44 '/images/debian/buster/arm64/default/']
45 ).decode().split()[-1].split('/')[-2]
46 latest_vm = subprocess.check_output(
47 ['gsutil.py', 'ls', f'gs://termina-component-testing/{milestone}/']
48 ).decode().split()[-1].split('/')[-2]
49
50 for arch in ['amd64', 'arm64']:
51 # The container URLs use 'arm64', but the tast data files use 'arm'
52 if arch == 'arm64':
53 file_arch = 'arm'
54 else:
55 file_arch = arch
56
57 for ctype in ['test', 'app_test']:
Fergus Dallfb64d2f2020-12-03 18:49:50 +110058 for release in ['buster']:
Fergus Dall1cf37202020-10-09 16:09:59 +110059 base_url = f'gs://cros-containers-staging/{milestone}' \
60 f'/images/debian/{release}/{arch}/{ctype}/{latest_container}/'
61
62 metadata_file = f'crostini_{ctype}_container_metadata_{release}' \
63 f'_{file_arch}.tar.xz.external'
64 update_data_file(base_url + 'lxd.tar.xz',
65 os.path.join(data_dir, metadata_file))
66
67 rootfs_file = f'crostini_{ctype}_container_rootfs_{release}' \
68 f'_{file_arch}.tar.xz.external'
69 update_data_file(base_url + 'rootfs.tar.xz',
70 os.path.join(data_dir, rootfs_file))
71
72 if arch == 'amd64':
73 vm_arch = 'chromeos_intel64-archive'
74 else:
75 vm_arch = 'chromeos_arm32-archive'
76 update_data_file(f'gs://termina-component-testing/{milestone}'
77 f'/{latest_vm}/{vm_arch}/files.zip',
78 os.path.join(
79 data_dir, f'crostini_vm_{file_arch}.zip.external'))
80
81 print('Tast data dependencies updated')
82 print(f'Go to {data_dir} and create a CL')
83
84if __name__ == '__main__':
85 main()