ota: Include full boot images when imgdiff fails
When generating a non-block based incremental, inclue the full boot
image when imgdiff fails to generate a patch. This logic is already
used for block based incrementals.
Change-Id: Idae484ea8c2553a3480961dfa413724e61c52e5f
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 6bce791..65d0308 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -1262,19 +1262,24 @@
so_far += vendor_diff.EmitVerification(script)
if updating_boot:
+ boot_type, boot_device = common.GetTypeAndDevice("/boot", OPTIONS.info_dict)
d = common.Difference(target_boot, source_boot)
_, _, d = d.ComputePatch()
- print "boot target: %d source: %d diff: %d" % (
+ if d is None:
+ include_full_boot = True
+ common.ZipWriteStr(output_zip, "boot.img", target_boot.data)
+ else:
+ include_full_boot = False
+
+ print "boot target: %d source: %d diff: %d" % (
target_boot.size, source_boot.size, len(d))
- common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
+ common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
- boot_type, boot_device = common.GetTypeAndDevice("/boot", OPTIONS.info_dict)
-
- script.PatchCheck("%s:%s:%d:%s:%d:%s" %
- (boot_type, boot_device,
- source_boot.size, source_boot.sha1,
- target_boot.size, target_boot.sha1))
+ script.PatchCheck("%s:%s:%d:%s:%d:%s" %
+ (boot_type, boot_device,
+ source_boot.size, source_boot.sha1,
+ target_boot.size, target_boot.sha1))
so_far += source_boot.size
size = []
@@ -1323,20 +1328,23 @@
if not OPTIONS.two_step:
if updating_boot:
- # Produce the boot image by applying a patch to the current
- # contents of the boot partition, and write it back to the
- # partition.
- script.Print("Patching boot image...")
- script.ApplyPatch("%s:%s:%d:%s:%d:%s"
- % (boot_type, boot_device,
- source_boot.size, source_boot.sha1,
- target_boot.size, target_boot.sha1),
- "-",
- target_boot.size, target_boot.sha1,
- source_boot.sha1, "patch/boot.img.p")
- so_far += target_boot.size
- script.SetProgress(so_far / total_patch_size)
- print "boot image changed; including."
+ if include_full_boot:
+ print "boot image changed; including full."
+ script.Print("Installing boot image...")
+ script.WriteRawImage("/boot", "boot.img")
+ else:
+ # Produce the boot image by applying a patch to the current
+ # contents of the boot partition, and write it back to the
+ # partition.
+ print "boot image changed; including patch."
+ script.Print("Patching boot image...")
+ script.ApplyPatch("%s:%s:%d:%s:%d:%s"
+ % (boot_type, boot_device,
+ source_boot.size, source_boot.sha1,
+ target_boot.size, target_boot.sha1),
+ "-",
+ target_boot.size, target_boot.sha1,
+ source_boot.sha1, "patch/boot.img.p")
else:
print "boot image unchanged; skipping."