Chromium Code Reviews| Index: chrome/tools/build/mac/clean_up_old_versions.py |
| diff --git a/chrome/tools/build/mac/clean_up_old_versions.py b/chrome/tools/build/mac/clean_up_old_versions.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ca8c6504b73ade66ff17a6460960eaaeced9721c |
| --- /dev/null |
| +++ b/chrome/tools/build/mac/clean_up_old_versions.py |
| @@ -0,0 +1,32 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import optparse |
| +import os |
| +import shutil |
| +import sys |
| + |
| + |
| +def CleanUpOldVersions(path_to_app, keep_version, stamp_path): |
| + versions_dir = os.path.join(path_to_app, 'Contents', 'Versions') |
| + for version in os.listdir(versions_dir): |
| + if version != keep_version: |
| + shutil.rmtree(os.path.join(versions_dir, version)) |
| + |
| + open(stamp_path, 'w').close() |
|
Mark Mentovai
2016/07/25 18:13:46
You should also call os.utime(stamp_path, None) to
Robert Sesek
2016/07/25 18:21:41
Done.
|
| + |
| + |
| +def Main(): |
| + parser = optparse.OptionParser( |
| + usage='%prog path/to/Chromium.app keep_version stamp_path') |
| + opts, args = parser.parse_args() |
| + if len(args) != 3: |
| + parser.error('missing arguments') |
| + return 1 |
| + |
| + CleanUpOldVersions(*args) |
| + return 0 |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main()) |