Merge "check_target_files_vintf: Support flattened apexes" am: eb5f9e2bef

Original change: https://android-review.googlesource.com/c/platform/build/+/2257463

Change-Id: I4b99ae384419368d7cd396823fa98474959daed3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-10-20 03:42:29 +00:00
committed by Automerger Merge Worker
2 changed files with 20 additions and 13 deletions

View File

@@ -95,6 +95,7 @@ python_defaults {
"check_target_files_vintf.py", "check_target_files_vintf.py",
], ],
libs: [ libs: [
"apex_manifest",
"releasetools_common", "releasetools_common",
], ],
required: [ required: [

View File

@@ -24,12 +24,14 @@ target_files can be a ZIP file or an extracted target files directory.
import json import json
import logging import logging
import os
import shutil
import subprocess import subprocess
import sys import sys
import os
import zipfile import zipfile
import common import common
from apex_manifest import ParseApexManifest
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -227,24 +229,26 @@ def PrepareApexDirectory(inp):
apex-info-list.xml file 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): def ExtractApexes(path, outp):
# Extract all APEXes found in input path. # 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) logger.info('Extracting APEXs in %s', path)
for f in os.listdir(path): for f in os.listdir(path):
logger.info(' adding APEX %s', os.path.basename(f)) logger.info(' adding APEX %s', os.path.basename(f))
apex = os.path.join(path, f) apex = os.path.join(path, f)
if os.path.isdir(apex): if os.path.isdir(apex) and os.path.isfile(os.path.join(apex, 'apex_manifest.pb')):
# TODO(b/242314000) Handle "flattened" apex info = ParseApexManifest(os.path.join(apex, 'apex_manifest.pb'))
pass # Flattened APEXes may have symlinks for libs (linked to /system/lib)
else: # 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, cmd = [deapexer,
'--debugfs_path', debugfs_path, '--debugfs_path', debugfs_path,
'info', 'info',
@@ -257,6 +261,8 @@ def PrepareApexDirectory(inp):
apex, apex,
os.path.join(outp, info['name'])] os.path.join(outp, info['name'])]
common.RunAndCheckOutput(cmd) common.RunAndCheckOutput(cmd)
else:
logger.info(' .. skipping %s (is it APEX?)', path)
root_dir_name = 'APEX' root_dir_name = 'APEX'
root_dir = os.path.join(inp, root_dir_name) root_dir = os.path.join(inp, root_dir_name)