autotest_quickmerge: programatically detect portage downgrade list
Instead of having a hard-coded list of autotest related packages to be
downgraded by autotest-quickmerge, this CL causes autotest_quickmerge to
parse the per-ebuild autotest packaging log files in the sysroot to
determine which packages to downgrade.
BUG=chromium:289181
TEST=Compared full directory print of sysroot autotest between a fresh
build_packages and (autotest_quickmerge && build_packages). Saw that all
but 4 package files were being correctly restored. I believe these
packages are being provided by an ebuild that has the same ${PV} name as
another ebuild, and so its log file is getting overwritten and hence it
is not being added the the downgrade list; a fix for that in the
autotest.eclass is forthcoming.
Change-Id: Id7b4b2b03b575528b9437a464cab8eb1eff1c166
Reviewed-on: https://chromium-review.googlesource.com/169635
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/autotest_quickmerge.py b/scripts/autotest_quickmerge.py
index 44afa13..c260f40 100644
--- a/scripts/autotest_quickmerge.py
+++ b/scripts/autotest_quickmerge.py
@@ -11,6 +11,7 @@
"""
import argparse
+import glob
import logging
import os
import re
@@ -31,13 +32,7 @@
INCLUDE_PATTERNS_FILENAME = 'autotest-quickmerge-includepatterns'
AUTOTEST_PROJECT_NAME = 'chromiumos/third_party/autotest'
AUTOTEST_EBUILD = 'chromeos-base/autotest'
-DOWNGRADE_EBUILDS = ['chromeos-base/autotest',
- 'chromeos-base/autotest-deps',
- 'chromeos-base/autotest-tests',
- 'chromeos-base/autotest-chrome',
- 'chromeos-base/autotest-factory',
- 'chromeos-base/autotest-tests-ltp',
- 'chromeos-base/autotest-tests-ownershipapi']
+DOWNGRADE_EBUILDS = ['chromeos-base/autotest']
IGNORE_SUBDIRS = ['ExternalSource',
'logs',
@@ -392,6 +387,17 @@
logging.info('Updating portage database.')
UpdatePackageContents(change_report, AUTOTEST_EBUILD,
sysroot_path)
+ for logfile in glob.glob(os.path.join(sysroot_autotest_path, 'packages',
+ '*.log')):
+ try:
+ # Open file in a try-except block, for atomicity, instead of
+ # doing existence check.
+ with open(logfile, 'r') as f:
+ package_cp = f.readline().strip()
+ DOWNGRADE_EBUILDS.append(package_cp)
+ except IOError:
+ pass
+
for ebuild in DOWNGRADE_EBUILDS:
if not DowngradePackageVersion(sysroot_path, ebuild):
logging.warning('Unable to downgrade package %s version number.',
@@ -402,6 +408,7 @@
'.quickmerge_sentinel')
cros_build_lib.RunCommand(['touch', sentinel_filename])
+
if args.pretend:
logging.info('The following message is pretend only. No filesystem '
'changes made.')