| 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 """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 # pylint is convinced the email module is missing attributes | 10 # pylint is convinced the email module is missing attributes |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 MANIFEST_BASENAME = 'naclsdk_manifest2.json' | 32 MANIFEST_BASENAME = 'naclsdk_manifest2.json' |
| 33 SCRIPT_DIR = os.path.dirname(__file__) | 33 SCRIPT_DIR = os.path.dirname(__file__) |
| 34 REPO_MANIFEST = os.path.join(SCRIPT_DIR, 'json', MANIFEST_BASENAME) | 34 REPO_MANIFEST = os.path.join(SCRIPT_DIR, 'json', MANIFEST_BASENAME) |
| 35 GS_BUCKET_PATH = 'gs://nativeclient-mirror/nacl/nacl_sdk/' | 35 GS_BUCKET_PATH = 'gs://nativeclient-mirror/nacl/nacl_sdk/' |
| 36 GS_SDK_MANIFEST = GS_BUCKET_PATH + MANIFEST_BASENAME | 36 GS_SDK_MANIFEST = GS_BUCKET_PATH + MANIFEST_BASENAME |
| 37 GS_SDK_MANIFEST_LOG = GS_BUCKET_PATH + MANIFEST_BASENAME + '.log' | 37 GS_SDK_MANIFEST_LOG = GS_BUCKET_PATH + MANIFEST_BASENAME + '.log' |
| 38 GS_MANIFEST_BACKUP_DIR = GS_BUCKET_PATH + 'manifest_backups/' | 38 GS_MANIFEST_BACKUP_DIR = GS_BUCKET_PATH + 'manifest_backups/' |
| 39 | 39 |
| 40 CANARY_BUNDLE_NAME = 'pepper_canary' | 40 CANARY_BUNDLE_NAME = 'pepper_canary' |
| 41 BIONIC_CANARY_BUNDLE_NAME = 'bionic_canary' | |
| 42 CANARY = 'canary' | 41 CANARY = 'canary' |
| 43 NACLPORTS_ARCHIVE_NAME = 'naclports.tar.bz2' | 42 NACLPORTS_ARCHIVE_NAME = 'naclports.tar.bz2' |
| 44 | 43 |
| 45 | 44 |
| 46 logger = logging.getLogger(__name__) | 45 logger = logging.getLogger(__name__) |
| 47 | 46 |
| 48 | 47 |
| 49 def SplitVersion(version_string): | 48 def SplitVersion(version_string): |
| 50 """Split a version string (e.g. "18.0.1025.163") into its components. | 49 """Split a version string (e.g. "18.0.1025.163") into its components. |
| 51 | 50 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 117 |
| 119 Args: | 118 Args: |
| 120 platform: One of ('win', 'mac', 'linux'). | 119 platform: One of ('win', 'mac', 'linux'). |
| 121 | 120 |
| 122 Returns: | 121 Returns: |
| 123 The basename of the sdk archive for that platform. | 122 The basename of the sdk archive for that platform. |
| 124 """ | 123 """ |
| 125 return 'naclsdk_%s.tar.bz2' % platform | 124 return 'naclsdk_%s.tar.bz2' % platform |
| 126 | 125 |
| 127 | 126 |
| 128 def GetBionicArchiveName(): | |
| 129 """Get the basename of an archive. Currently this is linux-only""" | |
| 130 return 'naclsdk_bionic.tar.bz2' | |
| 131 | |
| 132 | |
| 133 def GetCanonicalArchiveName(url): | 127 def GetCanonicalArchiveName(url): |
| 134 """Get the canonical name of an archive given its URL. | 128 """Get the canonical name of an archive given its URL. |
| 135 | 129 |
| 136 This will convert "naclsdk_linux.bz2" -> "naclsdk_linux.tar.bz2", and also | 130 This will convert "naclsdk_linux.bz2" -> "naclsdk_linux.tar.bz2", and also |
| 137 remove everything but the filename of the URL. | 131 remove everything but the filename of the URL. |
| 138 | 132 |
| 139 This is used below to determine if an expected bundle is found in an version | 133 This is used below to determine if an expected bundle is found in an version |
| 140 directory; the archives all have the same name, but may not exist for a given | 134 directory; the archives all have the same name, but may not exist for a given |
| 141 version. | 135 version. |
| 142 | 136 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 """Finds a version of a pepper bundle that all desired platforms share. | 348 """Finds a version of a pepper bundle that all desired platforms share. |
| 355 | 349 |
| 356 Args: | 350 Args: |
| 357 delegate: See Delegate class above. | 351 delegate: See Delegate class above. |
| 358 platforms: A sequence of platforms to consider, e.g. | 352 platforms: A sequence of platforms to consider, e.g. |
| 359 ('mac', 'linux', 'win') | 353 ('mac', 'linux', 'win') |
| 360 extra_archives: A sequence of tuples: (archive_basename, minimum_version), | 354 extra_archives: A sequence of tuples: (archive_basename, minimum_version), |
| 361 e.g. [('foo.tar.bz2', '18.0.1000.0'), ('bar.tar.bz2', '19.0.1100.20')] | 355 e.g. [('foo.tar.bz2', '18.0.1000.0'), ('bar.tar.bz2', '19.0.1100.20')] |
| 362 These archives must exist to consider a version for inclusion, as | 356 These archives must exist to consider a version for inclusion, as |
| 363 long as that version is greater than the archive's minimum version. | 357 long as that version is greater than the archive's minimum version. |
| 364 is_bionic: True if we are searching for bionic archives. | |
| 365 """ | 358 """ |
| 366 def __init__(self, delegate, platforms, extra_archives=None, is_bionic=False): | 359 def __init__(self, delegate, platforms, extra_archives=None): |
| 367 self.delegate = delegate | 360 self.delegate = delegate |
| 368 self.history = delegate.GetHistory() | 361 self.history = delegate.GetHistory() |
| 369 self.platforms = platforms | 362 self.platforms = platforms |
| 370 self.extra_archives = extra_archives | 363 self.extra_archives = extra_archives |
| 371 self.is_bionic = is_bionic | |
| 372 | 364 |
| 373 def GetMostRecentSharedVersion(self, major_version): | 365 def GetMostRecentSharedVersion(self, major_version): |
| 374 """Returns the most recent version of a pepper bundle that exists on all | 366 """Returns the most recent version of a pepper bundle that exists on all |
| 375 given platforms. | 367 given platforms. |
| 376 | 368 |
| 377 Specifically, the resulting version should be the most recently released | 369 Specifically, the resulting version should be the most recently released |
| 378 (meaning closest to the top of the listing on | 370 (meaning closest to the top of the listing on |
| 379 omahaproxy.appspot.com/history) version that has a Chrome release on all | 371 omahaproxy.appspot.com/history) version that has a Chrome release on all |
| 380 given platforms, and has a pepper bundle archive for each platform as well. | 372 given platforms, and has a pepper bundle archive for each platform as well. |
| 381 | 373 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 not have an archive for the given version. | 406 not have an archive for the given version. |
| 415 | 407 |
| 416 Args: | 408 Args: |
| 417 version: The version to find archives for. (e.g. "18.0.1025.164") | 409 version: The version to find archives for. (e.g. "18.0.1025.164") |
| 418 Returns: | 410 Returns: |
| 419 A tuple (archives, missing_archives). |archives| is a list of archive | 411 A tuple (archives, missing_archives). |archives| is a list of archive |
| 420 URLs, |missing_archives| is a list of archive names. | 412 URLs, |missing_archives| is a list of archive names. |
| 421 """ | 413 """ |
| 422 archive_urls = self._GetAvailableArchivesFor(version) | 414 archive_urls = self._GetAvailableArchivesFor(version) |
| 423 | 415 |
| 424 if self.is_bionic: | 416 expected_archives = set(GetPlatformArchiveName(p) for p in self.platforms) |
| 425 # Bionic currently is Linux-only. | |
| 426 expected_archives = set([GetBionicArchiveName()]) | |
| 427 else: | |
| 428 expected_archives = set(GetPlatformArchiveName(p) for p in self.platforms) | |
| 429 | 417 |
| 430 if self.extra_archives: | 418 if self.extra_archives: |
| 431 for extra_archive, min_version, max_version in self.extra_archives: | 419 for extra_archive, min_version, max_version in self.extra_archives: |
| 432 if (CompareVersions(version, min_version) >= 0 and | 420 if (CompareVersions(version, min_version) >= 0 and |
| 433 CompareVersions(version, max_version) < 0): | 421 CompareVersions(version, max_version) < 0): |
| 434 expected_archives.add(extra_archive) | 422 expected_archives.add(extra_archive) |
| 435 found_archives = set(GetCanonicalArchiveName(a) for a in archive_urls) | 423 found_archives = set(GetCanonicalArchiveName(a) for a in archive_urls) |
| 436 missing_archives = expected_archives - found_archives | 424 missing_archives = expected_archives - found_archives |
| 437 | 425 |
| 438 # Only return archives that are "expected". | 426 # Only return archives that are "expected". |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 e.g. ('pepper_21', '21.0.1145.0') | 789 e.g. ('pepper_21', '21.0.1145.0') |
| 802 """ | 790 """ |
| 803 if fixed_bundle_versions: | 791 if fixed_bundle_versions: |
| 804 fixed_bundle_versions = dict(fixed_bundle_versions) | 792 fixed_bundle_versions = dict(fixed_bundle_versions) |
| 805 else: | 793 else: |
| 806 fixed_bundle_versions = {} | 794 fixed_bundle_versions = {} |
| 807 | 795 |
| 808 manifest = delegate.GetRepoManifest() | 796 manifest = delegate.GetRepoManifest() |
| 809 auto_update_bundles = [] | 797 auto_update_bundles = [] |
| 810 for bundle in manifest.GetBundles(): | 798 for bundle in manifest.GetBundles(): |
| 811 if not bundle.name.startswith(('pepper_', 'bionic_')): | 799 if not bundle.name.startswith('pepper_'): |
| 812 continue | 800 continue |
| 813 archives = bundle.GetArchives() | 801 archives = bundle.GetArchives() |
| 814 if not archives: | 802 if not archives: |
| 815 auto_update_bundles.append(bundle) | 803 auto_update_bundles.append(bundle) |
| 816 | 804 |
| 817 if not auto_update_bundles: | 805 if not auto_update_bundles: |
| 818 logger.info('No versions need auto-updating.') | 806 logger.info('No versions need auto-updating.') |
| 819 return | 807 return |
| 820 | 808 |
| 821 updater = Updater(delegate) | 809 updater = Updater(delegate) |
| 822 | 810 |
| 823 for bundle in auto_update_bundles: | 811 for bundle in auto_update_bundles: |
| 824 try: | 812 try: |
| 825 if bundle.name == BIONIC_CANARY_BUNDLE_NAME: | 813 if bundle.name == CANARY_BUNDLE_NAME: |
| 826 logger.info('>>> Looking for most recent bionic_canary...') | |
| 827 # Ignore extra_archives on bionic; There is no naclports bundle yet. | |
| 828 version_finder = VersionFinder(delegate, platforms, None, | |
| 829 is_bionic=True) | |
| 830 version, channel, archives = version_finder.GetMostRecentSharedCanary() | |
| 831 elif bundle.name == CANARY_BUNDLE_NAME: | |
| 832 logger.info('>>> Looking for most recent pepper_canary...') | 814 logger.info('>>> Looking for most recent pepper_canary...') |
| 833 version_finder = VersionFinder(delegate, platforms, extra_archives) | 815 version_finder = VersionFinder(delegate, platforms, extra_archives) |
| 834 version, channel, archives = version_finder.GetMostRecentSharedCanary() | 816 version, channel, archives = version_finder.GetMostRecentSharedCanary() |
| 835 else: | 817 else: |
| 836 logger.info('>>> Looking for most recent pepper_%s...' % | 818 logger.info('>>> Looking for most recent pepper_%s...' % |
| 837 bundle.version) | 819 bundle.version) |
| 838 version_finder = VersionFinder(delegate, platforms, extra_archives) | 820 version_finder = VersionFinder(delegate, platforms, extra_archives) |
| 839 version, channel, archives = version_finder.GetMostRecentSharedVersion( | 821 version, channel, archives = version_finder.GetMostRecentSharedVersion( |
| 840 bundle.version) | 822 bundle.version) |
| 841 except NoSharedVersionException: | 823 except NoSharedVersionException: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 except manifest_util.Error as e: | 938 except manifest_util.Error as e: |
| 957 if options.debug: | 939 if options.debug: |
| 958 raise | 940 raise |
| 959 sys.stderr.write(str(e) + '\n') | 941 sys.stderr.write(str(e) + '\n') |
| 960 return 1 | 942 return 1 |
| 961 | 943 |
| 962 return 0 | 944 return 0 |
| 963 | 945 |
| 964 if __name__ == '__main__': | 946 if __name__ == '__main__': |
| 965 sys.exit(main(sys.argv[1:])) | 947 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |