platform_bootable_recovery/applypatch
Tianjie Xu 2903cddb58 Improve imgdiff for large zip files
Due to the cache size limit for OTA generation, we used to split large
zip files linearly into pieces and do bsdiff on them. As a result, i) we
lose the advantage of imgdiff; ii) if there's an accidental order change
of some huge files inside the zip, we'll create an insanely large patch.

This patch splits the src&tgt more smartly based on the zip entry_name.
If the entry_name is empty or no matching source is found for a target
chunk, we'll skip adding its source and later do a bsdiff against the
whole split source image (this rarely happens in our use cases except
for the metadata inside a ziparchive).

After the split, the target pieces are continuous and block aligned,
while the sources pieces are mutually exclusive. (Some of the source
blocks may not be used if there's no matching entry_name in the target.)
Then we will generate patches accordingly between each split image
pairs.

Afterwards, if we apply imgpatch to each pair of split source/target
images and add up the patched result, we can get back the original
target image.

For example:
Input: [src_image, tgt_image]
Split: [src-0,tgt-0; src-1,tgt-1, src-2,tgt-2]
Diff:  [  patch-0;     patch-1;    patch-2]

Patch: [(src-0,patch-0)=tgt-0; (src-1,patch-1)=tgt-1;
(src-2,patch-2)=tgt-2;]
Append: [tgt-0 + tgt-1 + tgt-2 = tgt_image]

Peformance:
For the small package in b/34220646, we decrease the patch size of
chrome.apk dramatically from 30M to 400K due to the order change of
two big .so files.

On two versions of angler, I also observe decent patch size decrease.
For chrome.apk, we reduced the size from 5.9M to 3.2M; and for
vevlet.apk from 8.0M to 6.5M.

Bug: 34220646
Test: recovery component test && apply imgdiff & imgpatch on two
chrome.apk
Change-Id: I145d802984fa805efbbac9d01a2e64d82ef9728b
2017-09-05 15:09:58 -07:00
..
include/applypatch Improve imgdiff for large zip files 2017-09-05 15:09:58 -07:00
Android.mk Turn on -Wall for recovery modules 2017-08-28 21:56:33 -07:00
applypatch.cpp applypatch: Let Apply{BSDiff,Image}Patch accept std::function. 2017-03-28 10:14:53 -07:00
applypatch_main.cpp applypatch: Add testcases for applypatch executable. 2016-11-01 14:40:14 -07:00
applypatch_modes.cpp applypatch: Remove the obsolete support for "applypatch -s". 2017-04-25 21:23:12 -07:00
applypatch_modes.h applypatch: Add testcases for applypatch executable. 2016-11-01 14:40:14 -07:00
bspatch.cpp Print SHA1 of the patch if bsdiff fails with data error 2017-05-16 12:39:14 -07:00
freecache.cpp Fix the improper use of LOCAL_WHOLE_STATIC_LIBRARIES. 2016-03-03 14:52:44 -08:00
imgdiff.cpp Improve imgdiff for large zip files 2017-09-05 15:09:58 -07:00
imgdiff_main.cpp Add tests for imgdiff. 2016-12-19 16:53:03 -08:00
imgpatch.cpp Implement a custom deflate sink function for bspatch 2017-05-26 14:05:20 -07:00
libimgpatch.pc applypatch: Add libimgpatch.pc 2016-02-16 11:35:29 -08:00
Makefile Add include/ to the Makefile include path. 2016-03-14 14:25:33 -07:00
NOTICE Add NOTICE file 2012-04-06 13:51:00 -07:00