diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-10-20 03:19:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-10-20 03:19:24 +0000 |
commit | eb5f9e2bef6a620cba79554b26b64e2155710f1b (patch) | |
tree | 45de7f9f1d041e0266c925c1a4b4de69017d5e68 | |
parent | 3bb6ef900730da84820a604faf6791efc5946276 (diff) | |
parent | eb1182115bdf57009d9773401625eeb4a5df9578 (diff) | |
download | build-eb5f9e2bef6a620cba79554b26b64e2155710f1b.tar.gz |
Merge "check_target_files_vintf: Support flattened apexes"
-rw-r--r-- | tools/releasetools/Android.bp | 1 | ||||
-rwxr-xr-x | tools/releasetools/check_target_files_vintf.py | 32 |
2 files changed, 20 insertions, 13 deletions
diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp index aefce81b4c..29fc771b86 100644 --- a/tools/releasetools/Android.bp +++ b/tools/releasetools/Android.bp @@ -95,6 +95,7 @@ python_defaults { "check_target_files_vintf.py", ], libs: [ + "apex_manifest", "releasetools_common", ], required: [ diff --git a/tools/releasetools/check_target_files_vintf.py b/tools/releasetools/check_target_files_vintf.py index fa2eaebac1..c369a5961c 100755 --- a/tools/releasetools/check_target_files_vintf.py +++ b/tools/releasetools/check_target_files_vintf.py @@ -24,12 +24,14 @@ target_files can be a ZIP file or an extracted target files directory. import json import logging +import os +import shutil import subprocess import sys -import os import zipfile import common +from apex_manifest import ParseApexManifest logger = logging.getLogger(__name__) @@ -227,24 +229,26 @@ def PrepareApexDirectory(inp): apex-info-list.xml file """ + debugfs_path = 'debugfs' + deapexer = 'deapexer' + if OPTIONS.search_path: + debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static') + deapexer_path = os.path.join(OPTIONS.search_path, 'bin', 'deapexer') + if os.path.isfile(deapexer_path): + deapexer = deapexer_path + def ExtractApexes(path, outp): # Extract all APEXes found in input path. - debugfs_path = 'debugfs' - deapexer = 'deapexer' - if OPTIONS.search_path: - debugfs_path = os.path.join(OPTIONS.search_path, 'bin', 'debugfs_static') - deapexer_path = os.path.join(OPTIONS.search_path, 'bin', 'deapexer') - if os.path.isfile(deapexer_path): - deapexer = deapexer_path - logger.info('Extracting APEXs in %s', path) for f in os.listdir(path): logger.info(' adding APEX %s', os.path.basename(f)) apex = os.path.join(path, f) - if os.path.isdir(apex): - # TODO(b/242314000) Handle "flattened" apex - pass - else: + if os.path.isdir(apex) and os.path.isfile(os.path.join(apex, 'apex_manifest.pb')): + info = ParseApexManifest(os.path.join(apex, 'apex_manifest.pb')) + # Flattened APEXes may have symlinks for libs (linked to /system/lib) + # We need to blindly copy them all. + shutil.copytree(apex, os.path.join(outp, info.name), symlinks=True) + elif os.path.isfile(apex) and apex.endswith(('.apex', '.capex')): cmd = [deapexer, '--debugfs_path', debugfs_path, 'info', @@ -257,6 +261,8 @@ def PrepareApexDirectory(inp): apex, os.path.join(outp, info['name'])] common.RunAndCheckOutput(cmd) + else: + logger.info(' .. skipping %s (is it APEX?)', path) root_dir_name = 'APEX' root_dir = os.path.join(inp, root_dir_name) |