Add host side simulation python script
This enables host side simulation of partial updates with the original
complete target file
Bug: 171519321
Test: run this script with a partial update
python3 simulate_ota.py --source
~/aosp/aosp_cf_x86_phone-target_files-6949164.zip --target
~/aosp/aosp_cf_x86_phone-target_files-6937553.zip
~/aosp/cf_x86_downgrade.zip
Change-Id: Iec52d8ac585b499d50bdb0c89d203ea353f2e94f
diff --git a/scripts/update_payload/payload.py b/scripts/update_payload/payload.py
index fe3a450..6b28046 100644
--- a/scripts/update_payload/payload.py
+++ b/scripts/update_payload/payload.py
@@ -124,8 +124,11 @@
if zipfile.is_zipfile(payload_file):
with zipfile.ZipFile(payload_file) as zfp:
with zfp.open("payload.bin") as payload_fp:
- payload_file = io.BytesIO(payload_fp.read())
- self.payload_file = payload_file
+ self.payload_file = io.BytesIO(payload_fp.read())
+ elif isinstance(payload_file, str):
+ self.payload_file = open(payload_file, "rb")
+ else:
+ self.payload_file = payload_file
self.payload_file_offset = payload_file_offset
self.manifest_hasher = None
self.is_init = False