Fix the detection for compressed APKs.
We pack _all_ the APK certs info into META/apkcerts.txt at build time,
including the ones that are not installed for the target. When
detecting for compressed APKs, we should only count the ones that are
actually installed.
Bug: 65498015
Test: `check_target_files_signatures.py bullhead-target_files.zip`
Change-Id: I2f32d4667be0efbfd5f9365dde819f009572533d
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 9d58954..34c334e 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -772,6 +772,14 @@
certmap = {}
compressed_extension = None
+ # META/apkcerts.txt contains the info for _all_ the packages known at build
+ # time. Filter out the ones that are not installed.
+ installed_files = set()
+ for name in tf_zip.namelist():
+ basename = os.path.basename(name)
+ if basename:
+ installed_files.add(basename)
+
for line in tf_zip.read("META/apkcerts.txt").split("\n"):
line = line.strip()
if not line:
@@ -796,6 +804,10 @@
else:
raise ValueError("failed to parse line from apkcerts.txt:\n" + line)
if this_compressed_extension:
+ # Only count the installed files.
+ filename = name + '.' + this_compressed_extension
+ if filename not in installed_files:
+ continue
# Make sure that all the values in the compression map have the same
# extension. We don't support multiple compression methods in the same
# system image.