Merge "Searches for debugfs_static in search path"

This commit is contained in:
Kelvin Zhang 2020-08-24 17:13:06 +00:00 committed by Gerrit Code Review
commit d073e3c87b
1 changed files with 11 additions and 4 deletions

View File

@ -51,6 +51,8 @@ class ApexApkSigner(object):
self.apex_path = apex_path
self.key_passwords = key_passwords
self.codename_to_api_level_map = codename_to_api_level_map
self.debugfs_path = os.path.join(
OPTIONS.search_path, "bin", "debugfs_static")
def ProcessApexFile(self, apk_keys, payload_key, signing_args=None):
"""Scans and signs the apk files and repack the apex
@ -61,14 +63,13 @@ class ApexApkSigner(object):
Returns:
The repacked apex file containing the signed apk files.
"""
debugfs_path = os.path.join(OPTIONS.search_path, "bin", "debugfs_static")
if not os.path.exists(debugfs_path):
if not os.path.exists(self.debugfs_path):
raise ApexSigningError(
"Couldn't find location of debugfs_static: " +
"Path {} does not exist. ".format(debugfs_path) +
"Make sure bin/debugfs_static can be found in -p <path>")
list_cmd = ['deapexer', '--debugfs_path',
debugfs_path, 'list', self.apex_path]
self.debugfs_path, 'list', self.apex_path]
entries_names = common.RunAndCheckOutput(list_cmd).split()
apk_entries = [name for name in entries_names if name.endswith('.apk')]
@ -98,8 +99,14 @@ class ApexApkSigner(object):
def ExtractApexPayloadAndSignApks(self, apk_entries, apk_keys):
"""Extracts the payload image and signs the containing apk files."""
if not os.path.exists(self.debugfs_path):
raise ApexSigningError(
"Couldn't find location of debugfs_static: " +
"Path {} does not exist. ".format(debugfs_path) +
"Make sure bin/debugfs_static can be found in -p <path>")
payload_dir = common.MakeTempDir()
extract_cmd = ['deapexer', 'extract', self.apex_path, payload_dir]
extract_cmd = ['deapexer', '--debugfs_path',
self.debugfs_path, 'extract', self.apex_path, payload_dir]
common.RunAndCheckOutput(extract_cmd)
has_signed_apk = False