Remove component uprev scripts

We've decided not to branch the termina component for M91, so we can
remove these scripts now.

BUG=chromium:1128741
TEST=none

Disallow-Recycled-Builds: test-failures
Change-Id: I6694acb7aeb9da2eeae6a3750604ea29ed06180b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/containers/cros-container-guest-tools/+/2735794
Reviewed-by: Nicholas Verne <nverne@chromium.org>
Reviewed-by: David Munro <davidmunro@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Fergus Dall <sidereal@google.com>
diff --git a/scripts/uprev.py b/scripts/uprev.py
index 2ab9e22..5590d29 100755
--- a/scripts/uprev.py
+++ b/scripts/uprev.py
@@ -43,9 +43,6 @@
         ['gsutil.py', 'ls', f'gs://cros-containers-staging/{milestone}'
          '/images/debian/buster/arm64/default/']
     ).decode().split()[-1].split('/')[-2]
-    latest_vm = subprocess.check_output(
-        ['gsutil.py', 'ls', f'gs://termina-component-testing/{milestone}/']
-    ).decode().split()[-1].split('/')[-2]
 
     for arch in ['amd64', 'arm64']:
         # The container URLs use 'arm64', but the tast data files use 'arm'
@@ -69,15 +66,6 @@
                 update_data_file(base_url + 'rootfs.tar.xz',
                                  os.path.join(data_dir, rootfs_file))
 
-        if arch == 'amd64':
-            vm_arch = 'chromeos_intel64-archive'
-        else:
-            vm_arch = 'chromeos_arm32-archive'
-        update_data_file(f'gs://termina-component-testing/{milestone}'
-                         f'/{latest_vm}/{vm_arch}/files.zip',
-                         os.path.join(
-                             data_dir, f'crostini_vm_{file_arch}.zip.external'))
-
     print('Tast data dependencies updated')
     print(f'Go to {data_dir} and create a CL')
 
diff --git a/termina/termina_upload.py b/termina/termina_upload.py
deleted file mode 100755
index 76f6635..0000000
--- a/termina/termina_upload.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/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.
-"""Uploads termina to the correct gsutil buckets.
-
-This script is designed to automate some of go/crostini-infra-playbook. It
-should be run after termina_uprev.py.
-"""
-
-import argparse
-import os
-import subprocess
-import tempfile
-
-
-def upload_termina(termina_dir, milestone, build):
-  """Uploads termina images to omaha/testing buckets.
-
-  After running termina_uprev.py you can run this script to put the new images
-  in the right gs buckets.
-
-  Args:
-    termina_dir: Directory where termina_uprev.py stored the images.
-    milestone: Chrome milestone for this build.
-    build: CrOS build which created these termina images.
-
-  Raises:
-    Exception: if termina_dir is not a directory.
-  """
-  if not os.path.isdir(termina_dir):
-    raise Exception("Can not locate termina directory: " + termina_dir)
-
-  omaha_url = "gs://chrome-component-termina/{}".format(build)
-  testing_url = "gs://termina-component-testing/{}".format(milestone)
-
-  for image, arch in [("tatl", "intel64"), ("tael", "arm32"),
-                      ("tael", "arm64")]:
-    local_copy = os.path.join(termina_dir, image, "files.zip")
-    remote_copy = "{}/chromeos_{}-archive/".format(omaha_url, arch)
-    subprocess.check_call(
-        ["gsutil.py", "--", "cp", "-a", "public-read", local_copy, remote_copy])
-
-  subprocess.check_call(["gsutil.py", "--", "cp", "-r", omaha_url, '{}/{}'.format(testing_url, build)])
-
-  with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
-    tmp.write("{}\n".format(build))
-    staging_file = tmp.name
-  subprocess.check_call(
-      ["gsutil.py", "--", "cp", staging_file, "{}/staging".format(testing_url)])
-  # Not removing staging_file in case the user wants to check it.
-
-def upload_debug_symbols(termina_dir, api_key):
-  with tempfile.NamedTemporaryFile(mode="w", delete=True) as tmp:
-    tmp.write(api_key)
-    tmp.flush()
-    for board in ["tatl", "tael"]:
-      tarball = os.path.join(termina_dir, board, "debug_breakpad.tar.xz")
-      subprocess.check_call(
-          ["upload_symbols", tarball, "--api_key", tmp.name, "--official_build", "--yes", "--dedupe"])
-
-def main():
-  parser = argparse.ArgumentParser(description=__doc__)
-  parser.add_argument(
-      "--api_key", required=True, help="crash server API key, found at http://pantheon/apis/credentials?project=crosvm-packages")
-  parser.add_argument(
-      "--milestone", required=True, help="milestone number, e.g. 78")
-  parser.add_argument(
-      "--build", required=True, help="build number, e.g. 11396.0.0")
-  parser.add_argument(
-      "--dir",
-      default="./uprev",
-      help="directory where termina_uprev.py stored its results")
-  args = parser.parse_args()
-
-  upload_termina(args.dir, args.milestone, args.build)
-  upload_debug_symbols(args.dir, args.api_key)
-
-
-if __name__ == "__main__":
-  main()
diff --git a/termina/termina_uprev.py b/termina/termina_uprev.py
deleted file mode 100755
index 17d1509..0000000
--- a/termina/termina_uprev.py
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# Copyright 2018 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.
-
-"""Uprevs Termina images"""
-
-import argparse
-import json
-import os
-import shutil
-import struct
-import subprocess
-import sys
-import tempfile
-import urllib.request
-
-from pathlib import Path
-from termina_build_image import repack_rootfs
-from termina_util import mount_disk, get_release_version
-
-def get_build_path(board, build, branch):
-  image_archive_url = 'https://storage.googleapis.com/chromeos-image-archive'
-  build_config_format = '{}-full'
-  if branch:
-    build_config_format = '{}-full-tryjob'
-  build_config = build_config_format.format(board)
-
-  # Manually specified builds override branches.
-  build_version = 'master'
-  if branch:
-    build_version = branch
-  if build:
-    build_version = build
-
-  base_url = '{}/{}'.format(image_archive_url, build_config)
-  symlink_url = '{}/LATEST-{}'.format(base_url, build_version)
-
-  print("Checking symlink URL", symlink_url)
-  response = urllib.request.urlopen(symlink_url)
-  build_number = response.read().decode('utf-8')
-
-  return '{}/{}'.format(base_url, build_number)
-
-def download_image(board, gs_path, output_dir):
-  image_url = '{}/chromiumos_base_image.tar.xz'.format(gs_path)
-  print('Downloading image from', image_url)
-  target_path = output_dir / '{}_base_image.tar.xz'.format(board)
-  filename, headers = urllib.request.urlretrieve(image_url, str(target_path))
-  print('Image downloaded to', filename)
-
-  return filename
-
-def download_debug_symbols(board, gs_path, output_dir):
-  debug_url = '{}/debug_breakpad.tar.xz'.format(gs_path)
-  print('Downloading debug symbols from', debug_url)
-  target_path = output_dir / board / 'debug_breakpad.tar.xz'
-  filename, headers = urllib.request.urlretrieve(debug_url, str(target_path))
-  print('Debug symbols downloaded to', filename)
-
-def unpack_component(board, image_path, output_dir):
-  component_dir = output_dir / board
-  component_dir.mkdir()
-  result = subprocess.run(['tar', 'xvf', image_path, '-C', str(component_dir)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
-  return component_dir / 'chromiumos_base_image.bin'
-
-def build_component(board, image_path, output_dir, component_version):
-  print('Repacking rootfs')
-  component_dir = output_dir / board
-  component_dir.mkdir(exist_ok=True)
-  repack_rootfs(component_dir, image_path)
-
-  # Assemble the component disk image.
-  print('Building component disk image')
-
-  # Create image at 150% of source size.
-  # resize2fs will shrink it to the minimum size later.
-  du_output = subprocess.check_output(['du', '-bsx',
-                                       component_dir]).decode('utf-8')
-  src_size = int(du_output.split()[0])
-  img_size = int(src_size * 1.50)
-
-  component_disk = component_dir / 'image.ext4'
-  with component_disk.open('wb+') as component:
-    component.truncate(img_size)
-  subprocess.run(['/sbin/mkfs.ext4', '-b', '4096', '-O', '^has_journal', str(component_disk)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
-  mnt_dir = component_dir / 'mnt'
-  mnt_dir.mkdir()
-
-  with mount_disk(str(component_disk), str(mnt_dir)) as mntpoint:
-    for component_file in ['about_os_credits.html', 'lsb-release',
-                           'vm_kernel', 'vm_rootfs.img', 'vm_tools.img']:
-      subprocess.run(['sudo', 'cp', str(component_dir / component_file),
-                      str(mnt_dir / component_file)], check=True)
-
-  subprocess.run(['/sbin/e2fsck', '-y', '-f', str(component_disk)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
-  subprocess.run(['/sbin/resize2fs', '-M', str(component_disk)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
-
-  # Create manifest and zip up.
-  print('Zipping up component and manifest')
-  release_version = get_release_version(component_dir / 'lsb-release')
-  if not release_version:
-    print("No valid version in lsb-release")
-    sys.exit(1)
-
-  manifest_contents = {
-    'description': 'Chrome OS VM Container',
-    'name': 'termina',
-    'version': release_version,
-    'min_env_version': component_version,
-    'squash' : 'false',
-    'image_name' : 'image.ext4',
-    'fs_type' : 'ext4',
-    'is_removable' : 'true'
-  }
-
-  manifest_encoded = json.dumps(manifest_contents)
-
-  manifest_path = component_dir / 'manifest.json'
-  with open(str(manifest_path), 'w+') as manifest:
-    manifest.write(manifest_encoded)
-
-  subprocess.run(['zip', '-rj', str(component_dir / 'files.zip'), str(component_disk), str(manifest_path)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
-
-def main():
-  parser = argparse.ArgumentParser(description='Uprev Termina images')
-  parser.add_argument('--build', help='build number, e.g. 11396.0.0 (default: master)')
-  parser.add_argument('--branch', help='optional branch name, e.g. release-R72-11316.B (default: master)')
-  parser.add_argument('--output_dir', help='local dir to save results')
-  parser.add_argument('component_version', help='version of the component')
-
-  args = parser.parse_args()
-
-  with tempfile.TemporaryDirectory() as tempdir_path:
-    tempdir = Path(tempdir_path)
-    for board in ['tatl', 'tael']:
-      gs_path = get_build_path(board, args.build, args.branch)
-      download_path = download_image(board, gs_path, tempdir)
-      image_path = unpack_component(board, download_path, tempdir)
-      build_component(board, image_path, tempdir, args.component_version)
-      download_debug_symbols(board, gs_path, tempdir)
-      if args.output_dir:
-        target_dir = Path(args.output_dir) / board
-        shutil.copytree(str(tempdir / board), str(target_dir))
-
-  sys.exit(0)
-
-if __name__ == '__main__':
-  main()