| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import optparse |
| 6 import os |
| 7 import shutil |
| 8 import sys |
| 9 |
| 10 |
| 11 def CleanUpOldVersions(path_to_app, keep_version, stamp_path): |
| 12 versions_dir = os.path.join(path_to_app, 'Contents', 'Versions') |
| 13 for version in os.listdir(versions_dir): |
| 14 if version != keep_version: |
| 15 shutil.rmtree(os.path.join(versions_dir, version)) |
| 16 |
| 17 open(stamp_path, 'w').close() |
| 18 os.utime(stamp_path, None) |
| 19 |
| 20 |
| 21 def Main(): |
| 22 parser = optparse.OptionParser( |
| 23 usage='%prog path/to/Chromium.app keep_version stamp_path') |
| 24 opts, args = parser.parse_args() |
| 25 if len(args) != 3: |
| 26 parser.error('missing arguments') |
| 27 return 1 |
| 28 |
| 29 CleanUpOldVersions(*args) |
| 30 return 0 |
| 31 |
| 32 if __name__ == '__main__': |
| 33 sys.exit(Main()) |
| OLD | NEW |