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 '''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 | 8 |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import re | 11 import re |
12 import string | 12 import string |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 import urllib2 | 15 import urllib2 |
16 | 16 |
17 # Create the various paths of interest | 17 # Create the various paths of interest |
18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
19 SDK_SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) | 19 SDK_SRC_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) |
20 SRC_DIR = os.path.dirname(os.path.dirname(SDK_SRC_DIR)) | 20 SRC_DIR = os.path.dirname(os.path.dirname(SDK_SRC_DIR)) |
21 NACL_DIR = os.path.join(SRC_DIR, 'native_client') | 21 NACL_DIR = os.path.join(SRC_DIR, 'native_client') |
22 | 22 |
23 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 23 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
24 sys.path.append(os.path.join(NACL_DIR, 'build')) | 24 sys.path.append(os.path.join(NACL_DIR, 'build')) |
25 | 25 |
26 import sdk_update | 26 import sdk_update |
27 | 27 |
28 HELP='''"Usage: %prog [-b bundle] [options]" | 28 HELP = '''"Usage: %prog [-b bundle] [options]" |
29 | 29 |
30 Actions for particular bundles: | 30 Actions for particular bundles: |
31 sdk_tools: Upload the most recently built nacl_sdk.zip and sdk_tools.tgz | 31 sdk_tools: Upload the most recently built nacl_sdk.zip and sdk_tools.tgz |
32 files to the server and update the manifest file | 32 files to the server and update the manifest file |
33 pepper_??: Download the latest pepper builds off the appropriate branch, | 33 pepper_??: Download the latest pepper builds off the appropriate branch, |
34 upload these files to the appropriate location on the server, and | 34 upload these files to the appropriate location on the server, and |
35 update the manifest file. | 35 update the manifest file. |
36 <others>: Only update manifest file -- you'll need to upload the file yourself | 36 <others>: Only update manifest file -- you'll need to upload the file yourself |
37 ''' | 37 ''' |
38 | 38 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ''' Update the bundle per content of the options. | 77 ''' Update the bundle per content of the options. |
78 | 78 |
79 Args: | 79 Args: |
80 options: options data. Attributes that are used are also deleted from | 80 options: options data. Attributes that are used are also deleted from |
81 options.''' | 81 options.''' |
82 # Check, set and consume individual bundle options. | 82 # Check, set and consume individual bundle options. |
83 for option_key, attribute_key in OPTION_KEY_MAP.iteritems(): | 83 for option_key, attribute_key in OPTION_KEY_MAP.iteritems(): |
84 option_val = getattr(options, option_key, None) | 84 option_val = getattr(options, option_key, None) |
85 if option_val is not None: | 85 if option_val is not None: |
86 bundle[attribute_key] = option_val | 86 bundle[attribute_key] = option_val |
87 delattr(options, option_key); | 87 delattr(options, option_key) |
88 # Validate what we have so far; we may just avoid going through a lengthy | 88 # Validate what we have so far; we may just avoid going through a lengthy |
89 # download, just to realize that some other trivial stuff is missing. | 89 # download, just to realize that some other trivial stuff is missing. |
90 bundle.Validate() | 90 bundle.Validate() |
91 # Check and consume archive-url options. | 91 # Check and consume archive-url options. |
92 for option_key, host_os in OPTION_KEY_TO_PLATFORM_MAP.iteritems(): | 92 for option_key, host_os in OPTION_KEY_TO_PLATFORM_MAP.iteritems(): |
93 platform_url = getattr(options, option_key, None) | 93 platform_url = getattr(options, option_key, None) |
94 if platform_url is not None: | 94 if platform_url is not None: |
95 bundle.UpdateArchive(host_os, platform_url) | 95 bundle.UpdateArchive(host_os, platform_url) |
96 delattr(options, option_key); | 96 delattr(options, option_key) |
97 | 97 |
98 | 98 |
99 class UpdateSDKManifest(sdk_update.SDKManifest): | 99 class UpdateSDKManifest(sdk_update.SDKManifest): |
100 '''Adds functions to SDKManifest that are only used in update_manifest''' | 100 '''Adds functions to SDKManifest that are only used in update_manifest''' |
101 | 101 |
102 def _ValidateBundleName(self, name): | 102 def _ValidateBundleName(self, name): |
103 ''' Verify that name is a valid bundle. | 103 ''' Verify that name is a valid bundle. |
104 | 104 |
105 Args: | 105 Args: |
106 name: the proposed name for the bundle. | 106 name: the proposed name for the bundle. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Args: | 147 Args: |
148 options: the object containing the remaining unused options attributes. | 148 options: the object containing the remaining unused options attributes. |
149 bundle_name: The name of the bundle, or None if it's missing.''' | 149 bundle_name: The name of the bundle, or None if it's missing.''' |
150 # Any option left in the list should have value = None | 150 # Any option left in the list should have value = None |
151 for key, val in options.__dict__.items(): | 151 for key, val in options.__dict__.items(): |
152 if val != None and key not in IGNORE_OPTIONS: | 152 if val != None and key not in IGNORE_OPTIONS: |
153 if bundle_name: | 153 if bundle_name: |
154 raise Error('Unused option "%s" for bundle "%s"' % (key, bundle_name)) | 154 raise Error('Unused option "%s" for bundle "%s"' % (key, bundle_name)) |
155 else: | 155 else: |
156 raise Error('No bundle name specified') | 156 raise Error('No bundle name specified') |
157 return True; | 157 return True |
158 | 158 |
159 def UpdateManifest(self, options): | 159 def UpdateManifest(self, options): |
160 ''' Update the manifest object with values from the command-line options | 160 ''' Update the manifest object with values from the command-line options |
161 | 161 |
162 Args: | 162 Args: |
163 options: options object containing attribute for the command-line options. | 163 options: options object containing attribute for the command-line options. |
164 Note that all the non-trivial options are consumed. | 164 Note that all the non-trivial options are consumed. |
165 ''' | 165 ''' |
166 # Go over all the options and update the manifest data accordingly. | 166 # Go over all the options and update the manifest data accordingly. |
167 # Valid options are consumed as they are used. This gives us a way to | 167 # Valid options are consumed as they are used. This gives us a way to |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 try: | 454 try: |
455 COMMANDS.get(args[0], CommandUnknown)(options, args, manifest_file) | 455 COMMANDS.get(args[0], CommandUnknown)(options, args, manifest_file) |
456 except Error as error: | 456 except Error as error: |
457 print "Error: %s" % error | 457 print "Error: %s" % error |
458 return 1 | 458 return 1 |
459 return 0 | 459 return 0 |
460 | 460 |
461 | 461 |
462 if __name__ == '__main__': | 462 if __name__ == '__main__': |
463 sys.exit(main(sys.argv[1:])) | 463 sys.exit(main(sys.argv[1:])) |
OLD | NEW |