Add migration script for helping with update of autotest-chrome.
With CL:59491, autotest-telemetry and autotest-chrome are again
being split into two separate ebuilds, so this means that we need
to uninstall the old version of autotest-chrome before we can install
the new version of autotest-telemetry. Do so.
BUG=chromium:59491
TEST=Run it locally.
Change-Id: I642bdf7faf17c6e9b917e61974726c14f1572011
Reviewed-on: https://gerrit.chromium.org/gerrit/59497
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/chroot_version_hooks.d/59_upgrade_autotest_pkgs b/chroot_version_hooks.d/59_upgrade_autotest_pkgs
new file mode 100644
index 0000000..d254a2c
--- /dev/null
+++ b/chroot_version_hooks.d/59_upgrade_autotest_pkgs
@@ -0,0 +1,32 @@
+# Copyright (c) 2013 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 old versions of autotest-chrome.
+opkg="chromeos-base/autotest-chrome"
+
+export CLEAN_DELAY=0
+
+update() {
+ local root=$1 board=$2 emerge
+
+ if [[ -z ${board} ]]; then
+ board="root"
+ emerge="sudo -E emerge"
+ else
+ emerge="emerge-${board}"
+ fi
+
+ if portageq has_version ${root} ${opkg}; then
+ ${emerge} -Cq ${opkg}
+ fi
+}
+
+update / &
+
+for board_root in /build/*; do
+ board=${board_root##*/}
+ update ${board_root} ${board} &
+done
+
+wait