releasetools: Disable using imgdiff for squashfs.

We use imgdiff to handle files in zip format (e.g. jar/zip/apk) for
higher compression ratio.

For system/vendor in squashfs, a) all files are compressed in LZ4
format; b) we use 4096-byte block size in their sparse images, but the
files in squashfs may not be laid out as 4K-aligned. So the blocks for
a given file as listed in block map may not form a valid zip file, which
may fail the patch generation with imgdiff.

Disable using imgdiff for squashfs images, and use bsdiff instead.

Bug: 22322817
Change-Id: Ie76aa4cece5c9d38cb1d1a34c505a4a8f37512d3
This commit is contained in:
Tao Bao
2016-06-11 12:19:23 -07:00
parent d06f07eef4
commit 293fd135c7
3 changed files with 19 additions and 6 deletions

View File

@@ -261,7 +261,8 @@ class HeapItem(object):
# original image.
class BlockImageDiff(object):
def __init__(self, tgt, src=None, threads=None, version=4):
def __init__(self, tgt, src=None, threads=None, version=4,
disable_imgdiff=False):
if threads is None:
threads = multiprocessing.cpu_count() // 2
if threads == 0:
@@ -274,6 +275,7 @@ class BlockImageDiff(object):
self._max_stashed_size = 0
self.touched_src_ranges = RangeSet()
self.touched_src_sha1 = None
self.disable_imgdiff = disable_imgdiff
assert version in (1, 2, 3, 4)
@@ -714,6 +716,7 @@ class BlockImageDiff(object):
# produces significantly smaller patches than bsdiff).
# This is permissible if:
#
# - imgdiff is not disabled, and
# - the source and target files are monotonic (ie, the
# data is stored with blocks in increasing order), and
# - we haven't removed any blocks from the source set.
@@ -723,7 +726,7 @@ class BlockImageDiff(object):
# zip file (plus possibly extra zeros in the last block),
# which is what imgdiff needs to operate. (imgdiff is
# fine with extra zeros at the end of the file.)
imgdiff = (xf.intact and
imgdiff = (not self.disable_imgdiff and xf.intact and
xf.tgt_name.split(".")[-1].lower()
in ("apk", "jar", "zip"))
xf.style = "imgdiff" if imgdiff else "bsdiff"