Merge "releasetools: Call Cleanup() in check_target_files_signatures.py." am: 903be914bb
am: 5410d8a52a
am: 501b84236f
Change-Id: Ia4dfee212e3ff55fcdd9ce60faddab91c5e195c6
This commit is contained in:
commit
921c81f7c3
|
@ -39,19 +39,18 @@ Usage: check_target_file_signatures [flags] target_files
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
import common
|
||||||
|
|
||||||
if sys.hexversion < 0x02070000:
|
if sys.hexversion < 0x02070000:
|
||||||
print >> sys.stderr, "Python 2.7 or newer is required."
|
print >> sys.stderr, "Python 2.7 or newer is required."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
import common
|
|
||||||
|
|
||||||
# Work around a bug in Python's zipfile module that prevents opening of zipfiles
|
# Work around a bug in Python's zipfile module that prevents opening of zipfiles
|
||||||
# if any entry has an extra field of between 1 and 3 bytes (which is common with
|
# if any entry has an extra field of between 1 and 3 bytes (which is common with
|
||||||
|
@ -244,12 +243,12 @@ class TargetFiles(object):
|
||||||
# This is the list of wildcards of files we extract from |filename|.
|
# This is the list of wildcards of files we extract from |filename|.
|
||||||
apk_extensions = ['*.apk']
|
apk_extensions = ['*.apk']
|
||||||
|
|
||||||
self.certmap, compressed_extension = common.ReadApkCerts(zipfile.ZipFile(filename, "r"))
|
self.certmap, compressed_extension = common.ReadApkCerts(
|
||||||
|
zipfile.ZipFile(filename, "r"))
|
||||||
if compressed_extension:
|
if compressed_extension:
|
||||||
apk_extensions.append("*.apk" + compressed_extension)
|
apk_extensions.append("*.apk" + compressed_extension)
|
||||||
|
|
||||||
d = common.UnzipTemp(filename, apk_extensions)
|
d = common.UnzipTemp(filename, apk_extensions)
|
||||||
try:
|
|
||||||
self.apks = {}
|
self.apks = {}
|
||||||
self.apks_by_basename = {}
|
self.apks_by_basename = {}
|
||||||
for dirpath, _, filenames in os.walk(d):
|
for dirpath, _, filenames in os.walk(d):
|
||||||
|
@ -264,13 +263,12 @@ class TargetFiles(object):
|
||||||
os.path.join(dirpath, uncompressed_fn))
|
os.path.join(dirpath, uncompressed_fn))
|
||||||
|
|
||||||
# Finally, delete the compressed file and use the uncompressed file
|
# Finally, delete the compressed file and use the uncompressed file
|
||||||
# for further processing. Note that the deletion is not strictly required,
|
# for further processing. Note that the deletion is not strictly
|
||||||
# but is done here to ensure that we're not using too much space in
|
# required, but is done here to ensure that we're not using too much
|
||||||
# the temporary directory.
|
# space in the temporary directory.
|
||||||
os.remove(os.path.join(dirpath, fn))
|
os.remove(os.path.join(dirpath, fn))
|
||||||
fn = uncompressed_fn
|
fn = uncompressed_fn
|
||||||
|
|
||||||
|
|
||||||
if fn.endswith(".apk"):
|
if fn.endswith(".apk"):
|
||||||
fullname = os.path.join(dirpath, fn)
|
fullname = os.path.join(dirpath, fn)
|
||||||
displayname = fullname[len(d)+1:]
|
displayname = fullname[len(d)+1:]
|
||||||
|
@ -280,8 +278,6 @@ class TargetFiles(object):
|
||||||
|
|
||||||
self.max_pkg_len = max(self.max_pkg_len, len(apk.package))
|
self.max_pkg_len = max(self.max_pkg_len, len(apk.package))
|
||||||
self.max_fn_len = max(self.max_fn_len, len(apk.filename))
|
self.max_fn_len = max(self.max_fn_len, len(apk.filename))
|
||||||
finally:
|
|
||||||
shutil.rmtree(d)
|
|
||||||
|
|
||||||
def CheckSharedUids(self):
|
def CheckSharedUids(self):
|
||||||
"""Look for any instances where packages signed with different
|
"""Look for any instances where packages signed with different
|
||||||
|
@ -291,7 +287,7 @@ class TargetFiles(object):
|
||||||
if apk.shared_uid:
|
if apk.shared_uid:
|
||||||
apks_by_uid.setdefault(apk.shared_uid, []).append(apk)
|
apks_by_uid.setdefault(apk.shared_uid, []).append(apk)
|
||||||
|
|
||||||
for uid in sorted(apks_by_uid.keys()):
|
for uid in sorted(apks_by_uid):
|
||||||
apks = apks_by_uid[uid]
|
apks = apks_by_uid[uid]
|
||||||
for apk in apks[1:]:
|
for apk in apks[1:]:
|
||||||
if apk.certs != apks[0].certs:
|
if apk.certs != apks[0].certs:
|
||||||
|
@ -466,3 +462,5 @@ if __name__ == '__main__':
|
||||||
print " ERROR: %s" % (e,)
|
print " ERROR: %s" % (e,)
|
||||||
print
|
print
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
finally:
|
||||||
|
common.Cleanup()
|
||||||
|
|
Loading…
Reference in New Issue