Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 338856f9 authored by Shashikant Baviskar's avatar Shashikant Baviskar Committed by Satoshi Futenma
Browse files

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
parent da9f2d8f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1096,7 +1096,9 @@ class PropertyFiles(object):
    def ComputeEntryOffsetSize(name):
      """Computes the zip entry offset and size."""
      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
      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_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

    with input_zip.open('payload.bin', 'r') as payload_fp: