OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
8 | 8 |
9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 shutil.rmtree(path, ignore_errors=True) | 196 shutil.rmtree(path, ignore_errors=True) |
197 else: | 197 else: |
198 # shutil.rmtree() doesn't delete read-only files on Windows. | 198 # shutil.rmtree() doesn't delete read-only files on Windows. |
199 subprocess.check_call('rmdir /s/q "%s"' % path, shell=True) | 199 subprocess.check_call('rmdir /s/q "%s"' % path, shell=True) |
200 | 200 |
201 | 201 |
202 def DoTreeMirror(target_dir, tree_sha1): | 202 def DoTreeMirror(target_dir, tree_sha1): |
203 """In order to save temporary space on bots that do not have enough space to | 203 """In order to save temporary space on bots that do not have enough space to |
204 download ISOs, unpack them, and copy to the target location, the whole tree | 204 download ISOs, unpack them, and copy to the target location, the whole tree |
205 is uploaded as a zip to internal storage, and then mirrored here.""" | 205 is uploaded as a zip to internal storage, and then mirrored here.""" |
206 temp_dir, local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') | 206 #temp_dir, local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') |
| 207 local_zip = tree_sha1 + '.zip' |
207 sys.stdout.write('Extracting %s...\n' % local_zip) | 208 sys.stdout.write('Extracting %s...\n' % local_zip) |
208 sys.stdout.flush() | 209 sys.stdout.flush() |
209 with zipfile.ZipFile(local_zip, 'r', zipfile.ZIP_DEFLATED, True) as zf: | 210 with zipfile.ZipFile(local_zip, 'r', zipfile.ZIP_DEFLATED, True) as zf: |
210 zf.extractall(target_dir) | 211 zf.extractall(target_dir) |
211 if temp_dir: | 212 #if temp_dir: |
212 RmDir(temp_dir) | 213 #RmDir(temp_dir) |
213 | 214 |
214 | 215 |
215 def main(): | 216 def main(): |
216 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 217 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
217 parser.add_option('--output-json', metavar='FILE', | 218 parser.add_option('--output-json', metavar='FILE', |
218 help='write information about toolchain to FILE') | 219 help='write information about toolchain to FILE') |
219 parser.add_option('--force', action='store_true', | 220 parser.add_option('--force', action='store_true', |
220 help='force script to run on non-Windows hosts') | 221 help='force script to run on non-Windows hosts') |
221 options, args = parser.parse_args() | 222 options, args = parser.parse_args() |
222 | 223 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 325 |
325 if options.output_json: | 326 if options.output_json: |
326 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 327 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
327 options.output_json) | 328 options.output_json) |
328 | 329 |
329 return 0 | 330 return 0 |
330 | 331 |
331 | 332 |
332 if __name__ == '__main__': | 333 if __name__ == '__main__': |
333 sys.exit(main()) | 334 sys.exit(main()) |
OLD | NEW |