| 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..91ab4bad7a8ebd33a9f8bb29a5c3a7eb088f1e7b
|
| --- /dev/null
|
| +++ b/chrome/tools/build/mac/clean_up_old_versions.py
|
| @@ -0,0 +1,33 @@
|
| +# 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()
|
| + os.utime(stamp_path, None)
|
| +
|
| +
|
| +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())
|
|
|