OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 | 6 |
7 # Dart Editor promote and google storage cleanup tools. | 7 # Dart Editor promote and google storage cleanup tools. |
8 | 8 |
9 import gsutil | 9 import gsutil |
10 import imp | 10 import imp |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 print 'At least one command must be specified' | 112 print 'At least one command must be specified' |
113 parser.print_help() | 113 parser.print_help() |
114 sys.exit(1) | 114 sys.exit(1) |
115 | 115 |
116 if args[0] == 'promote': | 116 if args[0] == 'promote': |
117 command = 'promote' | 117 command = 'promote' |
118 if options.revision is None: | 118 if options.revision is None: |
119 print 'You must specify a --revision to specify which revision to promote' | 119 print 'You must specify a --revision to specify which revision to promote' |
120 parser.print_help() | 120 parser.print_help() |
121 sys.exit(3) | 121 sys.exit(3) |
| 122 |
| 123 # Make sure revision is a valid integer |
| 124 try: |
| 125 _ = int(options.revision) |
| 126 except: |
| 127 print 'You must supply a valid integer argument to --revision to promote' |
| 128 parser.print_help() |
| 129 sys.exit(3) |
| 130 |
| 131 # Make sure options.channel is a valid channel if given |
| 132 if options.channel: |
| 133 if options.channel not in bot_utils.Channel.ALL_CHANNELS: |
| 134 print 'You must supply a valid channel to --channel to promote' |
| 135 parser.print_help() |
| 136 sys.exit(3) |
| 137 |
122 if not (options.continuous or options.integration or | 138 if not (options.continuous or options.integration or |
123 options.testing or options.trunk or options.internal or | 139 options.testing or options.trunk or options.internal or |
124 options.channel): | 140 options.channel): |
125 print ('Specify --continuous, --integration, --testing, --trunk or ' | 141 print ('Specify --continuous, --integration, --testing, --trunk or ' |
126 '--channel=be/dev/stable') | 142 '--channel=be/dev/stable') |
127 parser.print_help() | 143 parser.print_help() |
128 sys.exit(4) | 144 sys.exit(4) |
129 if options.continuous and options.integration: | 145 if options.continuous and options.integration: |
130 print 'continuous and integration can not be specified at the same time' | 146 print 'continuous and integration can not be specified at the same time' |
131 parser.print_help() | 147 parser.print_help() |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest]) | 298 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest]) |
283 | 299 |
284 def _PromoteDartArchiveBuild(channel, revision): | 300 def _PromoteDartArchiveBuild(channel, revision): |
285 # These namer objects will be used to create GCS object URIs. For the | 301 # These namer objects will be used to create GCS object URIs. For the |
286 # structure we use, please see tools/bots/bot_utils.py:GCSNamer | 302 # structure we use, please see tools/bots/bot_utils.py:GCSNamer |
287 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) | 303 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) |
288 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) | 304 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) |
289 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE) | 305 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE) |
290 | 306 |
291 def promote(to_revision): | 307 def promote(to_revision): |
| 308 def safety_check_on_gs_path(gs_path, revision, channel): |
| 309 if not ((revision == 'latest' or int(revision) > 0) |
| 310 and len(channel) > 0 |
| 311 and ('%s' % revision) in gs_path |
| 312 and channel in gs_path): |
| 313 raise Exception( |
| 314 "InternalError: Sanity check failed on GS URI: %s" % gs_path) |
| 315 |
| 316 def remove_gs_directory(gs_path): |
| 317 safety_check_on_gs_path(gs_path, to_revision, channel) |
| 318 _Gsutil(['-m', 'rm', '-R', '-f', gs_path]) |
| 319 |
292 # Copy VERSION file. | 320 # Copy VERSION file. |
293 from_loc = raw_namer.version_filepath(revision) | 321 from_loc = raw_namer.version_filepath(revision) |
294 to_loc = release_namer.version_filepath(to_revision) | 322 to_loc = release_namer.version_filepath(to_revision) |
295 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) | 323 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) |
296 | 324 |
297 # Copy sdk directory. | 325 # Copy sdk directory. |
298 from_loc = raw_namer.sdk_directory(revision) | 326 from_loc = raw_namer.sdk_directory(revision) |
299 to_loc = release_namer.sdk_directory(to_revision) | 327 to_loc = release_namer.sdk_directory(to_revision) |
| 328 remove_gs_directory(to_loc) |
300 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 329 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
301 | 330 |
302 # Copy eclipse update directory. | 331 # Copy eclipse update directory. |
303 from_loc = raw_namer.editor_eclipse_update_directory(revision) | 332 from_loc = raw_namer.editor_eclipse_update_directory(revision) |
304 to_loc = release_namer.editor_eclipse_update_directory(to_revision) | 333 to_loc = release_namer.editor_eclipse_update_directory(to_revision) |
| 334 remove_gs_directory(to_loc) |
305 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 335 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
306 | 336 |
307 # Copy api-docs directory. | 337 # Copy api-docs zipfile. |
308 from_loc = raw_namer.apidocs_directory(revision) | 338 from_loc = raw_namer.apidocs_zipfilepath(revision) |
309 to_loc = release_namer.apidocs_directory(to_revision) | 339 to_loc = release_namer.apidocs_zipfilepath(to_revision) |
310 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 340 _Gsutil(['-m', 'cp', '-a', 'public-read', from_loc, to_loc]) |
311 | 341 |
312 # Copy dartium directory. | 342 # Copy dartium directory. |
313 from_loc = raw_namer.dartium_directory(revision) | 343 from_loc = raw_namer.dartium_directory(revision) |
314 to_loc = release_namer.dartium_directory(to_revision) | 344 to_loc = release_namer.dartium_directory(to_revision) |
| 345 remove_gs_directory(to_loc) |
315 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | 346 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) |
316 | 347 |
317 # Copy editor zip files. | 348 # Copy editor zip files. |
| 349 target_editor_dir = release_namer.editor_directory(to_revision) |
| 350 remove_gs_directory(target_editor_dir) |
318 for system in ['windows', 'macos', 'linux']: | 351 for system in ['windows', 'macos', 'linux']: |
319 for arch in ['ia32', 'x64']: | 352 for arch in ['ia32', 'x64']: |
320 from_namer = raw_namer | 353 from_namer = raw_namer |
321 # We have signed versions of the editor for windows and macos. | 354 # We have signed versions of the editor for windows and macos. |
322 if system == 'windows' or system == 'macos': | 355 if system == 'windows' or system == 'macos': |
323 from_namer = signed_namer | 356 from_namer = signed_namer |
324 from_loc = from_namer.editor_zipfilepath(revision, system, arch) | 357 from_loc = from_namer.editor_zipfilepath(revision, system, arch) |
325 to_loc = release_namer.editor_zipfilepath(to_revision, system, arch) | 358 to_loc = release_namer.editor_zipfilepath(to_revision, system, arch) |
326 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) | 359 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) |
327 _Gsutil(['cp', '-a', 'public-read', from_loc + '.md5sum', | 360 _Gsutil(['cp', '-a', 'public-read', from_loc + '.md5sum', |
(...skipping 23 matching lines...) Expand all Loading... |
351 if directory is not None: | 384 if directory is not None: |
352 cwd = os.getcwd() | 385 cwd = os.getcwd() |
353 os.chdir(directory) | 386 os.chdir(directory) |
354 subprocess.call(cmd, env=os.environ) | 387 subprocess.call(cmd, env=os.environ) |
355 if directory is not None: | 388 if directory is not None: |
356 os.chdir(cwd) | 389 os.chdir(cwd) |
357 | 390 |
358 | 391 |
359 if __name__ == '__main__': | 392 if __name__ == '__main__': |
360 sys.exit(main()) | 393 sys.exit(main()) |
OLD | NEW |