Chromium Code Reviews| Index: build/get_syzygy_binaries.py |
| diff --git a/build/get_syzygy_binaries.py b/build/get_syzygy_binaries.py |
| index 05e8072d3dfa48458b7076b53b7f8a85fc3effc9..04b804a7c5bdea37619bdc492af277eda4b933af 100755 |
| --- a/build/get_syzygy_binaries.py |
| +++ b/build/get_syzygy_binaries.py |
| @@ -358,17 +358,49 @@ 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) |
| + |
| + expected_syzygy_dir = os.path.abspath(os.path.join( |
|
Sigurður Ásgeirsson
2014/09/19 18:44:42
one line of running commentary perhaps?
chrisha
2014/09/19 18:48:17
Done.
|
| + 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) |