blob: 5590d29a44bbb70c89521bed12214cbc6daa436a [file] [log] [blame]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Uprev crostini tast data dependencies"""
import argparse
import subprocess
import shlex
import json
import os
def update_data_file(url, filepath):
result = {'url': url}
ls = subprocess.check_output(['', 'ls', '-l', url])
result['size'] = int(ls.decode().split()[0])
sha256sum = subprocess.check_output(
f' cp {shlex.quote(url)} - | sha256sum'
, shell=True)
result['sha256sum'] = sha256sum.decode().split()[0]
print(f'Updated {os.path.basename(filepath)}')
with open(filepath, 'w') as f:
json.dump(result, f, indent=4, sort_keys=True)
def main():
parser = argparse.ArgumentParser(description=__doc__)
'milestone', help='milestone number, e.g. 78')
args = parser.parse_args()
milestone = args.milestone
tast_tests = subprocess.check_output(
['repo', 'list', '-pf', 'chromiumos/platform/tast-tests']
data_dir = os.path.join(tast_tests,
latest_container = subprocess.check_output(
['', 'ls', f'gs://cros-containers-staging/{milestone}'
for arch in ['amd64', 'arm64']:
# The container URLs use 'arm64', but the tast data files use 'arm'
if arch == 'arm64':
file_arch = 'arm'
file_arch = arch
for ctype in ['test', 'app_test']:
for release in ['stretch', 'buster']:
base_url = f'gs://cros-containers-staging/{milestone}' \
metadata_file = f'crostini_{ctype}_container_metadata_{release}' \
update_data_file(base_url + 'lxd.tar.xz',
os.path.join(data_dir, metadata_file))
rootfs_file = f'crostini_{ctype}_container_rootfs_{release}' \
update_data_file(base_url + 'rootfs.tar.xz',
os.path.join(data_dir, rootfs_file))
print('Tast data dependencies updated')
print(f'Go to {data_dir} and create a CL')
if __name__ == '__main__':