| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ Creates a zip file in the staging dir with the result of a compile. | 6 """ Creates a zip file in the staging dir with the result of a compile. |
| 7 It can be sent to other machines for testing. | 7 It can be sent to other machines for testing. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import csv | 10 import csv |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 def MakeVersionedArchive(zip_file, file_suffix, options): | 192 def MakeVersionedArchive(zip_file, file_suffix, options): |
| 193 """Takes a file name, e.g. /foo/bar.zip and an extra suffix, e.g. _baz, | 193 """Takes a file name, e.g. /foo/bar.zip and an extra suffix, e.g. _baz, |
| 194 and copies (or hardlinks) the file to /foo/bar_baz.zip. | 194 and copies (or hardlinks) the file to /foo/bar_baz.zip. |
| 195 | 195 |
| 196 Returns: A tuple containing three elements: the base filename, the extension | 196 Returns: A tuple containing three elements: the base filename, the extension |
| 197 and the full versioned filename.""" | 197 and the full versioned filename.""" |
| 198 zip_template = os.path.basename(zip_file) | 198 zip_template = os.path.basename(zip_file) |
| 199 zip_base, zip_ext = os.path.splitext(zip_template) | 199 zip_base, zip_ext = os.path.splitext(zip_template) |
| 200 # Create a versioned copy of the file. | 200 # Create a versioned copy of the file. |
| 201 versioned_file = zip_file.replace(zip_ext, file_suffix + zip_ext) | 201 versioned_file = zip_file.replace(zip_ext, file_suffix + zip_ext) |
| 202 # Allow for overriding the name of the file based on the given upload url. |
| 203 if options.use_build_url_name: |
| 204 new_build_url, new_archive_name = options.build_url.rsplit('/', 1) |
| 205 if new_archive_name and new_archive_name.endswith('.zip'): |
| 206 options.build_url = new_build_url |
| 207 versioned_file = zip_file.replace(zip_template, new_archive_name) |
| 202 if os.path.exists(versioned_file): | 208 if os.path.exists(versioned_file): |
| 203 # This file already exists. Maybe we are doing a clobber build at the same | 209 # This file already exists. Maybe we are doing a clobber build at the same |
| 204 # revision. We can move this file away. | 210 # revision. We can move this file away. |
| 205 old_file = versioned_file.replace(zip_ext, '_old' + zip_ext) | 211 old_file = versioned_file.replace(zip_ext, '_old' + zip_ext) |
| 206 chromium_utils.MoveFile(versioned_file, old_file) | 212 chromium_utils.MoveFile(versioned_file, old_file) |
| 207 if chromium_utils.IsWindows(): | 213 if chromium_utils.IsWindows(): |
| 208 shutil.copyfile(zip_file, versioned_file) | 214 shutil.copyfile(zip_file, versioned_file) |
| 209 else: | 215 else: |
| 210 os.link(zip_file, versioned_file) | 216 os.link(zip_file, versioned_file) |
| 211 chromium_utils.MakeWorldReadable(versioned_file) | 217 chromium_utils.MakeWorldReadable(versioned_file) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 help='The revision the archive should be at. ' | 432 help='The revision the archive should be at. ' |
| 427 'Overrides the revision found on disk.') | 433 'Overrides the revision found on disk.') |
| 428 option_parser.add_option('--webkit_revision', | 434 option_parser.add_option('--webkit_revision', |
| 429 help='The revision of webkit the build is at. ' | 435 help='The revision of webkit the build is at. ' |
| 430 'Overrides the revision found on disk.') | 436 'Overrides the revision found on disk.') |
| 431 option_parser.add_option('--exclude-unmatched', action='store_true', | 437 option_parser.add_option('--exclude-unmatched', action='store_true', |
| 432 help='Exclude all files not matched by a whitelist') | 438 help='Exclude all files not matched by a whitelist') |
| 433 option_parser.add_option('--build-url', default='', | 439 option_parser.add_option('--build-url', default='', |
| 434 help=('Optional URL to which to upload build ' | 440 help=('Optional URL to which to upload build ' |
| 435 '(overrides build_url factory property)')) | 441 '(overrides build_url factory property)')) |
| 442 option_parser.add_option('--use-build-url-name', action='store_true', |
| 443 help=('Use the filename given in --build-url instead' |
| 444 'of generating one.')) |
| 436 option_parser.add_option('--cros-board', | 445 option_parser.add_option('--cros-board', |
| 437 help=('If building for Chrom[e|ium]OS via the ' | 446 help=('If building for Chrom[e|ium]OS via the ' |
| 438 'simple chrome workflow, the name of the ' | 447 'simple chrome workflow, the name of the ' |
| 439 'target CROS board.')) | 448 'target CROS board.')) |
| 440 option_parser.add_option('--package-dsym-files', action='store_true', | 449 option_parser.add_option('--package-dsym-files', action='store_true', |
| 441 default=False, help='Add also dSYM files.') | 450 default=False, help='Add also dSYM files.') |
| 442 option_parser.add_option('--append-deps-patch-sha', action='store_true') | 451 option_parser.add_option('--append-deps-patch-sha', action='store_true') |
| 443 option_parser.add_option('--gs-acl') | 452 option_parser.add_option('--gs-acl') |
| 444 option_parser.add_option('--json-urls', | 453 option_parser.add_option('--json-urls', |
| 445 help=('Path to json file containing uploaded ' | 454 help=('Path to json file containing uploaded ' |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 json.dump(urls, json_file) | 496 json.dump(urls, json_file) |
| 488 else: # we need to print buildbot annotations | 497 else: # we need to print buildbot annotations |
| 489 if 'storage_url' in urls: | 498 if 'storage_url' in urls: |
| 490 print '@@@STEP_LINK@download@%s@@@' % urls['storage_url'] | 499 print '@@@STEP_LINK@download@%s@@@' % urls['storage_url'] |
| 491 if 'zip_url' in urls: | 500 if 'zip_url' in urls: |
| 492 print '@@@SET_BUILD_PROPERTY@build_archive_url@"%s"@@@' % urls['zip_url'] | 501 print '@@@SET_BUILD_PROPERTY@build_archive_url@"%s"@@@' % urls['zip_url'] |
| 493 return 0 | 502 return 0 |
| 494 | 503 |
| 495 if '__main__' == __name__: | 504 if '__main__' == __name__: |
| 496 sys.exit(main(sys.argv)) | 505 sys.exit(main(sys.argv)) |
| OLD | NEW |