chroot_version_hooks.d: drop support for upgrading SDKs pre-2021

Punt old upgrade hooks that only get used for SDKs that were created
before 2021 and have not been upgraded since.  The tooling will already
detect this scenario (because the upgrade hooks are missing) and throw
an error telling the user to recreate the SDK.

BUG=None
TEST=CQ passes

Change-Id: I3d6a7e72ab8d04cd44b79e9356a0833d8545d56a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/3621320
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ram Chandrasekar <rchandrasekar@google.com>
Commit-Queue: Ram Chandrasekar <rchandrasekar@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/chroot_version_hooks.d/161_cleanup_sdk_binpkgs b/chroot_version_hooks.d/161_cleanup_sdk_binpkgs
deleted file mode 100644
index c4775ee..0000000
--- a/chroot_version_hooks.d/161_cleanup_sdk_binpkgs
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2019 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.
-
-# Prune orphaned binpkgs from the SDK that are never used by builders or devs.
-# See https://crbug.com/927122 for more details.
-
-exec sudo rm -rf /packages/
diff --git a/chroot_version_hooks.d/162_post_protobuf_upgrade b/chroot_version_hooks.d/162_post_protobuf_upgrade
deleted file mode 100644
index 16f93ee..0000000
--- a/chroot_version_hooks.d/162_post_protobuf_upgrade
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2019 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.
-
-# Clean local portage caches. This is necessary if there are
-# cros_workon packages.
-sudo rm -rf /var/cache/portage/* /build/*/var/cache/portage/*
-
-# Clean board packages.
-for board_root in /build/* ; do
-  board=${board_root##*/}
-  [[ "${board}" == "bin" || "${board}" == "dev" || \
-     "${board}" == "proc" ]] && continue
-
-  # Find packages using  either protobuf or grpc.
-  PKGS=( $(qdepends-${board} -qCN -Q dev-libs/protobuf && \
-         qdepends-${board} -qCN -Q net-libs/grpc | sort -u))
-  if [[ ${#PKGS[@]} -eq 0 ]]; then
-    continue
-  fi
-
-  echo "Cleaning packages using protobuf or grpc from ${board}"
-  PKGDIR=$(portageq-${board} envvar PKGDIR)
-  cd "${PKGDIR}"
-  # Remove existing binary packages.
-  for pkg in "${PKGS[@]}"; do
-    sudo rm -f "${pkg}"-[0-9]*.tbz2
-  done
-  # Unmerge all packages using either protobuf or grpc.
-  qmerge-${board} -Uqy "${PKGS[@]}"
-done
diff --git a/chroot_version_hooks.d/163_use_postsubmit_binpkgs b/chroot_version_hooks.d/163_use_postsubmit_binpkgs
deleted file mode 100644
index a8ccdcd..0000000
--- a/chroot_version_hooks.d/163_use_postsubmit_binpkgs
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2019 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.
-
-# Force regeneration of every board configuration in order to include the
-# postsubmit builders as binpkg sources.
-# crbug.com/898996
-
-for board_root in /build/*; do
-  board_name=${board_root##*/}
-  if [[ -e "/build/${board_name}/etc/make.conf.board" ]]; then
-    /mnt/host/source/chromite/bin/setup_board \
-        --board=${board_name} \
-        --skip-board-pkg-init \
-        --skip-chroot-upgrade \
-        --regen-configs &
-  fi
-done
-wait
diff --git a/chroot_version_hooks.d/164_post_protobuf_upgrade b/chroot_version_hooks.d/164_post_protobuf_upgrade
deleted file mode 120000
index 127de13..0000000
--- a/chroot_version_hooks.d/164_post_protobuf_upgrade
+++ /dev/null
@@ -1 +0,0 @@
-162_post_protobuf_upgrade
\ No newline at end of file
diff --git a/chroot_version_hooks.d/165_clean_libbrillo_so b/chroot_version_hooks.d/165_clean_libbrillo_so
deleted file mode 100644
index 5e9b1bf..0000000
--- a/chroot_version_hooks.d/165_clean_libbrillo_so
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2019 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.
-
-# Some library and package config files of libbrillo were created at
-# src_install() phase into the cache. It prevents overwriting when we switch to
-# create those files at src_compile with the user privilege.
-
-sudo rm -rf /var/cache/portage/* /build/*/var/cache/portage/*
diff --git a/chroot_version_hooks.d/166_gtest_upgrade b/chroot_version_hooks.d/166_gtest_upgrade
deleted file mode 100644
index 7db485a..0000000
--- a/chroot_version_hooks.d/166_gtest_upgrade
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2014 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.
-
-# gtest/gmock 1.7 is not binary compatible with the 1.6 version since
-# some internal symbols exposed in the .so file changed. The portage
-# cache in /build/$BOARD/var/cache/portage/chromeos-base will keep files
-# even if the ebuild is recompiled with the new gtest, so we need to remove
-# those files as well.
-#
-
-for sysroot in /build/* /; do
-  (
-  info "Cleaning /var/cache/portage/chromeos-base from ${sysroot}"
-  sudo rm -rf "${sysroot}"/var/cache/portage/chromeos-base
-  ) &
-done
-wait
diff --git a/chroot_version_hooks.d/167_remove_svn b/chroot_version_hooks.d/167_remove_svn
deleted file mode 100644
index cc31348..0000000
--- a/chroot_version_hooks.d/167_remove_svn
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2019 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.
-
-# Purge subversion (and its unique deps) from the SDK as no one uses it anymore.
-# https://crbug.com/982351
-
-PKGS=(
-  dev-vcs/subversion
-  net-libs/neon
-  net-libs/serf
-
-  # Some boards might need these for other packages (e.g. apache), but our build
-  # system will just pull them back in on demand, so purging should be safe.
-  dev-libs/apr
-  dev-libs/apr-util
-)
-
-# Clear the SDK first.
-echo "Clearing subversion (and deps) from the SDK"
-sudo qmerge -Uqy "${PKGS[@]}" &
-
-# Clean board packages.
-for board_root in /build/*; do
-  board=${board_root##*/}
-  if [[ -d "${board_root}/var/db/pkg" ]]; then
-    echo "Clearing subversion (and deps) from ${board}"
-    sudo qmerge-${board} -Uqy "${PKGS[@]}" &
-  fi
-done
-
-wait
diff --git a/chroot_version_hooks.d/168_python34_cleanup b/chroot_version_hooks.d/168_python34_cleanup
deleted file mode 100644
index 71673be..0000000
--- a/chroot_version_hooks.d/168_python34_cleanup
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2019 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.
-
-# Drop Python 3.4 from the SDK as we've moved to Python 3.6 everywhere.
-# Make sure 3.6 is installed in case this is an old chroot.
-
-echo "Cleaning up Python 3.4 to migrate to 3.6"
-
-export CLEAN_DELAY=0
-
-# Install python 3.6 if the sdk is out of date.
-if ! python3.6 --version >&/dev/null; then
-  sudo emerge -ug dev-lang/python:3.6
-fi
-
-# Point python3 to the new version.
-sudo eselect python update --python3
-
-# Remove python 3.4 from the system.
-sudo emerge -Cq dev-lang/python:3.4
-
-# Remove java-config if needed to avoid circular deps.
-reinstall_java="false"
-if ! python3.6 -c 'import java_config_2' >&/dev/null; then
-  reinstall_java="true"
-  sudo emerge -Cq dev-java/java-config
-fi
-
-# Upgrade portage itself finally.
-sudo emerge -Ugqv sys-apps/portage
-
-# Reinstall java-config in case we purged it.
-if [[ "${reinstall_java}" == "true" ]]; then
-  sudo emerge -ugqv dev-java/java-config
-fi
diff --git a/chroot_version_hooks.d/169_deleted_binhosts_cleanup b/chroot_version_hooks.d/169_deleted_binhosts_cleanup
deleted file mode 100644
index a8097cd..0000000
--- a/chroot_version_hooks.d/169_deleted_binhosts_cleanup
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2019 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.
-
-# Force regeneration of every board configuration in order to clean out
-# old binhosts. crbug.com/965244
-
-for board_root in /build/*; do
-  board_name=${board_root##*/}
-  if [[ -e "/build/${board_name}/etc/make.conf.board" ]]; then
-    /mnt/host/source/chromite/bin/setup_board \
-        --board=${board_name} \
-        --skip-board-pkg-init \
-        --skip-chroot-upgrade \
-        --regen-configs &
-  fi
-done
-wait
diff --git a/chroot_version_hooks.d/170_deleted_binhosts_cleanup b/chroot_version_hooks.d/170_deleted_binhosts_cleanup
deleted file mode 120000
index 7bac7f7..0000000
--- a/chroot_version_hooks.d/170_deleted_binhosts_cleanup
+++ /dev/null
@@ -1 +0,0 @@
-169_deleted_binhosts_cleanup
\ No newline at end of file
diff --git a/chroot_version_hooks.d/171_world_set_cleanup b/chroot_version_hooks.d/171_world_set_cleanup
deleted file mode 100644
index 3ddf7b8..0000000
--- a/chroot_version_hooks.d/171_world_set_cleanup
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2019 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.
-
-# Make sure the @world set is empty and doesn't contain packages we don't want
-# it to like rust.  https://crbug.com/1013967
-sudo rm -f /var/lib/portage/world
diff --git a/chroot_version_hooks.d/172_deleted_binhosts_cleanup b/chroot_version_hooks.d/172_deleted_binhosts_cleanup
deleted file mode 120000
index 7bac7f7..0000000
--- a/chroot_version_hooks.d/172_deleted_binhosts_cleanup
+++ /dev/null
@@ -1 +0,0 @@
-169_deleted_binhosts_cleanup
\ No newline at end of file
diff --git a/chroot_version_hooks.d/173_rust_slot_purge b/chroot_version_hooks.d/173_rust_slot_purge
deleted file mode 100644
index 5157ae9..0000000
--- a/chroot_version_hooks.d/173_rust_slot_purge
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2019 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.
-
-# A hack to try and unwedge some rust rebuilds.  https://crbug.com/1018589
-
-export CLEAN_DELAY=0
-
-for board_root in /build/*; do
-  board_name=${board_root##*/}
-  if [[ -d "${board_root}/var/db/pkg/dev-rust" ]]; then
-    if rust_pkgs=$(qlist-"${board_name}" -IC dev-rust); then
-      emerge-"${board_name}" -Cq ${rust_pkgs} &
-    fi
-  fi
-done
-wait
diff --git a/chroot_version_hooks.d/174_python3_sdk_default b/chroot_version_hooks.d/174_python3_sdk_default
deleted file mode 100644
index 73a382c..0000000
--- a/chroot_version_hooks.d/174_python3_sdk_default
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2019 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.
-
-# Set Python 3 as the default implementation.
-sudo eselect python update
-
-# Install the new symlinks.  This is normally handled only when the SDK is
-# first created.
-sudo ln -sfT /mnt/host/source/chromite \
-  /usr/lib64/python3.6/site-packages/chromite
-
-# Sanity check.
-python -c 'import sys; assert sys.version_info.major >= 3'
diff --git a/chroot_version_hooks.d/175_clang-python_cleanup b/chroot_version_hooks.d/175_clang-python_cleanup
deleted file mode 100644
index 955aeeb..0000000
--- a/chroot_version_hooks.d/175_clang-python_cleanup
+++ /dev/null
@@ -1,7 +0,0 @@
-# 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.
-
-# Remove dev-python/clang-python package which will clean-up out-dated
-# dependencies in the old chroot.
-sudo qmerge -Uqy dev-python/clang-python
diff --git a/chroot_version_hooks.d/176_binutils_fixup b/chroot_version_hooks.d/176_binutils_fixup
deleted file mode 100644
index b33c38e..0000000
--- a/chroot_version_hooks.d/176_binutils_fixup
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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.
-
-# Fix binutils headers and library conflicts when installing binutils-libs.
-# Remove symlinks to headers that are now provided by binutils-libs.
-# Note re-building binutils does not remove these symlinks so
-# a manual removal is needed to avoid merge conflicts.
-files_to_remove=(
-	/usr/include/symcat.h
-	/usr/include/plugin-api.h
-	/usr/include/bfdlink.h
-	/usr/include/bfd.h
-	/usr/include/dis-asm.h
-	/usr/include/ansidecl.h
-	/usr/include/libiberty/sort.h
-	/usr/include/libiberty/fibheap.h
-	/usr/include/libiberty/safe-ctype.h
-	/usr/include/libiberty/demangle.h
-	/usr/include/libiberty/objalloc.h
-	/usr/include/libiberty/hashtab.h
-	/usr/include/libiberty/timeval-utils.h
-	/usr/include/libiberty/splay-tree.h
-	/usr/include/libiberty/partition.h
-	/usr/include/libiberty/dyn-string.h
-	/usr/include/libiberty/libiberty.h
-	/usr/include/libiberty/floatformat.h
-	/usr/include/libiberty/ansidecl.h
-	/usr/include/libiberty.h
-)
-echo "Fixing up binutils installation"
-sudo rm -f "${files_to_remove[@]}"
-sudo emerge -ugq sys-devel/binutils-config
-sudo emerge -ugq sys-libs/binutils-libs
diff --git a/chroot_version_hooks.d/177_purge_crosutils b/chroot_version_hooks.d/177_purge_crosutils
deleted file mode 100644
index 30e258e..0000000
--- a/chroot_version_hooks.d/177_purge_crosutils
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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.
-
-# This package has been removed, so make sure it's cleaned up.
-sudo qmerge -Uqy dev-util/crosutils
diff --git a/chroot_version_hooks.d/178_merge_distdir b/chroot_version_hooks.d/178_merge_distdir
deleted file mode 100644
index ff79034..0000000
--- a/chroot_version_hooks.d/178_merge_distdir
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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.
-
-# We changed the distfile download dirs to a combined one, so move the old
-# content up to the common location.
-
-# Delete the old symlinks.
-sudo rm -f /var/lib/portage/distfiles /var/lib/portage/distfiles-target
-
-# Merge the content.
-echo "Merging old distfiles paths"
-cd /var/cache/distfiles
-for srcdir in target host; do
-  if [[ ! -d "${srcdir}" ]]; then
-    continue
-  fi
-
-  echo "  ${srcdir} ..."
-  # Merge the two git subdirs.
-  for gitdir in egit-src git3-src; do
-    mkdir -p "${gitdir}"
-    if [[ -d "${srcdir}/${gitdir}" ]]; then
-      for d in $(find "${srcdir}/${gitdir}/" -mindepth 1 -maxdepth 1 -type d \
-                   -printf '%f\n'); do
-        if [[ ! -d "${gitdir}/${d}" ]]; then
-          mv "${srcdir}/${gitdir}/${d}" "${gitdir}/" || exit 1
-        fi
-      done
-    fi
-  done
-
-  # Clear all the subdirs now that they're migrated.
-  sudo rm -rf "${srcdir}"/*/
-
-  # Merge the files.
-  rm -f "${srcdir}"/*._checksum_failure_.*
-  for f in "${srcdir}"/*; do
-    if [[ -e "${f}" && ! -e "${f##*/}" ]]; then
-      mv "${f}" ./ || exit 1
-    fi
-  done
-
-  # Delete the dir.
-  sudo rm -rf "${srcdir}" || exit 1
-done
diff --git a/chroot_version_hooks.d/179_purge_ruby b/chroot_version_hooks.d/179_purge_ruby
deleted file mode 100644
index 61be2bb..0000000
--- a/chroot_version_hooks.d/179_purge_ruby
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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.
-
-# These packages have been removed, so make sure they're cleaned up.
-sudo qmerge -Uqy \
-  app-admin/puppet \
-  app-eselect/eselect-ruby \
-  dev-lang/ruby \
-  $(qlist -IC virtual/ruby dev-ruby/)
diff --git a/chroot_version_hooks.d/180_select_jvm b/chroot_version_hooks.d/180_select_jvm
deleted file mode 100644
index e76d71c..0000000
--- a/chroot_version_hooks.d/180_select_jvm
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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.
-
-# Specify JDK as openjdk-bin-11 upon entering chroot.
-# See crrev.com/c/2335921 for more details.
-
-# Make sure dependencies are installed for older SDKs.
-sudo emerge -qug '>=virtual/jdk-9'
-
-sudo eselect java-vm set system openjdk-bin-11
-
-# Log current state for debugging issues.
-eselect java-vm list
-whereis java
diff --git a/chroot_version_hooks.d/181_rust_cleanup b/chroot_version_hooks.d/181_rust_cleanup
deleted file mode 100644
index 6bf0fc6..0000000
--- a/chroot_version_hooks.d/181_rust_cleanup
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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.
-
-# Clean ebuilds that have been upgraded but aren't automatically removed.
-
-export CLEAN_DELAY=0
-
-to_remove=(
-  "~dev-rust/bitflags-1.1.0"
-  "~dev-rust/byteorder-1.3.1"
-  "~dev-rust/proc-macro2-1.0.8"
-  "~serde-1.0.81"
-  "~serde_derive-1.0.81"
-  "~syn-1.0.14"
-)
-
-sudo emerge -Cq "${to_remove[@]}" &
-
-for board_root in /build/*; do
-  board_name=${board_root##*/}
-  if [[ -d "${board_root}/var/db/pkg/dev-rust" ]]; then
-    emerge-"${board_name}" -Cq "${to_remove[@]}" &
-  fi
-done
-wait