diff options
author | chrisha <chrisha@chromium.org> | 2014-09-19 12:27:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-19 19:30:04 +0000 |
commit | f3b3b3bbeb8ed28ffa0c7580650a1d2ef29dade2 (patch) | |
tree | 3843a2222ef5eac62b0ccdd0a3c3ca08a8967388 /build/get_syzygy_binaries.py | |
parent | 4c04dfdb0fdc06ffe6bfb199a12b08fddc7eeb12 (diff) | |
download | chromium_src-f3b3b3bbeb8ed28ffa0c7580650a1d2ef29dade2.zip chromium_src-f3b3b3bbeb8ed28ffa0c7580650a1d2ef29dade2.tar.gz chromium_src-f3b3b3bbeb8ed28ffa0c7580650a1d2ef29dade2.tar.bz2 |
Remove orphaned Syzygy binaries on non-Windows platforms.
This modifies the gclient hook to remove files that were inadvertently downloaded by a previous version of the script.
BUG=414826
Review URL: https://codereview.chromium.org/586063002
Cr-Commit-Position: refs/heads/master@{#295763}
Diffstat (limited to 'build/get_syzygy_binaries.py')
-rwxr-xr-x | build/get_syzygy_binaries.py | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/build/get_syzygy_binaries.py b/build/get_syzygy_binaries.py index 05e8072..79a186d 100755 --- a/build/get_syzygy_binaries.py +++ b/build/get_syzygy_binaries.py @@ -358,17 +358,53 @@ def _ParseCommandLine(): return options -def main(): - # We only care about Windows platforms, as the Syzygy binaries aren't used - # elsewhere. - if sys.platform not in ('win32', 'cygwin'): +def _RemoveOrphanedFiles(options): + """This is run on non-Windows systems to remove orphaned files that may have + been downloaded by a previous version of this script. + """ + # Reconfigure logging to output info messages. This will allow inspection of + # cleanup status on non-Windows buildbots. + _LOGGER.setLevel(logging.INFO) + + output_dir = os.path.abspath(options.output_dir) + + # We only want to clean up the folder in 'src/third_party/syzygy', and we + # expect to be called with that as an output directory. This is an attempt to + # not start deleting random things if the script is run from an alternate + # location, or not called from the gclient hooks. + expected_syzygy_dir = os.path.abspath(os.path.join( + os.path.dirname(__file__), '..', 'third_party', 'syzygy')) + expected_output_dir = os.path.join(expected_syzygy_dir, 'binaries') + if expected_output_dir != output_dir: + _LOGGER.info('Unexpected output directory, skipping cleanup.') return + if not os.path.isdir(expected_syzygy_dir): + _LOGGER.info('Output directory does not exist, skipping cleanup.') + return + + def OnError(function, path, excinfo): + """Logs error encountered by shutil.rmtree.""" + _LOGGER.error('Error when running %s(%s)', function, path, exc_info=excinfo) + + _LOGGER.info('Removing orphaned files from %s', expected_syzygy_dir) + if not options.dry_run: + shutil.rmtree(expected_syzygy_dir, True, OnError) + + +def main(): options = _ParseCommandLine() if options.dry_run: _LOGGER.debug('Performing a dry-run.') + # We only care about Windows platforms, as the Syzygy binaries aren't used + # elsewhere. However, there was a short period of time where this script + # wasn't gated on OS types, and those OSes downloaded and installed binaries. + # This will cleanup orphaned files on those operating systems. + if sys.platform not in ('win32', 'cygwin'): + return _RemoveOrphanedFiles(options) + # Load the current installation state, and validate it against the # requested installation. state, is_consistent = _GetCurrentState(options.revision, options.output_dir) |