OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import posixpath | 8 import posixpath |
9 import re | 9 import re |
10 import tempfile | 10 import tempfile |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 md5sum_script += ';'.join('$a %s' % p for p in paths) | 88 md5sum_script += ';'.join('$a %s' % p for p in paths) |
89 # Don't fail the script if the last md5sum fails (due to file not found) | 89 # Don't fail the script if the last md5sum fails (due to file not found) |
90 # Note: ":" is equivalent to "true". | 90 # Note: ":" is equivalent to "true". |
91 md5sum_script += ';:' | 91 md5sum_script += ';:' |
92 try: | 92 try: |
93 out = device.RunShellCommand(md5sum_script, check_return=True) | 93 out = device.RunShellCommand(md5sum_script, check_return=True) |
94 except device_errors.AdbShellCommandFailedError as e: | 94 except device_errors.AdbShellCommandFailedError as e: |
95 # Push the binary only if it is found to not exist | 95 # Push the binary only if it is found to not exist |
96 # (faster than checking up-front). | 96 # (faster than checking up-front). |
97 if e.status == 2: | 97 if e.status == 2: |
| 98 # If files were previously pushed as root (adbd running as root), trying |
| 99 # to re-push as non-root causes the push command to report success, but |
| 100 # actually fail. So, wipe the directory first. |
| 101 device.RunShellCommand(['rm', '-rf', MD5SUM_DEVICE_LIB_PATH], |
| 102 as_root=True, check_return=True) |
98 device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH) | 103 device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH) |
99 out = device.RunShellCommand(md5sum_script, check_return=True) | 104 out = device.RunShellCommand(md5sum_script, check_return=True) |
100 else: | 105 else: |
101 raise | 106 raise |
102 | 107 |
103 return _ParseMd5SumOutput(out) | 108 return _ParseMd5SumOutput(out) |
104 | 109 |
105 | 110 |
106 def _ParseMd5SumOutput(out): | 111 def _ParseMd5SumOutput(out): |
107 hash_and_path = (l.split(None, 1) for l in out | 112 hash_and_path = (l.split(None, 1) for l in out |
108 if l and _STARTS_WITH_CHECKSUM_RE.match(l)) | 113 if l and _STARTS_WITH_CHECKSUM_RE.match(l)) |
109 return dict((p, h) for h, p in hash_and_path) | 114 return dict((p, h) for h, p in hash_and_path) |
110 | 115 |
OLD | NEW |