Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: build/android/pylib/utils/md5sum.py

Issue 1321503003: Fix md5sum printing a stale checksum for missing files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forgot if I already uploaded... Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/utils/md5sum_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/md5sum.py
diff --git a/build/android/pylib/utils/md5sum.py b/build/android/pylib/utils/md5sum.py
index 2b14f338ee813937146fdd546c8922c8825d2c6c..f3a780ece3d29688ab6a15bcc1211aaeaeae651e 100644
--- a/build/android/pylib/utils/md5sum.py
+++ b/build/android/pylib/utils/md5sum.py
@@ -60,17 +60,21 @@ def CalculateDeviceMd5Sums(paths, device):
# Allow generators
paths = list(paths)
- def push_md5sum():
- md5sum_dist_path = os.path.join(constants.GetOutDirectory(), 'md5sum_dist')
- if not os.path.exists(md5sum_dist_path):
- raise IOError('File not built: %s' % md5sum_dist_path)
- device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH)
+ md5sum_dist_path = os.path.join(constants.GetOutDirectory(), 'md5sum_dist')
+ md5sum_dist_bin_path = os.path.join(md5sum_dist_path, 'md5sum_bin')
+
+ if not os.path.exists(md5sum_dist_path):
+ raise IOError('File not built: %s' % md5sum_dist_path)
+ md5sum_file_size = os.path.getsize(md5sum_dist_bin_path)
# For better performance, make the script as small as possible to try and
# avoid needing to write to an intermediary file (which RunShellCommand will
# do if necessary).
md5sum_script = 'a=%s;' % MD5SUM_DEVICE_BIN_PATH
- md5sum_script += 'test -e $a||exit 2;'
+ # Check if the binary is missing or has changed (using its file size as an
+ # indicator), and trigger a (re-)push via the exit code.
+ md5sum_script += '! [[ $(ls -l $a) = *%d* ]]&&exit 2;' % md5sum_file_size
+ # Make sure it can find libbase.so
md5sum_script += 'export LD_LIBRARY_PATH=%s;' % MD5SUM_DEVICE_LIB_PATH
if len(paths) > 1:
prefix = posixpath.commonprefix(paths)
@@ -88,7 +92,7 @@ def CalculateDeviceMd5Sums(paths, device):
# Push the binary only if it is found to not exist
# (faster than checking up-front).
if e.status == 2:
- push_md5sum()
+ device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH)
out = device.RunShellCommand(md5sum_script, check_return=True)
else:
raise
« no previous file with comments | « no previous file | build/android/pylib/utils/md5sum_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698