releasetools: Add common.ZipDelete().
We have been shelling out to 'zip -d' to delete existing ZIP entries in
add_img_to_target_files.py. This CL moves the function into common.py,
and calls that for the similar work in ota_from_target_files.py. This CL
also adds unittests for the newly added function.
Test: `m dist`
Test: python -m unittest test_common
Test: ota_from_target_files.py generates identical packages w/ and w/o
the CL (so we know the streaming property computation is intact).
Test: Run 'add_img_to_target_files.py -a' that triggers a call to
ReplaceUpdatedFiles().
Change-Id: Icaa6c3ea3ee2166023f78fa79275295f837ea842
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index e295760..8b55a45 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -467,16 +467,12 @@
def ReplaceUpdatedFiles(zip_filename, files_list):
- """Update all the zip entries listed in the files_list.
+ """Updates all the ZIP entries listed in files_list.
For now the list includes META/care_map.txt, and the related files under
SYSTEM/ after rebuilding recovery.
"""
-
- cmd = ["zip", "-d", zip_filename] + files_list
- p = common.Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- p.communicate()
-
+ common.ZipDelete(zip_filename, files_list)
output_zip = zipfile.ZipFile(zip_filename, "a",
compression=zipfile.ZIP_DEFLATED,
allowZip64=True)