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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 | 104 |
105 matches = len(file_list) == len(timestamps_data['files']) | 105 matches = len(file_list) == len(timestamps_data['files']) |
106 if matches: | 106 if matches: |
107 for disk, cached in zip(file_list, timestamps_data['files']): | 107 for disk, cached in zip(file_list, timestamps_data['files']): |
108 if disk != cached[0] or os.stat(disk).st_mtime != cached[1]: | 108 if disk != cached[0] or os.stat(disk).st_mtime != cached[1]: |
109 matches = False | 109 matches = False |
110 break | 110 break |
111 if matches: | 111 if matches: |
112 return timestamps_data['sha1'] | 112 return timestamps_data['sha1'] |
113 | 113 |
114 # Make long hangs when updating the toolchain less mysterious. | |
115 print 'Calculating hash of toolchain in %s. Please wait...' % root | |
scottmg
2016/02/02 22:55:13
This will probably need a stdout.flush() or you wo
brucedawson
2016/02/03 00:19:49
Done.
| |
114 digest = hashlib.sha1() | 116 digest = hashlib.sha1() |
115 for path in file_list: | 117 for path in file_list: |
116 digest.update(str(path).replace('/', '\\')) | 118 digest.update(str(path).replace('/', '\\')) |
117 with open(path, 'rb') as f: | 119 with open(path, 'rb') as f: |
118 digest.update(f.read()) | 120 digest.update(f.read()) |
119 return digest.hexdigest() | 121 return digest.hexdigest() |
120 | 122 |
121 | 123 |
122 def SaveTimestampsAndHash(root, sha1): | 124 def SaveTimestampsAndHash(root, sha1): |
123 """Saves timestamps and the final hash to be able to early-out more quickly | 125 """Saves timestamps and the final hash to be able to early-out more quickly |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 288 |
287 installer = os.path.join(abs_target_dir, "installers", installer_name) | 289 installer = os.path.join(abs_target_dir, "installers", installer_name) |
288 command = r'wusa.exe /quiet "%s"' % installer | 290 command = r'wusa.exe /quiet "%s"' % installer |
289 print 'Running %s' % command | 291 print 'Running %s' % command |
290 | 292 |
291 try: | 293 try: |
292 subprocess.check_call(command) | 294 subprocess.check_call(command) |
293 # Trap OSError instead of WindowsError so pylint will succeed on Linux. | 295 # Trap OSError instead of WindowsError so pylint will succeed on Linux. |
294 except OSError as e: | 296 except OSError as e: |
295 if e.winerror == 740: # The requested operation requires elevation | 297 if e.winerror == 740: # The requested operation requires elevation |
296 print | 298 print 'Elevation required. You can manually install this update:' |
297 print '-'*80 | |
298 print | |
299 print 'Elevation required. You must manually install this update:' | |
300 print ' %s' % installer | 299 print ' %s' % installer |
301 print | 300 return |
302 print '-'*80 | |
303 print | |
304 raise Exception('Elevation required. You must manually install %s' % | |
305 installer) | |
306 raise e | 301 raise e |
307 | 302 |
308 | 303 |
309 def main(): | 304 def main(): |
310 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 305 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
311 parser.add_option('--output-json', metavar='FILE', | 306 parser.add_option('--output-json', metavar='FILE', |
312 help='write information about toolchain to FILE') | 307 help='write information about toolchain to FILE') |
313 parser.add_option('--force', action='store_true', | 308 parser.add_option('--force', action='store_true', |
314 help='force script to run on non-Windows hosts') | 309 help='force script to run on non-Windows hosts') |
315 options, args = parser.parse_args() | 310 options, args = parser.parse_args() |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 options.output_json) | 421 options.output_json) |
427 | 422 |
428 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 423 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
429 InstallUniversalCRTIfNeeded(abs_target_dir) | 424 InstallUniversalCRTIfNeeded(abs_target_dir) |
430 | 425 |
431 return 0 | 426 return 0 |
432 | 427 |
433 | 428 |
434 if __name__ == '__main__': | 429 if __name__ == '__main__': |
435 sys.exit(main()) | 430 sys.exit(main()) |
OLD | NEW |