Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/tools/build/mac/clean_up_old_versions.py

Issue 2181113002: [Mac/GN] Unconditionally write the stamp file in clean_up_old_versions.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import optparse 5 import optparse
6 import os 6 import os
7 import shutil 7 import shutil
8 import sys 8 import sys
9 9
10 10
11 def CleanUpOldVersions(path_to_app, keep_version, stamp_path): 11 def CleanUpOldVersions(path_to_app, keep_version, stamp_path):
12 versions_dir = os.path.join(path_to_app, 'Contents', 'Versions') 12 versions_dir = os.path.join(path_to_app, 'Contents', 'Versions')
13 if not os.path.exists(versions_dir): 13 if os.path.exists(versions_dir):
14 return 14 for version in os.listdir(versions_dir):
15 15 if version != keep_version:
16 for version in os.listdir(versions_dir): 16 shutil.rmtree(os.path.join(versions_dir, version))
17 if version != keep_version:
18 shutil.rmtree(os.path.join(versions_dir, version))
19 17
20 open(stamp_path, 'w').close() 18 open(stamp_path, 'w').close()
21 os.utime(stamp_path, None) 19 os.utime(stamp_path, None)
22 20
23 21
24 def Main(): 22 def Main():
25 parser = optparse.OptionParser( 23 parser = optparse.OptionParser(
26 usage='%prog path/to/Chromium.app keep_version stamp_path') 24 usage='%prog path/to/Chromium.app keep_version stamp_path')
27 opts, args = parser.parse_args() 25 opts, args = parser.parse_args()
28 if len(args) != 3: 26 if len(args) != 3:
29 parser.error('missing arguments') 27 parser.error('missing arguments')
30 return 1 28 return 1
31 29
32 CleanUpOldVersions(*args) 30 CleanUpOldVersions(*args)
33 return 0 31 return 0
34 32
35 if __name__ == '__main__': 33 if __name__ == '__main__':
36 sys.exit(Main()) 34 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698