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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 sys.stdout.write('No --file_hash arguments given: nothing to update\n') | 156 sys.stdout.write('No --file_hash arguments given: nothing to update\n') |
157 | 157 |
158 new_deps = [] | 158 new_deps = [] |
159 for arch, expected_hash in options.file_hashes: | 159 for arch, expected_hash in options.file_hashes: |
160 url = '%s/r%s/irt_%s.nexe' % (options.base_url, | 160 url = '%s/r%s/irt_%s.nexe' % (options.base_url, |
161 options.nacl_revision, | 161 options.nacl_revision, |
162 arch) | 162 arch) |
163 dest_dir = os.path.join(nacl_dir, 'irt_binaries') | 163 dest_dir = os.path.join(nacl_dir, 'irt_binaries') |
164 if not os.path.exists(dest_dir): | 164 if not os.path.exists(dest_dir): |
165 os.makedirs(dest_dir) | 165 os.makedirs(dest_dir) |
166 dest_path = os.path.join(dest_dir, 'irt_%s.nexe' % arch) | 166 dest_path = os.path.join(dest_dir, 'nacl_irt_%s.nexe' % arch) |
167 DownloadFileWithRetry(dest_path, url) | 167 DownloadFileWithRetry(dest_path, url) |
168 downloaded_hash = HashFile(dest_path) | 168 downloaded_hash = HashFile(dest_path) |
169 if downloaded_hash != expected_hash: | 169 if downloaded_hash != expected_hash: |
170 sys.stdout.write( | 170 sys.stdout.write( |
171 'Hash mismatch: the file downloaded from URL %r had hash %r, ' | 171 'Hash mismatch: the file downloaded from URL %r had hash %r, ' |
172 'but we expected %r\n' % (url, downloaded_hash, expected_hash)) | 172 'but we expected %r\n' % (url, downloaded_hash, expected_hash)) |
173 new_deps.append(' "nacl_irt_hash_%s": "%s",\n' | 173 new_deps.append(' "nacl_irt_hash_%s": "%s",\n' |
174 % (arch, downloaded_hash)) | 174 % (arch, downloaded_hash)) |
175 | 175 |
176 if len(new_deps) > 0: | 176 if len(new_deps) > 0: |
177 sys.stdout.write('\nIf you have changed nacl_revision, the DEPS file ' | 177 sys.stdout.write('\nIf you have changed nacl_revision, the DEPS file ' |
178 'probably needs to be updated with the following:\n%s\n' | 178 'probably needs to be updated with the following:\n%s\n' |
179 % ''.join(new_deps)) | 179 % ''.join(new_deps)) |
180 sys.exit(1) | 180 sys.exit(1) |
181 | 181 |
182 | 182 |
183 if __name__ == '__main__': | 183 if __name__ == '__main__': |
184 Main() | 184 Main() |
OLD | NEW |