From 15604b84e246514da6c9721266919003f734380b Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 1 Sep 2009 17:53:34 -0700 Subject: [PATCH] use imgdiff -z to diff zipfiles imgdiff now understands the zip file format and can produce smaller patches by doing the patching in uncompressed space. Start taking advantage of this for .zip, .apk, and .jar files. --- tools/releasetools/ota_from_target_files | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index afd31aaa4..fc6a4c66a 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -481,6 +481,15 @@ def GetRecoveryAPIVersion(zip): except KeyError: return 0 + +DIFF_METHOD_BY_EXT = { + ".gz" : "imgdiff", + ".zip" : ["imgdiff", "-z"], + ".jar" : ["imgdiff", "-z"], + ".apk" : ["imgdiff", "-z"], + } + + def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip): source_version = GetRecoveryAPIVersion(source_zip) @@ -526,9 +535,8 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip): verbatim_targets.append((fn, tf.size)) elif tf.sha1 != sf.sha1: # File is different; consider sending as a patch - diff_method = "bsdiff" - if tf.name.endswith(".gz"): - diff_method = "imgdiff" + ext = os.path.splitext(tf.name)[1] + diff_method = DIFF_METHOD_BY_EXT.get(ext, "bsdiff") d = Difference(tf, sf, diff_method) if d is not None: print fn, tf.size, len(d), (float(len(d)) / tf.size)