add EROFS apex support.
Signing code uses deapexer to expand payload image, deapexer currently only supports ext4 payload image expansion using debugfs or debugfs_static. To support EROFS, need to supply deapexer with fsck.erofs native binary for EROFS payload expansion. cherrypick of ag/20154950BUG: b/195515562, b/240288941 Change-Id: Ibf707989f2502bfcf112202a3a6fdb74b6a8dbbc
This commit is contained in:
@@ -63,6 +63,8 @@ class ApexApkSigner(object):
|
|||||||
self.codename_to_api_level_map = codename_to_api_level_map
|
self.codename_to_api_level_map = codename_to_api_level_map
|
||||||
self.debugfs_path = os.path.join(
|
self.debugfs_path = os.path.join(
|
||||||
OPTIONS.search_path, "bin", "debugfs_static")
|
OPTIONS.search_path, "bin", "debugfs_static")
|
||||||
|
self.fsckerofs_path = os.path.join(
|
||||||
|
OPTIONS.search_path, "bin", "fsck.erofs")
|
||||||
self.avbtool = avbtool if avbtool else "avbtool"
|
self.avbtool = avbtool if avbtool else "avbtool"
|
||||||
self.sign_tool = sign_tool
|
self.sign_tool = sign_tool
|
||||||
|
|
||||||
@@ -80,8 +82,13 @@ class ApexApkSigner(object):
|
|||||||
"Couldn't find location of debugfs_static: " +
|
"Couldn't find location of debugfs_static: " +
|
||||||
"Path {} does not exist. ".format(self.debugfs_path) +
|
"Path {} does not exist. ".format(self.debugfs_path) +
|
||||||
"Make sure bin/debugfs_static can be found in -p <path>")
|
"Make sure bin/debugfs_static can be found in -p <path>")
|
||||||
list_cmd = ['deapexer', '--debugfs_path',
|
if not os.path.exists(self.fsckerofs_path):
|
||||||
self.debugfs_path, 'list', self.apex_path]
|
raise ApexSigningError(
|
||||||
|
"Couldn't find location of fsck.erofs: " +
|
||||||
|
"Path {} does not exist. ".format(self.fsckerofs_path) +
|
||||||
|
"Make sure bin/fsck.erofs can be found in -p <path>")
|
||||||
|
list_cmd = ['deapexer', '--debugfs_path', self.debugfs_path,
|
||||||
|
'--fsckerofs_path', self.fsckerofs_path, 'list', self.apex_path]
|
||||||
entries_names = common.RunAndCheckOutput(list_cmd).split()
|
entries_names = common.RunAndCheckOutput(list_cmd).split()
|
||||||
apk_entries = [name for name in entries_names if name.endswith('.apk')]
|
apk_entries = [name for name in entries_names if name.endswith('.apk')]
|
||||||
sepolicy_entries = []
|
sepolicy_entries = []
|
||||||
@@ -120,9 +127,15 @@ class ApexApkSigner(object):
|
|||||||
"Couldn't find location of debugfs_static: " +
|
"Couldn't find location of debugfs_static: " +
|
||||||
"Path {} does not exist. ".format(self.debugfs_path) +
|
"Path {} does not exist. ".format(self.debugfs_path) +
|
||||||
"Make sure bin/debugfs_static can be found in -p <path>")
|
"Make sure bin/debugfs_static can be found in -p <path>")
|
||||||
|
if not os.path.exists(self.fsckerofs_path):
|
||||||
|
raise ApexSigningError(
|
||||||
|
"Couldn't find location of fsck.erofs: " +
|
||||||
|
"Path {} does not exist. ".format(self.fsckerofs_path) +
|
||||||
|
"Make sure bin/fsck.erofs can be found in -p <path>")
|
||||||
payload_dir = common.MakeTempDir()
|
payload_dir = common.MakeTempDir()
|
||||||
extract_cmd = ['deapexer', '--debugfs_path',
|
extract_cmd = ['deapexer', '--debugfs_path', self.debugfs_path,
|
||||||
self.debugfs_path, 'extract', self.apex_path, payload_dir]
|
'--fsckerofs_path', self.fsckerofs_path, 'extract',
|
||||||
|
self.apex_path, payload_dir]
|
||||||
common.RunAndCheckOutput(extract_cmd)
|
common.RunAndCheckOutput(extract_cmd)
|
||||||
assert os.path.exists(self.apex_path)
|
assert os.path.exists(self.apex_path)
|
||||||
|
|
||||||
@@ -457,6 +470,7 @@ def SignCompressedApex(avbtool, apex_file, payload_key, container_key,
|
|||||||
The path to the signed APEX file.
|
The path to the signed APEX file.
|
||||||
"""
|
"""
|
||||||
debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static')
|
debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static')
|
||||||
|
fsckerofs_path = os.path.join(OPTIONS.search_path, 'bin', 'fsck.erofs')
|
||||||
|
|
||||||
# 1. Decompress original_apex inside compressed apex.
|
# 1. Decompress original_apex inside compressed apex.
|
||||||
original_apex_file = common.MakeTempFile(prefix='original-apex-',
|
original_apex_file = common.MakeTempFile(prefix='original-apex-',
|
||||||
@@ -464,6 +478,7 @@ def SignCompressedApex(avbtool, apex_file, payload_key, container_key,
|
|||||||
# Decompression target path should not exist
|
# Decompression target path should not exist
|
||||||
os.remove(original_apex_file)
|
os.remove(original_apex_file)
|
||||||
common.RunAndCheckOutput(['deapexer', '--debugfs_path', debugfs_path,
|
common.RunAndCheckOutput(['deapexer', '--debugfs_path', debugfs_path,
|
||||||
|
'--fsckerofs_path', fsckerofs_path,
|
||||||
'decompress', '--input', apex_file,
|
'decompress', '--input', apex_file,
|
||||||
'--output', original_apex_file])
|
'--output', original_apex_file])
|
||||||
|
|
||||||
@@ -529,7 +544,9 @@ def SignApex(avbtool, apex_data, payload_key, container_key, container_pw,
|
|||||||
output_fp.write(apex_data)
|
output_fp.write(apex_data)
|
||||||
|
|
||||||
debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static')
|
debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static')
|
||||||
|
fsckerofs_path = os.path.join(OPTIONS.search_path, 'bin', 'fsck.erofs')
|
||||||
cmd = ['deapexer', '--debugfs_path', debugfs_path,
|
cmd = ['deapexer', '--debugfs_path', debugfs_path,
|
||||||
|
'--fsckerofs_path', fsckerofs_path,
|
||||||
'info', '--print-type', apex_file]
|
'info', '--print-type', apex_file]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -603,11 +620,17 @@ def GetApexInfoFromTargetFiles(input_file, partition, compressed_only=True):
|
|||||||
debugfs_path = "debugfs"
|
debugfs_path = "debugfs"
|
||||||
if OPTIONS.search_path:
|
if OPTIONS.search_path:
|
||||||
debugfs_path = os.path.join(OPTIONS.search_path, "bin", "debugfs_static")
|
debugfs_path = os.path.join(OPTIONS.search_path, "bin", "debugfs_static")
|
||||||
|
|
||||||
|
fsckerofs_path = "fsck.erofs"
|
||||||
|
if OPTIONS.search_path:
|
||||||
|
fsckerofs_path = os.path.join(OPTIONS.search_path, "bin", "fsck.erofs")
|
||||||
|
|
||||||
deapexer = 'deapexer'
|
deapexer = 'deapexer'
|
||||||
if OPTIONS.search_path:
|
if OPTIONS.search_path:
|
||||||
deapexer_path = os.path.join(OPTIONS.search_path, "bin", "deapexer")
|
deapexer_path = os.path.join(OPTIONS.search_path, "bin", "deapexer")
|
||||||
if os.path.isfile(deapexer_path):
|
if os.path.isfile(deapexer_path):
|
||||||
deapexer = deapexer_path
|
deapexer = deapexer_path
|
||||||
|
|
||||||
for apex_filename in os.listdir(target_dir):
|
for apex_filename in os.listdir(target_dir):
|
||||||
apex_filepath = os.path.join(target_dir, apex_filename)
|
apex_filepath = os.path.join(target_dir, apex_filename)
|
||||||
if not os.path.isfile(apex_filepath) or \
|
if not os.path.isfile(apex_filepath) or \
|
||||||
@@ -622,6 +645,7 @@ def GetApexInfoFromTargetFiles(input_file, partition, compressed_only=True):
|
|||||||
# Check if the file is compressed or not
|
# Check if the file is compressed or not
|
||||||
apex_type = RunAndCheckOutput([
|
apex_type = RunAndCheckOutput([
|
||||||
deapexer, "--debugfs_path", debugfs_path,
|
deapexer, "--debugfs_path", debugfs_path,
|
||||||
|
"--fsckerofs_path", fsckerofs_path,
|
||||||
'info', '--print-type', apex_filepath]).rstrip()
|
'info', '--print-type', apex_filepath]).rstrip()
|
||||||
if apex_type == 'COMPRESSED':
|
if apex_type == 'COMPRESSED':
|
||||||
apex_info.is_compressed = True
|
apex_info.is_compressed = True
|
||||||
|
Reference in New Issue
Block a user