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

Side by Side Diff: scripts/slave/zip_build.py

Issue 2112413002: Allowing zip_build to use a file name given in build_url. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
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
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.override_archive_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)
212 print 'Created versioned archive', versioned_file 218 print 'Created versioned archive', versioned_file
213 return (zip_base, zip_ext, versioned_file) 219 return (zip_base, zip_ext, versioned_file)
214 220
215 221
216 def UploadToGoogleStorage(versioned_file, revision_file, build_url, gs_acl, 222 def UploadToGoogleStorage(versioned_file, revision_file, build_url, gs_acl,
217 gsutil_py_path=None): 223 gsutil_py_path=None):
224
218 override_gsutil = None 225 override_gsutil = None
219 if gsutil_py_path: 226 if gsutil_py_path:
220 override_gsutil = [sys.executable, gsutil_py_path] 227 override_gsutil = [sys.executable, gsutil_py_path]
221 228
222 if slave_utils.GSUtilCopyFile(versioned_file, build_url, gs_acl=gs_acl, 229 if slave_utils.GSUtilCopyFile(versioned_file, build_url, gs_acl=gs_acl,
223 override_gsutil=override_gsutil): 230 override_gsutil=override_gsutil):
224 raise chromium_utils.ExternalError( 231 raise chromium_utils.ExternalError(
225 'gsutil returned non-zero status when uploading %s to %s!' % 232 'gsutil returned non-zero status when uploading %s to %s!' %
226 (versioned_file, build_url)) 233 (versioned_file, build_url))
227 print 'Successfully uploaded %s to %s' % (versioned_file, build_url) 234 print 'Successfully uploaded %s to %s' % (versioned_file, build_url)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 help='The revision the archive should be at. ' 433 help='The revision the archive should be at. '
427 'Overrides the revision found on disk.') 434 'Overrides the revision found on disk.')
428 option_parser.add_option('--webkit_revision', 435 option_parser.add_option('--webkit_revision',
429 help='The revision of webkit the build is at. ' 436 help='The revision of webkit the build is at. '
430 'Overrides the revision found on disk.') 437 'Overrides the revision found on disk.')
431 option_parser.add_option('--exclude-unmatched', action='store_true', 438 option_parser.add_option('--exclude-unmatched', action='store_true',
432 help='Exclude all files not matched by a whitelist') 439 help='Exclude all files not matched by a whitelist')
433 option_parser.add_option('--build-url', default='', 440 option_parser.add_option('--build-url', default='',
434 help=('Optional URL to which to upload build ' 441 help=('Optional URL to which to upload build '
435 '(overrides build_url factory property)')) 442 '(overrides build_url factory property)'))
443 option_parser.add_option('--override-archive-name', action='store_true',
martiniss 2016/07/06 21:28:47 Maybe name this '--use-build-url-name' instead? Ov
RobertoCN 2016/07/06 22:06:49 Done.
444 help=('Use the filename given in --build-url instead'
445 'of generating one.'))
436 option_parser.add_option('--cros-board', 446 option_parser.add_option('--cros-board',
437 help=('If building for Chrom[e|ium]OS via the ' 447 help=('If building for Chrom[e|ium]OS via the '
438 'simple chrome workflow, the name of the ' 448 'simple chrome workflow, the name of the '
439 'target CROS board.')) 449 'target CROS board.'))
440 option_parser.add_option('--package-dsym-files', action='store_true', 450 option_parser.add_option('--package-dsym-files', action='store_true',
441 default=False, help='Add also dSYM files.') 451 default=False, help='Add also dSYM files.')
442 option_parser.add_option('--append-deps-patch-sha', action='store_true') 452 option_parser.add_option('--append-deps-patch-sha', action='store_true')
443 option_parser.add_option('--gs-acl') 453 option_parser.add_option('--gs-acl')
444 option_parser.add_option('--json-urls', 454 option_parser.add_option('--json-urls',
445 help=('Path to json file containing uploaded ' 455 help=('Path to json file containing uploaded '
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 json.dump(urls, json_file) 497 json.dump(urls, json_file)
488 else: # we need to print buildbot annotations 498 else: # we need to print buildbot annotations
489 if 'storage_url' in urls: 499 if 'storage_url' in urls:
490 print '@@@STEP_LINK@download@%s@@@' % urls['storage_url'] 500 print '@@@STEP_LINK@download@%s@@@' % urls['storage_url']
491 if 'zip_url' in urls: 501 if 'zip_url' in urls:
492 print '@@@SET_BUILD_PROPERTY@build_archive_url@"%s"@@@' % urls['zip_url'] 502 print '@@@SET_BUILD_PROPERTY@build_archive_url@"%s"@@@' % urls['zip_url']
493 return 0 503 return 0
494 504
495 if '__main__' == __name__: 505 if '__main__' == __name__:
496 sys.exit(main(sys.argv)) 506 sys.exit(main(sys.argv))
OLDNEW
« scripts/slave/recipe_modules/archive/api.py ('K') | « scripts/slave/recipe_modules/archive/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698