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

Commit 8e9b39e0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix signing failure when no entry to convert to store" am: ea586a8d

Original change: https://android-review.googlesource.com/c/platform/build/+/1978755

Change-Id: I1d311e6a5c0e4bf782d20ed4d00c2b138ac9bd49
parents 7fda7d36 ea586a8d
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ import verity_utils
import ota_metadata_pb2
import ota_metadata_pb2


from apex_utils import GetApexInfoFromTargetFiles
from apex_utils import GetApexInfoFromTargetFiles
from common import AddCareMapForAbOta
from common import AddCareMapForAbOta, ZipDelete


if sys.hexversion < 0x02070000:
if sys.hexversion < 0x02070000:
  print("Python 2.7 or newer is required.", file=sys.stderr)
  print("Python 2.7 or newer is required.", file=sys.stderr)
@@ -1034,9 +1034,10 @@ def OptimizeCompressedEntries(zipfile_path):
        if zinfo.compress_size > zinfo.file_size * 0.80 and zinfo.compress_type != zipfile.ZIP_STORED:
        if zinfo.compress_size > zinfo.file_size * 0.80 and zinfo.compress_type != zipfile.ZIP_STORED:
          entries_to_store.append(zinfo)
          entries_to_store.append(zinfo)
          zfp.extract(zinfo, tmpdir)
          zfp.extract(zinfo, tmpdir)
    if len(entries_to_store) == 0:
      return
    # Remove these entries, then re-add them as ZIP_STORED
    # Remove these entries, then re-add them as ZIP_STORED
    common.RunAndCheckOutput(
    ZipDelete(zipfile_path, [entry.filename for entry in entries_to_store])
        ["zip", "-d", zipfile_path] + [entry.filename for entry in entries_to_store])
    with zipfile.ZipFile(zipfile_path, "a", allowZip64=True) as zfp:
    with zipfile.ZipFile(zipfile_path, "a", allowZip64=True) as zfp:
      for entry in entries_to_store:
      for entry in entries_to_store:
        zfp.write(os.path.join(tmpdir, entry.filename), entry.filename, compress_type=zipfile.ZIP_STORED)
        zfp.write(os.path.join(tmpdir, entry.filename), entry.filename, compress_type=zipfile.ZIP_STORED)
+3 −0
Original line number Original line Diff line number Diff line
@@ -2818,6 +2818,9 @@ def ZipDelete(zip_filename, entries):
  """
  """
  if isinstance(entries, str):
  if isinstance(entries, str):
    entries = [entries]
    entries = [entries]
  # If list is empty, nothing to do
  if not entries:
    return
  cmd = ["zip", "-d", zip_filename] + entries
  cmd = ["zip", "-d", zip_filename] + entries
  RunAndCheckOutput(cmd)
  RunAndCheckOutput(cmd)


+0 −3
Original line number Original line Diff line number Diff line
@@ -1521,8 +1521,5 @@ def main(argv):
if __name__ == '__main__':
if __name__ == '__main__':
  try:
  try:
    main(sys.argv[1:])
    main(sys.argv[1:])
  except common.ExternalError as e:
    print("\n   ERROR: %s\n" % (e,))
    raise
  finally:
  finally:
    common.Cleanup()
    common.Cleanup()