OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import hashlib | 6 import hashlib |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import urllib2 | 9 import urllib2 |
10 import sys | 10 import sys |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 break | 112 break |
113 except urllib2.HTTPError, exn: | 113 except urllib2.HTTPError, exn: |
114 if exn.getcode() == 404: | 114 if exn.getcode() == 404: |
115 raise | 115 raise |
116 sys.stdout.write('Download failed with error %r. Retrying...\n' | 116 sys.stdout.write('Download failed with error %r. Retrying...\n' |
117 % str(exn)) | 117 % str(exn)) |
118 sys.stdout.flush() | 118 sys.stdout.flush() |
119 time.sleep(1) | 119 time.sleep(1) |
120 | 120 |
121 | 121 |
122 def EvalDepsFile(path): | |
123 scope = {'Var': lambda name: scope['vars'][name]} | |
124 execfile(path, {}, scope) | |
125 return scope | |
126 | |
127 | |
122 def Main(): | 128 def Main(): |
123 parser = optparse.OptionParser() | 129 parser = optparse.OptionParser() |
124 parser.add_option( | 130 parser.add_option( |
125 '--base_url', dest='base_url', | 131 '--base_url', dest='base_url', |
126 # For a view of this site that includes directory listings, see: | 132 # For a view of this site that includes directory listings, see: |
127 # http://gsdview.appspot.com/nativeclient-archive2/ | 133 # http://gsdview.appspot.com/nativeclient-archive2/ |
128 # (The trailing slash is required.) | 134 # (The trailing slash is required.) |
129 default=('http://commondatastorage.googleapis.com/' | 135 default=('http://commondatastorage.googleapis.com/' |
130 'nativeclient-archive2/irt'), | 136 'nativeclient-archive2/irt'), |
131 help='Base URL from which to download.') | 137 help='Base URL from which to download.') |
132 parser.add_option( | 138 parser.add_option( |
133 '--nacl_revision', dest='nacl_revision', | 139 '--nacl_revision', dest='nacl_revision', |
134 help='Download an IRT binary that was built from this ' | 140 help='Download an IRT binary that was built from this ' |
135 'SVN revision of Native Client.') | 141 'SVN revision of Native Client.') |
136 parser.add_option( | 142 parser.add_option( |
137 '--file_hash', dest='file_hashes', action='append', nargs=2, default=[], | 143 '--file_hash', dest='file_hashes', action='append', nargs=2, default=[], |
138 metavar='ARCH HASH', | 144 metavar='ARCH HASH', |
139 help='ARCH gives the name of the architecture (e.g. "x86_32") for ' | 145 help='ARCH gives the name of the architecture (e.g. "x86_32") for ' |
140 'which to download an IRT binary. ' | 146 'which to download an IRT binary. ' |
141 'HASH gives the expected SHA1 hash of the file.') | 147 'HASH gives the expected SHA1 hash of the file.') |
142 options, args = parser.parse_args() | 148 options, args = parser.parse_args() |
143 if len(args) != 0: | 149 if len(args) != 0: |
144 parser.error('Unexpected arguments: %r' % args) | 150 parser.error('Unexpected arguments: %r' % args) |
145 | 151 |
152 if options.nacl_revision is None and len(options.file_hashes) == 0: | |
153 # The script must have been invoked directly with no arguments, | |
154 # rather than being invoked by gclient. In this case, read the | |
155 # DEPS file ourselves rather than having gclient pass us values | |
156 # from DEPS. | |
157 deps_data = EvalDepsFile(os.path.join('src', 'DEPS')) | |
Paweł Hajdan Jr.
2011/05/09 14:08:48
This is duplicating some gclient code and it's rel
| |
158 options.nacl_revision = deps_data['vars']['nacl_revision'] | |
159 options.file_hashes = [ | |
160 ('x86_32', deps_data['vars']['nacl_irt_hash_x86_32']), | |
161 ('x86_64', deps_data['vars']['nacl_irt_hash_x86_64']), | |
162 ] | |
163 | |
146 nacl_dir = os.path.join('src', 'native_client') | 164 nacl_dir = os.path.join('src', 'native_client') |
147 if not os.path.exists(nacl_dir): | 165 if not os.path.exists(nacl_dir): |
148 # If "native_client" is not present, this might be because the | 166 # If "native_client" is not present, this might be because the |
149 # developer has put '"src/native_client": None' in their | 167 # developer has put '"src/native_client": None' in their |
150 # '.gclient' file, because they don't want to build Chromium with | 168 # '.gclient' file, because they don't want to build Chromium with |
151 # Native Client support. So don't create 'src/native_client', | 169 # Native Client support. So don't create 'src/native_client', |
152 # because that would interfere with checking it out from SVN | 170 # because that would interfere with checking it out from SVN |
153 # later. | 171 # later. |
154 sys.stdout.write( | 172 sys.stdout.write( |
155 'The directory %r does not exist: skipping downloading binaries ' | 173 'The directory %r does not exist: skipping downloading binaries ' |
(...skipping 22 matching lines...) Expand all Loading... | |
178 | 196 |
179 if len(new_deps) > 0: | 197 if len(new_deps) > 0: |
180 sys.stdout.write('\nIf you have changed nacl_revision, the DEPS file ' | 198 sys.stdout.write('\nIf you have changed nacl_revision, the DEPS file ' |
181 'probably needs to be updated with the following:\n%s\n' | 199 'probably needs to be updated with the following:\n%s\n' |
182 % ''.join(new_deps)) | 200 % ''.join(new_deps)) |
183 sys.exit(1) | 201 sys.exit(1) |
184 | 202 |
185 | 203 |
186 if __name__ == '__main__': | 204 if __name__ == '__main__': |
187 Main() | 205 Main() |
OLD | NEW |