Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | |
| 8 | """ |
| 9 | Simple script to be run inside the chroot. Used as a fast approximation of |
| 10 | emerge-$board autotest-all, by simply rsync'ing changes from trunk to sysroot. |
| 11 | """ |
| 12 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 13 | import argparse |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 14 | import logging |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 15 | import os |
Aviv Keshet | 787ffcd | 2013-04-08 15:14:56 -0700 | [diff] [blame] | 16 | import re |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 17 | import sys |
Aviv Keshet | 787ffcd | 2013-04-08 15:14:56 -0700 | [diff] [blame] | 18 | from collections import namedtuple |
| 19 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 20 | from chromite.buildbot import constants |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 21 | from chromite.buildbot import portage_utilities |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 22 | from chromite.lib import cros_build_lib |
| 23 | from chromite.lib import git |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 24 | from chromite.lib import osutils |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 25 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 26 | |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 27 | if cros_build_lib.IsInsideChroot(): |
| 28 | # Only import portage after we've checked that we're inside the chroot. |
| 29 | import portage |
| 30 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 31 | INCLUDE_PATTERNS_FILENAME = 'autotest-quickmerge-includepatterns' |
| 32 | AUTOTEST_PROJECT_NAME = 'chromiumos/third_party/autotest' |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 33 | AUTOTEST_TESTS_EBUILD = 'chromeos-base/autotest-tests' |
Aviv Keshet | 3cc4e9e | 2013-04-24 10:47:23 -0700 | [diff] [blame] | 34 | DOWNGRADE_EBUILDS = ['chromeos-base/autotest', |
| 35 | 'chromeos-base/autotest-tests', |
| 36 | 'chromeos-base/autotest-chrome', |
| 37 | 'chromeos-base/autotest-factory', |
| 38 | 'chromeos-base/autotest-telemetry', |
| 39 | 'chromeos-base/autotest-tests-ltp', |
| 40 | 'chromeos-base/autotest-tests-ownershipapi'] |
Aviv Keshet | 787ffcd | 2013-04-08 15:14:56 -0700 | [diff] [blame] | 41 | |
| 42 | # Data structure describing a single rsync filesystem change. |
| 43 | # |
| 44 | # change_description: An 11 character string, the rsync change description |
| 45 | # for the particular file. |
| 46 | # absolute_path: The absolute path of the created or modified file. |
| 47 | ItemizedChange = namedtuple('ItemizedChange', ['change_description', |
| 48 | 'absolute_path']) |
| 49 | |
| 50 | |
| 51 | # Data structure describing the rsync new/modified files or directories. |
| 52 | # |
| 53 | # new_files: A list of ItemizedChange objects for new files. |
| 54 | # modified_files: A list of ItemizedChange objects for modified files. |
| 55 | # new_directories: A list of ItemizedChange objects for new directories. |
| 56 | ItemizedChangeReport = namedtuple('ItemizedChangeReport', |
| 57 | ['new_files', 'modified_files', |
| 58 | 'new_directories']) |
| 59 | |
| 60 | |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 61 | def GetStalePackageNames(change_list, autotest_sysroot): |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 62 | """Given a rsync change report, returns the names of stale test packages. |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 63 | |
| 64 | This function pulls out test package names for client-side tests, stored |
| 65 | within the client/site_tests directory tree, that had any files added or |
| 66 | modified and for whom any existing bzipped test packages may now be stale. |
| 67 | |
| 68 | Arguments: |
| 69 | change_list: A list of ItemizedChange objects corresponding to changed |
| 70 | or modified files. |
| 71 | autotest_sysroot: Absolute path of autotest in the sysroot, |
| 72 | e.g. '/build/lumpy/usr/local/autotest' |
| 73 | |
| 74 | Returns: |
| 75 | A list of test package names, eg ['factory_Leds', 'login_UserPolicyKeys']. |
| 76 | May contain duplicate entries if multiple files within a test directory |
| 77 | were modified. |
| 78 | """ |
| 79 | exp = os.path.abspath(autotest_sysroot) + r'/client/site_tests/(.*?)/.*' |
| 80 | matches = [re.match(exp, change.absolute_path) for change in change_list] |
| 81 | return [match.group(1) for match in matches if match] |
| 82 | |
| 83 | |
Aviv Keshet | 787ffcd | 2013-04-08 15:14:56 -0700 | [diff] [blame] | 84 | def ItemizeChangesFromRsyncOutput(rsync_output, destination_path): |
| 85 | """Convert the output of an rsync with `-i` to a ItemizedChangeReport object. |
| 86 | |
| 87 | Arguments: |
| 88 | rsync_output: String stdout of rsync command that was run with `-i` option. |
| 89 | destination_path: String absolute path of the destination directory for the |
| 90 | rsync operations. This argument is necessary because |
| 91 | rsync's output only gives the relative path of |
| 92 | touched/added files. |
| 93 | |
| 94 | Returns: |
| 95 | ItemizedChangeReport object giving the absolute paths of files that were |
| 96 | created or modified by rsync. |
| 97 | """ |
| 98 | modified_matches = re.findall(r'([.>]f[^+]{9}) (.*)', rsync_output) |
| 99 | new_matches = re.findall(r'(>f\+{9}) (.*)', rsync_output) |
| 100 | new_symlink_matches = re.findall(r'(cL\+{9}) (.*) -> .*', rsync_output) |
| 101 | new_dir_matches = re.findall(r'(cd\+{9}) (.*)', rsync_output) |
| 102 | |
| 103 | absolute_modified = [ItemizedChange(c, os.path.join(destination_path, f)) |
| 104 | for (c, f) in modified_matches] |
| 105 | |
| 106 | # Note: new symlinks are treated as new files. |
| 107 | absolute_new = [ItemizedChange(c, os.path.join(destination_path, f)) |
| 108 | for (c, f) in new_matches + new_symlink_matches] |
| 109 | |
| 110 | absolute_new_dir = [ItemizedChange(c, os.path.join(destination_path, f)) |
| 111 | for (c, f) in new_dir_matches] |
| 112 | |
| 113 | return ItemizedChangeReport(new_files=absolute_new, |
| 114 | modified_files=absolute_modified, |
| 115 | new_directories=absolute_new_dir) |
| 116 | |
| 117 | |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 118 | def GetPackageAPI(portage_root, package_cp): |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 119 | """Gets portage API handles for the given package. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 120 | |
| 121 | Arguments: |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 122 | portage_root: Root directory of portage tree. Eg '/' or '/build/lumpy' |
| 123 | package_cp: A string similar to 'chromeos-base/autotest-tests'. |
| 124 | |
| 125 | Returns: |
| 126 | Returns (package, vartree) tuple, where |
| 127 | package is of type portage.dbapi.vartree.dblink |
| 128 | vartree is of type portage.dbapi.vartree.vartree |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 129 | """ |
| 130 | if portage_root is None: |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 131 | # pylint: disable-msg=E1101 |
| 132 | portage_root = portage.root |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 133 | # Ensure that portage_root ends with trailing slash. |
| 134 | portage_root = os.path.join(portage_root, '') |
| 135 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 136 | # Create a vartree object corresponding to portage_root. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 137 | trees = portage.create_trees(portage_root, portage_root) |
| 138 | vartree = trees[portage_root]['vartree'] |
| 139 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 140 | # List the matching installed packages in cpv format. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 141 | matching_packages = vartree.dbapi.cp_list(package_cp) |
| 142 | |
| 143 | if not matching_packages: |
| 144 | raise ValueError('No matching package for %s in portage_root %s' % ( |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 145 | package_cp, portage_root)) |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 146 | |
| 147 | if len(matching_packages) > 1: |
| 148 | raise ValueError('Too many matching packages for %s in portage_root ' |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 149 | '%s' % (package_cp, portage_root)) |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 150 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 151 | # Convert string match to package dblink. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 152 | package_cpv = matching_packages[0] |
| 153 | package_split = portage_utilities.SplitCPV(package_cpv) |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 154 | # pylint: disable-msg=E1101 |
| 155 | package = portage.dblink(package_split.category, |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 156 | package_split.pv, settings=vartree.settings, |
| 157 | vartree=vartree) |
| 158 | |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 159 | return package, vartree |
| 160 | |
| 161 | |
| 162 | def DowngradePackageVersion(portage_root, package_cp, |
| 163 | downgrade_to_version='0'): |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 164 | """Downgrade the specified portage package version. |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 165 | |
| 166 | Arguments: |
| 167 | portage_root: Root directory of portage tree. Eg '/' or '/build/lumpy' |
| 168 | package_cp: A string similar to 'chromeos-base/autotest-tests'. |
| 169 | downgrade_to_version: String version to downgrade to. Default: '0' |
| 170 | |
| 171 | Returns: |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 172 | True on success. False on failure (nonzero return code from `mv` command). |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 173 | """ |
| 174 | package, _ = GetPackageAPI(portage_root, package_cp) |
| 175 | |
| 176 | source_directory = package.dbdir |
| 177 | destination_path = os.path.join( |
| 178 | package.dbroot, package_cp + '-' + downgrade_to_version) |
| 179 | if os.path.abspath(source_directory) == os.path.abspath(destination_path): |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 180 | return True |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 181 | command = ['mv', source_directory, destination_path] |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 182 | code = cros_build_lib.SudoRunCommand(command, error_code_ok=True).returncode |
| 183 | return code == 0 |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 184 | |
| 185 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 186 | def UpdatePackageContents(change_report, package_cp, portage_root=None): |
| 187 | """Add newly created files/directors to package contents. |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 188 | |
| 189 | Given an ItemizedChangeReport, add the newly created files and directories |
| 190 | to the CONTENTS of an installed portage package, such that these files are |
| 191 | considered owned by that package. |
| 192 | |
| 193 | Arguments: |
| 194 | changereport: ItemizedChangeReport object for the changes to be |
| 195 | made to the package. |
| 196 | package_cp: A string similar to 'chromeos-base/autotest-tests' giving |
| 197 | the package category and name of the package to be altered. |
| 198 | portage_root: Portage root path, corresponding to the board that |
| 199 | we are working on. Defaults to '/' |
| 200 | """ |
| 201 | package, vartree = GetPackageAPI(portage_root, package_cp) |
| 202 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 203 | # Append new contents to package contents dictionary. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 204 | contents = package.getcontents().copy() |
| 205 | for _, filename in change_report.new_files: |
| 206 | contents.setdefault(filename, (u'obj', '0', '0')) |
| 207 | for _, dirname in change_report.new_directories: |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 208 | # Strip trailing slashes if present. |
| 209 | contents.setdefault(dirname.rstrip('/'), (u'dir',)) |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 210 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 211 | # Write new contents dictionary to file. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 212 | vartree.dbapi.writeContentsToContentsFile(package, contents) |
| 213 | |
| 214 | |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 215 | def RemoveTestPackages(stale_packages, autotest_sysroot): |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 216 | """Remove bzipped test packages from sysroot. |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 217 | |
| 218 | Arguments: |
| 219 | stale_packages: List of test packages names to be removed. |
| 220 | e.g. ['factory_Leds', 'login_UserPolicyKeys'] |
| 221 | autotest_sysroot: Absolute path of autotest in the sysroot, |
| 222 | e.g. '/build/lumpy/usr/local/autotest' |
| 223 | """ |
| 224 | for package in set(stale_packages): |
| 225 | package_filename = 'test-' + package + '.tar.bz2' |
| 226 | package_file_fullpath = os.path.join(autotest_sysroot, 'packages', |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 227 | package_filename) |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 228 | if osutils.SafeUnlink(package_file_fullpath): |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 229 | logging.info('Removed stale %s', package_file_fullpath) |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 230 | |
| 231 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 232 | def RsyncQuickmerge(source_path, sysroot_autotest_path, |
| 233 | include_pattern_file=None, pretend=False, |
Aviv Keshet | 60968ec | 2013-04-11 18:44:14 -0700 | [diff] [blame] | 234 | overwrite=False): |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 235 | """Run rsync quickmerge command, with specified arguments. |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 236 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 237 | Command will take form `rsync -a [options] --exclude=**.pyc |
| 238 | --exclude=**.pyo |
| 239 | [optional --include-from argument] |
| 240 | --exclude=* [source_path] [sysroot_autotest_path]` |
| 241 | |
| 242 | Arguments: |
| 243 | pretend: True to use the '-n' option to rsync, to perform dry run. |
| 244 | overwrite: True to omit '-u' option, overwrite all files in sysroot, |
| 245 | not just older files. |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 246 | |
| 247 | Returns: |
| 248 | The cros_build_lib.CommandResult object resulting from the rsync command. |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 249 | """ |
| 250 | command = ['rsync', '-a'] |
| 251 | |
| 252 | if pretend: |
| 253 | command += ['-n'] |
| 254 | |
| 255 | if not overwrite: |
| 256 | command += ['-u'] |
| 257 | |
Aviv Keshet | 60968ec | 2013-04-11 18:44:14 -0700 | [diff] [blame] | 258 | command += ['-i'] |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 259 | |
| 260 | command += ['--exclude=**.pyc'] |
| 261 | command += ['--exclude=**.pyo'] |
| 262 | |
Aviv Keshet | 787ffcd | 2013-04-08 15:14:56 -0700 | [diff] [blame] | 263 | # Exclude files with a specific substring in their name, because |
| 264 | # they create an ambiguous itemized report. (see unit test file for details) |
| 265 | command += ['--exclude=** -> *'] |
| 266 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 267 | if include_pattern_file: |
| 268 | command += ['--include-from=%s' % include_pattern_file] |
| 269 | |
| 270 | command += ['--exclude=*'] |
| 271 | |
| 272 | command += [source_path, sysroot_autotest_path] |
| 273 | |
Aviv Keshet | 60968ec | 2013-04-11 18:44:14 -0700 | [diff] [blame] | 274 | return cros_build_lib.SudoRunCommand(command, redirect_stdout=True) |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 275 | |
| 276 | |
| 277 | def ParseArguments(argv): |
| 278 | """Parse command line arguments |
| 279 | |
| 280 | Returns: parsed arguments. |
| 281 | """ |
| 282 | parser = argparse.ArgumentParser(description='Perform a fast approximation ' |
| 283 | 'to emerge-$board autotest-all, by ' |
| 284 | 'rsyncing source tree to sysroot.') |
| 285 | |
| 286 | parser.add_argument('--board', metavar='BOARD', default=None, required=True) |
| 287 | parser.add_argument('--pretend', action='store_true', |
| 288 | help='Dry run only, do not modify sysroot autotest.') |
| 289 | parser.add_argument('--overwrite', action='store_true', |
| 290 | help='Overwrite existing files even if newer.') |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 291 | parser.add_argument('--verbose', action='store_true', |
| 292 | help='Print detailed change report.') |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 293 | |
| 294 | return parser.parse_args(argv) |
| 295 | |
| 296 | |
| 297 | def main(argv): |
| 298 | cros_build_lib.AssertInsideChroot() |
| 299 | |
| 300 | args = ParseArguments(argv) |
| 301 | |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 302 | if os.geteuid() != 0: |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 303 | try: |
| 304 | cros_build_lib.SudoRunCommand([sys.executable] + sys.argv) |
| 305 | except cros_build_lib.RunCommandError: |
| 306 | return 1 |
| 307 | return 0 |
| 308 | |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 309 | if not args.board: |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 310 | print 'No board specified. Aborting.' |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 311 | return 1 |
| 312 | |
| 313 | manifest = git.ManifestCheckout.Cached(constants.SOURCE_ROOT) |
| 314 | source_path = manifest.GetProjectPath(AUTOTEST_PROJECT_NAME, absolute=True) |
| 315 | source_path = os.path.join(source_path, '') |
| 316 | |
| 317 | script_path = os.path.dirname(__file__) |
| 318 | include_pattern_file = os.path.join(script_path, INCLUDE_PATTERNS_FILENAME) |
| 319 | |
| 320 | # TODO: Determine the following string programatically. |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 321 | sysroot_path = os.path.join('/build', args.board, '') |
| 322 | sysroot_autotest_path = os.path.join(sysroot_path, 'usr', 'local', |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 323 | 'autotest', '') |
| 324 | |
Aviv Keshet | 60968ec | 2013-04-11 18:44:14 -0700 | [diff] [blame] | 325 | rsync_output = RsyncQuickmerge(source_path, sysroot_autotest_path, |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 326 | include_pattern_file, args.pretend, |
| 327 | args.overwrite) |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 328 | |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 329 | if args.verbose: |
| 330 | logging.info(rsync_output.output) |
| 331 | |
Aviv Keshet | 60968ec | 2013-04-11 18:44:14 -0700 | [diff] [blame] | 332 | change_report = ItemizeChangesFromRsyncOutput(rsync_output.output, |
| 333 | sysroot_autotest_path) |
| 334 | |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 335 | if not args.pretend: |
| 336 | UpdatePackageContents(change_report, AUTOTEST_TESTS_EBUILD, |
| 337 | sysroot_path) |
Aviv Keshet | 3cc4e9e | 2013-04-24 10:47:23 -0700 | [diff] [blame] | 338 | for ebuild in DOWNGRADE_EBUILDS: |
Aviv Keshet | 557e688 | 2013-04-25 13:26:09 -0700 | [diff] [blame] | 339 | if not DowngradePackageVersion(sysroot_path, ebuild): |
Aviv Keshet | 3cc4e9e | 2013-04-24 10:47:23 -0700 | [diff] [blame] | 340 | logging.warning('Unable to downgrade package %s version number.', |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 341 | ebuild) |
Aviv Keshet | 75d6596 | 2013-04-17 16:15:23 -0700 | [diff] [blame] | 342 | stale_packages = GetStalePackageNames( |
| 343 | change_report.new_files + change_report.modified_files, |
| 344 | sysroot_autotest_path) |
| 345 | RemoveTestPackages(stale_packages, sysroot_autotest_path) |
Aviv Keshet | c87f412 | 2013-05-01 13:40:00 -0700 | [diff] [blame^] | 346 | osutils.SafeUnlink(os.path.join(sysroot_autotest_path, 'packages.checksum')) |
| 347 | osutils.SafeUnlink(os.path.join(sysroot_autotest_path, 'packages', |
| 348 | 'packages.checksum')) |
Aviv Keshet | b1238c3 | 2013-04-01 11:42:13 -0700 | [diff] [blame] | 349 | |
Aviv Keshet | 940c17f | 2013-04-11 18:41:42 -0700 | [diff] [blame] | 350 | if args.pretend: |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 351 | logging.info('The following message is pretend only. No filesystem ' |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 352 | 'changes made.') |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 353 | logging.info('Quickmerge complete. Created or modified %s files.', |
Aviv Keshet | e7b2019 | 2013-04-24 14:05:53 -0700 | [diff] [blame] | 354 | len(change_report.new_files) + |
| 355 | len(change_report.modified_files)) |
Aviv Keshet | e00caeb | 2013-04-17 14:03:25 -0700 | [diff] [blame] | 356 | |
| 357 | return 0 |