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

Side by Side Diff: native_client_sdk/src/build_tools/update_nacl_manifest.py

Issue 10868089: add PRESUBMIT for native_client_sdk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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 | Annotate | Revision Log
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 """Script that reads omahaproxy and gsutil to determine version of SDK to put 6 """Script that reads omahaproxy and gsutil to determine version of SDK to put
7 in manifest. 7 in manifest.
8 """ 8 """
9 9
10 import buildbot_common 10 import buildbot_common
(...skipping 14 matching lines...) Expand all
25 25
26 26
27 MANIFEST_BASENAME = 'naclsdk_manifest2.json' 27 MANIFEST_BASENAME = 'naclsdk_manifest2.json'
28 SCRIPT_DIR = os.path.dirname(__file__) 28 SCRIPT_DIR = os.path.dirname(__file__)
29 REPO_MANIFEST = os.path.join(SCRIPT_DIR, 'json', MANIFEST_BASENAME) 29 REPO_MANIFEST = os.path.join(SCRIPT_DIR, 'json', MANIFEST_BASENAME)
30 GS_BUCKET_PATH = 'gs://nativeclient-mirror/nacl/nacl_sdk/' 30 GS_BUCKET_PATH = 'gs://nativeclient-mirror/nacl/nacl_sdk/'
31 GS_SDK_MANIFEST = GS_BUCKET_PATH + MANIFEST_BASENAME 31 GS_SDK_MANIFEST = GS_BUCKET_PATH + MANIFEST_BASENAME
32 GS_MANIFEST_BACKUP_DIR = GS_BUCKET_PATH + 'manifest_backups/' 32 GS_MANIFEST_BACKUP_DIR = GS_BUCKET_PATH + 'manifest_backups/'
33 33
34 CANARY_BUNDLE_NAME = 'pepper_canary' 34 CANARY_BUNDLE_NAME = 'pepper_canary'
35 CANARY='canary' 35 CANARY = 'canary'
36 36
37 37
38 def SplitVersion(version_string): 38 def SplitVersion(version_string):
39 """Split a version string (e.g. "18.0.1025.163") into its components. 39 """Split a version string (e.g. "18.0.1025.163") into its components.
40 40
41 Note that this function doesn't handle versions in the form "trunk.###". 41 Note that this function doesn't handle versions in the form "trunk.###".
42 """ 42 """
43 return tuple(map(int, version_string.split('.'))) 43 return tuple(map(int, version_string.split('.')))
44 44
45 45
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 Args: 372 Args:
373 with_platform: The name of the platform to filter for. 373 with_platform: The name of the platform to filter for.
374 Returns: 374 Returns:
375 A generator that yields a tuple (channel, version) for each version that 375 A generator that yields a tuple (channel, version) for each version that
376 matches the platform and uses the canary channel. The version returned is 376 matches the platform and uses the canary channel. The version returned is
377 a tuple as returned from SplitVersion. 377 a tuple as returned from SplitVersion.
378 """ 378 """
379 for platform, channel, version, _ in self.history: 379 for platform, channel, version, _ in self.history:
380 version = SplitVersion(version) 380 version = SplitVersion(version)
381 if with_platform == platform and channel==CANARY: 381 if with_platform == platform and channel == CANARY:
382 yield channel, version 382 yield channel, version
383 383
384 384
385 def _FindNextSharedVersion(self, platforms, generator_func): 385 def _FindNextSharedVersion(self, platforms, generator_func):
386 """Yields versions of Chrome that exist on all given platforms, in order of 386 """Yields versions of Chrome that exist on all given platforms, in order of
387 newest to oldest. 387 newest to oldest.
388 388
389 Versions are compared in reverse order of release. That is, the most 389 Versions are compared in reverse order of release. That is, the most
390 recently updated version will be tested first. 390 recently updated version will be tested first.
391 391
392 Args: 392 Args:
393 platforms: A sequence of platforms to filter for. Any other platforms will 393 platforms: A sequence of platforms to filter for. Any other platforms will
394 be ignored. 394 be ignored.
395 Returns: 395 Returns:
396 A generator that yields a tuple (version, channel) for each version that 396 A generator that yields a tuple (version, channel) for each version that
397 matches all platforms and the major version. The version returned is a 397 matches all platforms and the major version. The version returned is a
398 string (e.g. "18.0.1025.164"). 398 string (e.g. "18.0.1025.164").
399 """ 399 """
400 platform_generators = [] 400 platform_generators = []
401 for platform in platforms: 401 for platform in platforms:
402 platform_generators.append(generator_func(platform)) 402 platform_generators.append(generator_func(platform))
403 403
404 shared_version = None 404 shared_version = None
405 platform_versions = [(tuple(), '')] * len(platforms) 405 platform_versions = [(tuple(), '')] * len(platforms)
406 while True: 406 while True:
407 try: 407 try:
408 for i, platform_gen in enumerate(platform_generators): 408 for i, platform_gen in enumerate(platform_generators):
409 if platform_versions[i][1] != shared_version: 409 if platform_versions[i][1] != shared_version:
410 platform_versions[i] = platform_gen.next() 410 platform_versions[i] = platform_gen.next()
411 except StopIteration: 411 except StopIteration:
412 return 412 return
413 413
414 shared_version = min(v for c, v in platform_versions) 414 shared_version = min(v for c, v in platform_versions)
415 415
416 if all(v == shared_version for c, v in platform_versions): 416 if all(v == shared_version for c, v in platform_versions):
417 # grab the channel from an arbitrary platform 417 # grab the channel from an arbitrary platform
418 first_platform = platform_versions[0] 418 first_platform = platform_versions[0]
419 channel = first_platform[0] 419 channel = first_platform[0]
420 yield JoinVersion(shared_version), channel 420 yield JoinVersion(shared_version), channel
421 421
422 # force increment to next version for all platforms 422 # force increment to next version for all platforms
423 shared_version = None 423 shared_version = None
424 424
425 def _GetAvailableNaClSDKArchivesFor(self, version_string): 425 def _GetAvailableNaClSDKArchivesFor(self, version_string):
426 """Downloads a list of all available archives for a given version. 426 """Downloads a list of all available archives for a given version.
427 427
428 Args: 428 Args:
429 version_string: The version to find archives for. (e.g. "18.0.1025.164") 429 version_string: The version to find archives for. (e.g. "18.0.1025.164")
430 Returns: 430 Returns:
431 A list of strings, each of which is a platform-specific archive URL. (e.g. 431 A list of strings, each of which is a platform-specific archive URL. (e.g.
432 "gs://nativeclient_mirror/nacl/nacl_sdk/18.0.1025.164/" 432 "gs://nativeclient_mirror/nacl/nacl_sdk/18.0.1025.164/"
433 "naclsdk_linux.tar.bz2"). 433 "naclsdk_linux.tar.bz2").
434 434
435 All returned URLs will use the gs:// schema.""" 435 All returned URLs will use the gs:// schema."""
436 files = self.delegate.GsUtil_ls(GS_BUCKET_PATH + version_string) 436 files = self.delegate.GsUtil_ls(GS_BUCKET_PATH + version_string)
437 437
438 assert all(file.startswith('gs://') for file in files) 438 assert all(file.startswith('gs://') for file in files)
439 439
440 archives = [file for file in files if not file.endswith('.json')] 440 archives = [f for f in files if not f.endswith('.json')]
441 manifests = [file for file in files if file.endswith('.json')] 441 manifests = [f for f in files if f.endswith('.json')]
442 442
443 # don't include any archives that don't have an associated manifest. 443 # don't include any archives that don't have an associated manifest.
444 return filter(lambda a: a + '.json' in manifests, archives) 444 return filter(lambda a: a + '.json' in manifests, archives)
445 445
446 446
447 class Updater(object): 447 class Updater(object):
448 def __init__(self, delegate): 448 def __init__(self, delegate):
449 self.delegate = delegate 449 self.delegate = delegate
450 self.versions_to_update = [] 450 self.versions_to_update = []
451 451
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 sys.stderr.write('warning: Disabling email, one of --mailto or --mailfrom ' 608 sys.stderr.write('warning: Disabling email, one of --mailto or --mailfrom '
609 'was missing.\n') 609 'was missing.\n')
610 610
611 if options.mailfrom and options.mailto: 611 if options.mailfrom and options.mailto:
612 # Capture stderr so it can be emailed, if necessary. 612 # Capture stderr so it can be emailed, if necessary.
613 sys.stderr = CapturedFile(sys.stderr) 613 sys.stderr = CapturedFile(sys.stderr)
614 614
615 try: 615 try:
616 delegate = RealDelegate(dryrun=options.dryrun, gsutil=options.gsutil) 616 delegate = RealDelegate(dryrun=options.dryrun, gsutil=options.gsutil)
617 Run(delegate, ('mac', 'win', 'linux')) 617 Run(delegate, ('mac', 'win', 'linux'))
618 except Exception, e: 618 except Exception:
619 if options.mailfrom and options.mailto: 619 if options.mailfrom and options.mailto:
620 traceback.print_exc() 620 traceback.print_exc()
621 scriptname = os.path.basename(sys.argv[0]) 621 scriptname = os.path.basename(sys.argv[0])
622 subject = '[%s] Failed to update manifest' % (scriptname,) 622 subject = '[%s] Failed to update manifest' % (scriptname,)
623 text = '%s failed.\n\nSTDERR:\n%s\n' % (scriptname, sys.stderr.getvalue()) 623 text = '%s failed.\n\nSTDERR:\n%s\n' % (scriptname, sys.stderr.getvalue())
624 SendMail(options.mailfrom, options.mailto, subject, text) 624 SendMail(options.mailfrom, options.mailto, subject, text)
625 sys.exit(1) 625 sys.exit(1)
626 else: 626 else:
627 raise 627 raise
628 628
629 629
630 if __name__ == '__main__': 630 if __name__ == '__main__':
631 sys.exit(main(sys.argv)) 631 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/sdk_tools/update_manifest.py ('k') | native_client_sdk/src/examples/httpd.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698