Merge "Use zip2zip to copy zipfiles" am: a59e5b7a29

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

Change-Id: Ib8786a7e70b292f43de26e6d6ffa35bab22dbc07
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2023-02-16 23:14:14 +00:00
committed by Automerger Merge Worker

View File

@@ -302,6 +302,8 @@ def RunAndCheckOutput(args, verbose=None, **kwargs):
Raises: Raises:
ExternalError: On non-zero exit from the command. ExternalError: On non-zero exit from the command.
""" """
if verbose is None:
verbose = OPTIONS.verbose
proc = Run(args, verbose=verbose, **kwargs) proc = Run(args, verbose=verbose, **kwargs)
output, _ = proc.communicate() output, _ = proc.communicate()
if output is None: if output is None:
@@ -2893,13 +2895,12 @@ def ZipDelete(zip_filename, entries, force=False):
fd, new_zipfile = tempfile.mkstemp(dir=os.path.dirname(zip_filename)) fd, new_zipfile = tempfile.mkstemp(dir=os.path.dirname(zip_filename))
os.close(fd) os.close(fd)
cmd = ["zip2zip", "-i", zip_filename, "-o", new_zipfile]
for entry in entries:
cmd.append("-x")
cmd.append(entry)
RunAndCheckOutput(cmd)
with zipfile.ZipFile(new_zipfile, 'w') as zout:
for item in zin.infolist():
if item.filename in entries:
continue
buffer = zin.read(item.filename)
zout.writestr(item, buffer)
os.replace(new_zipfile, zip_filename) os.replace(new_zipfile, zip_filename)