A/B update: Replace the zip FileHeader mechanism for update package

When the update package gets larger than 2 GiB, payload.bin offset
mentioned in metadata file for ota-streaming-property-files gets
shifted (CrAU of payload.bin) because ZipInfo FileHeader() returns
incorrect value. To solve the issue, offset is re-calculated from
fixed bytes of central directory file header, filename length and
extra length.

This patch is to sync with update_device.py script.

Test: manually create an A/B update package and run it using
      update_device.py
Bug: 111198589

Change-Id: I9bf5a5ca24938cad3206d04af529f70d45e992c0
This commit is contained in:
Shashikant Baviskar 2018-04-12 12:11:22 +09:00 committed by Satoshi Futenma
parent da9f2d8fd4
commit 338856f92b

View file

@ -1096,7 +1096,9 @@ class PropertyFiles(object):
def ComputeEntryOffsetSize(name): def ComputeEntryOffsetSize(name):
"""Computes the zip entry offset and size.""" """Computes the zip entry offset and size."""
info = zip_file.getinfo(name) info = zip_file.getinfo(name)
offset = info.header_offset + len(info.FileHeader()) offset = info.header_offset
offset += zipfile.sizeFileHeader
offset += len(info.extra) + len(info.filename)
size = info.file_size size = info.file_size
return '%s:%d:%d' % (os.path.basename(name), offset, size) return '%s:%d:%d' % (os.path.basename(name), offset, size)
@ -1220,7 +1222,9 @@ class AbOtaPropertyFiles(StreamingPropertyFiles):
payload, till the end of 'medatada_signature_message'. payload, till the end of 'medatada_signature_message'.
""" """
payload_info = input_zip.getinfo('payload.bin') payload_info = input_zip.getinfo('payload.bin')
payload_offset = payload_info.header_offset + len(payload_info.FileHeader()) payload_offset = payload_info.header_offset
payload_offset += zipfile.sizeFileHeader
payload_offset += len(payload_info.extra) + len(payload_info.filename)
payload_size = payload_info.file_size payload_size = payload_info.file_size
with input_zip.open('payload.bin', 'r') as payload_fp: with input_zip.open('payload.bin', 'r') as payload_fp: