releasetools: Make recovery patch use bsdiff exclusively

It seems like switching from minigzip to toybox gzip (bug: 288169261)
makes imgdiff fail in in this way:
* W imgdiff : imgdiff.cpp:1435 Failed to reconstruct target deflate chunk 3 []; treating as normal
* E imgdiff : imgdiff.cpp:1390 Failed to set bonus data

Test: Sign non-AB target files package
Change-Id: I29f1d8f1168347141d80860e8ed02e19b0031447
This commit is contained in:
Gérard Parat 2024-03-26 14:31:21 +01:00 committed by Bartłomiej Rudecki
parent f84254ef1b
commit 7713f520fa
Signed by: przekichane
GPG key ID: 751F23C6F014EF76

View file

@ -3823,34 +3823,15 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
if board_uses_vendorimage:
# In this case, the output sink is rooted at VENDOR
recovery_img_path = "etc/recovery.img"
recovery_resource_dat_path = "VENDOR/etc/recovery-resource.dat"
else:
# In this case the output sink is rooted at SYSTEM
recovery_img_path = "vendor/etc/recovery.img"
recovery_resource_dat_path = "SYSTEM/vendor/etc/recovery-resource.dat"
if full_recovery_image:
output_sink(recovery_img_path, recovery_img.data)
else:
include_recovery_dtbo = info_dict.get("include_recovery_dtbo") == "true"
include_recovery_acpio = info_dict.get("include_recovery_acpio") == "true"
path = os.path.join(input_dir, recovery_resource_dat_path)
# Use bsdiff to handle mismatching entries (Bug: 72731506)
if include_recovery_dtbo or include_recovery_acpio:
diff_program = ["bsdiff"]
bonus_args = ""
assert not os.path.exists(path)
else:
diff_program = ["imgdiff"]
if os.path.exists(path):
diff_program.append("-b")
diff_program.append(path)
bonus_args = "--bonus /vendor/etc/recovery-resource.dat"
else:
bonus_args = ""
d = Difference(recovery_img, boot_img, diff_program=diff_program)
d = Difference(recovery_img, boot_img)
_, _, patch = d.ComputePatch()
output_sink("recovery-from-boot.p", patch)
@ -3888,7 +3869,7 @@ fi
else:
sh = """#!/vendor/bin/sh
if ! applypatch --check %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
applypatch %(bonus_args)s \\
applypatch \\
--patch /vendor/recovery-from-boot.p \\
--source %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s \\
--target %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s && \\
@ -3904,8 +3885,7 @@ fi
'boot_type': boot_type,
'boot_device': boot_device + '$(getprop ro.boot.slot_suffix)',
'recovery_type': recovery_type,
'recovery_device': recovery_device + '$(getprop ro.boot.slot_suffix)',
'bonus_args': bonus_args}
'recovery_device': recovery_device + '$(getprop ro.boot.slot_suffix)'}
# The install script location moved from /system/etc to /system/bin in the L
# release. In the R release it is in VENDOR/bin or SYSTEM/vendor/bin.