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
Signed-off-by: RITEFANG <1721985272@qq.com>
This commit is contained in:
Gérard Parat
2024-03-26 14:31:21 +01:00
committed by SkyMinus
parent a12cd56eda
commit 3c32ba6cbf

View File

@@ -3833,11 +3833,9 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
if board_builds_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"
elif not board_uses_vendorimage:
# 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"
else:
logger.warning('Recovery patch generation is disable when prebuilt vendor image is used.')
return None
@@ -3846,24 +3844,7 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
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)
@@ -3901,7 +3882,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 && \\
@@ -3917,8 +3898,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.