diff --git a/tools/releasetools/merge/merge_dexopt.py b/tools/releasetools/merge/merge_dexopt.py index 1dd591b743..c21103cfad 100644 --- a/tools/releasetools/merge/merge_dexopt.py +++ b/tools/releasetools/merge/merge_dexopt.py @@ -72,7 +72,6 @@ def MergeDexopt(temp_dir, output_target_files_dir): # # system -> output/SYSTEM # vendor -> output/VENDOR - # apex -> output/SYSTEM/apex (only for flattened APEX builds) # apex/ (extracted updatable APEX) # / # ... @@ -114,19 +113,11 @@ def MergeDexopt(temp_dir, output_target_files_dir): os.path.join(output_target_files_dir, 'VENDOR'), os.path.join(temp_dir, 'vendor')) - # The directory structure for flatteded APEXes is: - # - # SYSTEM - # apex - # - # apex_manifest.pb - # apex_pubkey - # etc/ - # javalib/ - # lib/ - # lib64/ - # priv-app/ - # + # Extract APEX. + logging.info('extracting APEX') + apex_extract_root_dir = os.path.join(temp_dir, 'apex') + os.makedirs(apex_extract_root_dir) + # The directory structure for updatable APEXes is: # # SYSTEM @@ -136,46 +127,33 @@ def MergeDexopt(temp_dir, output_target_files_dir): # com.android.art.apex # ... apex_root = os.path.join(output_target_files_dir, 'SYSTEM', 'apex') + for apex in (glob.glob(os.path.join(apex_root, '*.apex')) + + glob.glob(os.path.join(apex_root, '*.capex'))): + logging.info(' apex: %s', apex) + # deapexer is in the same directory as the merge_target_files binary extracted + # from otatools.zip. + apex_json_info = subprocess.check_output(['deapexer', 'info', apex]) + logging.info(' info: %s', apex_json_info) + apex_info = json.loads(apex_json_info) + apex_name = apex_info['name'] + logging.info(' name: %s', apex_name) - # Check for flattended versus updatable APEX. - if OPTIONS.framework_misc_info.get('target_flatten_apex') == 'false': - # Extract APEX. - logging.info('extracting APEX') + apex_extract_dir = os.path.join(apex_extract_root_dir, apex_name) + os.makedirs(apex_extract_dir) - apex_extract_root_dir = os.path.join(temp_dir, 'apex') - os.makedirs(apex_extract_root_dir) - - for apex in (glob.glob(os.path.join(apex_root, '*.apex')) + - glob.glob(os.path.join(apex_root, '*.capex'))): - logging.info(' apex: %s', apex) - # deapexer is in the same directory as the merge_target_files binary extracted - # from otatools.zip. - apex_json_info = subprocess.check_output(['deapexer', 'info', apex]) - logging.info(' info: %s', apex_json_info) - apex_info = json.loads(apex_json_info) - apex_name = apex_info['name'] - logging.info(' name: %s', apex_name) - - apex_extract_dir = os.path.join(apex_extract_root_dir, apex_name) - os.makedirs(apex_extract_dir) - - # deapexer uses debugfs_static, which is part of otatools.zip. - command = [ - 'deapexer', - '--debugfs_path', - 'debugfs_static', - '--fsckerofs_path', - 'fsck.erofs', - 'extract', - apex, - apex_extract_dir, - ] - logging.info(' running %s', command) - subprocess.check_call(command) - else: - # Flattened APEXes don't need to be extracted since they have the necessary - # directory structure. - os.symlink(os.path.join(apex_root), os.path.join(temp_dir, 'apex')) + # deapexer uses debugfs_static/fsck.erofs from otatools.zip. + command = [ + 'deapexer', + '--debugfs_path', + 'debugfs_static', + '--fsckerofs_path', + 'fsck.erofs', + 'extract', + apex, + apex_extract_dir, + ] + logging.info(' running %s', command) + subprocess.check_call(command) # Modify system config to point to the tools that have been extracted. # Absolute or .. paths are not allowed by the dexpreopt_gen tool in