use BlockDifference to do the patching for shamu radio image
A plain bsdiff often performs poorly on radio images because they
contain large regions of all-zero blocks, which is a bad case for
bsdiff's suffix sort.
Change to using the new block image stuff, which pulls these blocks
out and handles them separately.
Change-Id: Id9b57fb97f9d3de53277507e0dc3ae622b9b43ac
diff --git a/releasetools.py b/releasetools.py
index 11470d4..d6c893e 100644
--- a/releasetools.py
+++ b/releasetools.py
@@ -211,23 +211,11 @@
tf = target_modem_image
sf = source_modem_image
- patchfile_name = "radio.modem.img.p"
+ b = common.BlockDifference("modem", common.DataImage(tf.data),
+ common.DataImage(sf.data))
- diff = common.Difference(tf, sf, diff_program="bsdiff")
- common.ComputeDifferences([diff])
- _, _, d = diff.GetPatch()
- if d is None or len(d) > tf.size * common.OPTIONS.patch_threshold:
- # computing difference failed, or difference is nearly as
- # big as the target: simply send the target.
- WritePartitionImage(info, tf, "radio")
- else:
- common.ZipWriteStr(info.output_zip, patchfile_name, d)
- info.script.Print("Patching modem image...")
- radio_type, radio_device = common.GetTypeAndDevice(
- "/modem", info.info_dict)
- info.script.ApplyPatch("%s:%s:%d:%s:%d:%s" % (radio_type, radio_device,
- sf.size, sf.sha1, tf.size, tf.sha1),
- "-", tf.size, tf.sha1, sf.sha1, patchfile_name)
+ b.WriteScript(info.script, info.output_zip)
+
def WriteRadio(info, radio_img):
info.script.Print("Writing radio...")