OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client 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 '''Utility to update the SDK manifest file in the build_tools directory''' | 6 '''Utility to update the SDK manifest file in the build_tools directory''' |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 NACL_SDK_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( | 47 NACL_SDK_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( |
48 os.path.abspath(__file__)))) | 48 os.path.abspath(__file__)))) |
49 | 49 |
50 BUILD_TOOLS_OUT = os.path.join(NACL_SDK_ROOT, 'scons-out', 'build', 'obj', | 50 BUILD_TOOLS_OUT = os.path.join(NACL_SDK_ROOT, 'scons-out', 'build', 'obj', |
51 'build_tools') | 51 'build_tools') |
52 | 52 |
53 BUNDLE_SDK_TOOLS = 'sdk_tools' | 53 BUNDLE_SDK_TOOLS = 'sdk_tools' |
54 BUNDLE_PEPPER_MATCHER = re.compile('^pepper_([0-9]+)$') | 54 BUNDLE_PEPPER_MATCHER = re.compile('^pepper_([0-9]+)$') |
55 IGNORE_OPTIONS = set(['gsutil', 'manifest_file', 'upload', 'root_url']) | 55 IGNORE_OPTIONS = set([ |
| 56 'archive_id', 'gsutil', 'manifest_file', 'upload', 'root_url']) |
56 | 57 |
57 | 58 |
58 class Error(Exception): | 59 class Error(Exception): |
59 '''Generic error/exception for update_manifest module''' | 60 '''Generic error/exception for update_manifest module''' |
60 pass | 61 pass |
61 | 62 |
62 | 63 |
63 def UpdateBundle(bundle, options): | 64 def UpdateBundle(bundle, options): |
64 ''' Update the bundle per content of the options. | 65 ''' Update the bundle per content of the options. |
65 | 66 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 self.SetBundle(bundle) | 127 self.SetBundle(bundle) |
127 UpdateBundle(bundle, options) | 128 UpdateBundle(bundle, options) |
128 | 129 |
129 def _VerifyAllOptionsConsumed(self, options, bundle_name): | 130 def _VerifyAllOptionsConsumed(self, options, bundle_name): |
130 ''' Verify that all the options have been used. Raise an exception if | 131 ''' Verify that all the options have been used. Raise an exception if |
131 any valid option has not been used. Returns True if all options have | 132 any valid option has not been used. Returns True if all options have |
132 been consumed. | 133 been consumed. |
133 | 134 |
134 Args: | 135 Args: |
135 options: the object containing the remaining unused options attributes. | 136 options: the object containing the remaining unused options attributes. |
136 bundl_name: The name of the bundle, or None if it's missing.''' | 137 bundle_name: The name of the bundle, or None if it's missing.''' |
137 # Any option left in the list should have value = None | 138 # Any option left in the list should have value = None |
138 for key, val in options.__dict__.items(): | 139 for key, val in options.__dict__.items(): |
139 if val != None and key not in IGNORE_OPTIONS: | 140 if val != None and key not in IGNORE_OPTIONS: |
140 if bundle_name: | 141 if bundle_name: |
141 raise Error('Unused option "%s" for bundle "%s"' % (key, bundle_name)) | 142 raise Error('Unused option "%s" for bundle "%s"' % (key, bundle_name)) |
142 else: | 143 else: |
143 raise Error('No bundle name specified') | 144 raise Error('No bundle name specified') |
144 return True; | 145 return True; |
145 | 146 |
146 def UpdateManifest(self, options): | 147 def UpdateManifest(self, options): |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 options.bundle_version = int(match.group(1)) | 271 options.bundle_version = int(match.group(1)) |
271 if options.bundle_version is None: | 272 if options.bundle_version is None: |
272 raise Error('Need to specify a bundle version') | 273 raise Error('Need to specify a bundle version') |
273 if options.bundle_revision is None: | 274 if options.bundle_revision is None: |
274 raise Error('Need to specify a bundle revision') | 275 raise Error('Need to specify a bundle revision') |
275 if options.bundle_name == 'pepper': | 276 if options.bundle_name == 'pepper': |
276 self.options.bundle_name = 'pepper_%s' % options.bundle_version | 277 self.options.bundle_name = 'pepper_%s' % options.bundle_version |
277 if options.desc is None: | 278 if options.desc is None: |
278 options.desc = ('Chrome %s bundle, revision %s' % | 279 options.desc = ('Chrome %s bundle, revision %s' % |
279 (options.bundle_version, options.bundle_revision)) | 280 (options.bundle_version, options.bundle_revision)) |
280 root_url = '%s/pepper_%s_%s' % (options.root_url, options.bundle_version, | 281 root_url = options.root_url |
281 options.bundle_revision) | 282 if options.archive_id: |
| 283 # Support archive names like trunk.113440 or 17.0.963.3, which is how |
| 284 # the Chrome builders archive things. |
| 285 root_url = '/'.join([root_url, options.archive_id]) |
| 286 else: |
| 287 # This is the old archive naming scheme |
| 288 root_url = '%s/pepper_%s_%s' % (root_url, options.bundle_version, |
| 289 options.bundle_revision) |
282 options.mac_arch_url = '/'.join([root_url, 'naclsdk_mac.tgz']) | 290 options.mac_arch_url = '/'.join([root_url, 'naclsdk_mac.tgz']) |
283 options.linux_arch_url = '/'.join([root_url, 'naclsdk_linux.tgz']) | 291 options.linux_arch_url = '/'.join([root_url, 'naclsdk_linux.tgz']) |
284 options.win_arch_url = '/'.join([root_url, 'naclsdk_win.exe']) | 292 options.win_arch_url = '/'.join([root_url, 'naclsdk_win.exe']) |
285 | 293 |
286 def HandleBundles(self): | 294 def HandleBundles(self): |
287 '''Handles known bundles by automatically uploading files''' | 295 '''Handles known bundles by automatically uploading files''' |
288 bundle_name = self.options.bundle_name | 296 bundle_name = self.options.bundle_name |
289 if bundle_name == BUNDLE_SDK_TOOLS: | 297 if bundle_name == BUNDLE_SDK_TOOLS: |
290 self._HandleSDKTools() | 298 self._HandleSDKTools() |
291 elif bundle_name.startswith('pepper'): | 299 elif bundle_name.startswith('pepper'): |
(...skipping 12 matching lines...) Expand all Loading... |
304 | 312 |
305 | 313 |
306 def main(argv): | 314 def main(argv): |
307 '''Main entry for update_manifest.py''' | 315 '''Main entry for update_manifest.py''' |
308 | 316 |
309 buildtools_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 317 buildtools_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
310 parser = optparse.OptionParser(usage=HELP) | 318 parser = optparse.OptionParser(usage=HELP) |
311 | 319 |
312 # Setup options | 320 # Setup options |
313 parser.add_option( | 321 parser.add_option( |
| 322 '-a', '--archive-id', dest='archive_id', |
| 323 default=None, |
| 324 help='Archive identifier, produced by the Chromium builders; string ' |
| 325 'like "trunk.113440" or "17.0.963.3". Used with --root-url to ' |
| 326 'build the full archive URL. If not set the archive id defaults to ' |
| 327 '"pepper_<version>_<revision>"') |
| 328 parser.add_option( |
314 '-b', '--bundle-version', dest='bundle_version', | 329 '-b', '--bundle-version', dest='bundle_version', |
315 type='int', | 330 type='int', |
316 default=None, | 331 default=None, |
317 help='Required: Version number for the bundle.') | 332 help='Required: Version number for the bundle.') |
318 parser.add_option( | 333 parser.add_option( |
319 '-B', '--bundle-revision', dest='bundle_revision', | 334 '-B', '--bundle-revision', dest='bundle_revision', |
320 type='int', | 335 type='int', |
321 default=None, | 336 default=None, |
322 help='Required: Revision number for the bundle.') | 337 help='Required: Revision number for the bundle.') |
323 parser.add_option( | 338 parser.add_option( |
(...skipping 17 matching lines...) Expand all Loading... |
341 default=None, | 356 default=None, |
342 help='URL for the Mac archive.') | 357 help='URL for the Mac archive.') |
343 parser.add_option( | 358 parser.add_option( |
344 '-n', '--bundle-name', dest='bundle_name', | 359 '-n', '--bundle-name', dest='bundle_name', |
345 default=None, | 360 default=None, |
346 help='Required: Name of the bundle.') | 361 help='Required: Name of the bundle.') |
347 parser.add_option( | 362 parser.add_option( |
348 '-r', '--recommended', dest='recommended', | 363 '-r', '--recommended', dest='recommended', |
349 choices=sdk_update.YES_NO_LITERALS, | 364 choices=sdk_update.YES_NO_LITERALS, |
350 default=None, | 365 default=None, |
351 help='Required: whether this bundle is recommended. one of "yes" or "no"') | 366 help='Required: whether this bundle is recommended. One of "yes" or "no"') |
352 parser.add_option( | 367 parser.add_option( |
353 '-R', '--root-url', dest='root_url', | 368 '-R', '--root-url', dest='root_url', |
354 default='http://commondatastorage.googleapis.com/nativeclient-mirror/' | 369 default='http://commondatastorage.googleapis.com/nativeclient-mirror/' |
355 'nacl/nacl_sdk', | 370 'nacl/nacl_sdk', |
356 help='Root url for uploading') | 371 help='Root url for uploading') |
357 parser.add_option( | 372 parser.add_option( |
358 '-s', '--stability', dest='stability', | 373 '-s', '--stability', dest='stability', |
359 choices=sdk_update.STABILITY_LITERALS, | 374 choices=sdk_update.STABILITY_LITERALS, |
360 default=None, | 375 default=None, |
361 help='Required: Stability for this bundle; one of. ' | 376 help='Required: Stability for this bundle; one of. ' |
(...skipping 23 matching lines...) Expand all Loading... |
385 | 400 |
386 manifest_file = UpdateSDKManifestFile(options) | 401 manifest_file = UpdateSDKManifestFile(options) |
387 manifest_file.HandleBundles() | 402 manifest_file.HandleBundles() |
388 manifest_file.UpdateWithOptions() | 403 manifest_file.UpdateWithOptions() |
389 | 404 |
390 return 0 | 405 return 0 |
391 | 406 |
392 | 407 |
393 if __name__ == '__main__': | 408 if __name__ == '__main__': |
394 sys.exit(main(sys.argv[1:])) | 409 sys.exit(main(sys.argv[1:])) |
OLD | NEW |