autotest_quickmerge remove all bzipped packages, skip shadow_config.ini

Prior to this CL, changes to python code for profilers (or dependencies)
would not be reflected on DUT after a quickmerge, since autoserv uses
the version stored in one of the bzipped packages (if one exists). This
CL causes autotest_quickmerge to take the more aggressive strategy of
deleting all the bzipped backages instead of trying to figure out which
ones are stale (which is fragile, introduces test- or profiler- or dep-
specific logic, and probably doesn't win us anything but an tiny
speed improvement in run_remote_tests).

This CL also excludes shadow_config.ini from autotest_quickmerge, since
it confuses the autoserv packaging engine when it is present in the
sysroot.

BUG=chromium:241279, chromium:241643
TEST=Manual verification that deleting packages directory still allows
tests with dependencies to be run (tested with one of the login_*
tests).
Run autotest_quickmerge - packages directory is deleted from
sysroot autotest. shadow_config.ini is absent from sysroot (though
present in source tree)
Run a smoke suite with run_remote_tests. Suite runs correctly.
Then run build_packages. Package directory is restored, with the same
contents as a fresh build_packages (verified by comparing ls output
before and after).

Change-Id: I7478e750a5b4aeb2dff6a9e2ae93ec89adb695ce
Reviewed-on: https://gerrit.chromium.org/gerrit/51537
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/autotest_quickmerge.py b/scripts/autotest_quickmerge.py
index b1d01b6..57fafa7 100644
--- a/scripts/autotest_quickmerge.py
+++ b/scripts/autotest_quickmerge.py
@@ -212,21 +212,16 @@
   vartree.dbapi.writeContentsToContentsFile(package, contents)
 
 
-def RemoveTestPackages(stale_packages, autotest_sysroot):
-  """Remove bzipped test packages from sysroot.
+def RemoveBzipPackages(autotest_sysroot):
+  """Remove all bzipped test/dep/profiler packages from sysroot autotest.
 
   Arguments:
-    stale_packages: List of test packages names to be removed.
-                    e.g. ['factory_Leds', 'login_UserPolicyKeys']
     autotest_sysroot: Absolute path of autotest in the sysroot,
                       e.g. '/build/lumpy/usr/local/autotest'
   """
-  for package in set(stale_packages):
-    package_filename = 'test-' + package + '.tar.bz2'
-    package_file_fullpath = os.path.join(autotest_sysroot, 'packages',
-                                         package_filename)
-    if osutils.SafeUnlink(package_file_fullpath):
-      logging.info('Removed stale %s', package_file_fullpath)
+  osutils.RmDir(os.path.join(autotest_sysroot, 'packages'),
+                             ignore_missing=True)
+  osutils.SafeUnlink(os.path.join(autotest_sysroot, 'packages.checksum'))
 
 
 def RsyncQuickmerge(source_path, sysroot_autotest_path,
@@ -339,13 +334,7 @@
       if not DowngradePackageVersion(sysroot_path, ebuild):
         logging.warning('Unable to downgrade package %s version number.',
                         ebuild)
-    stale_packages = GetStalePackageNames(
-        change_report.new_files + change_report.modified_files,
-        sysroot_autotest_path)
-    RemoveTestPackages(stale_packages, sysroot_autotest_path)
-    osutils.SafeUnlink(os.path.join(sysroot_autotest_path, 'packages.checksum'))
-    osutils.SafeUnlink(os.path.join(sysroot_autotest_path, 'packages',
-                                    'packages.checksum'))
+    RemoveBzipPackages(sysroot_autotest_path)
 
   if args.pretend:
     logging.info('The following message is pretend only. No filesystem '