Files
build_soong/scripts/extra_install_zips_file_list.py
Cole Faust 99bec75197 Create EXTRA_INSTALL_ZIPS variable
Make needs to know about the "extra" zip files that are extracted
to the staging directories so that it can track all the installed files
correctly.

Also add a utility tool for listing the contents of relevant zips.

Bug: 337869220
Test: m droid and checked the contents of file_list.txt when adding an android_app_set locally
Change-Id: Idc5dd785b03c05f7972c66620d4e6359892b3863
2024-05-09 14:20:11 -07:00

40 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import os
import sys
import zipfile
from typing import List
def list_files_in_zip(zipfile_path: str) -> List[str]:
with zipfile.ZipFile(zipfile_path, 'r') as zf:
return zf.namelist()
def main():
parser = argparse.ArgumentParser(
description='Lists paths to all files inside an EXTRA_INSTALL_ZIPS zip file relative to a partition staging directory. '
'This script is just a helper because its difficult to implement this logic in make code.'
)
parser.add_argument('staging_dir',
help='Path to the partition staging directory')
parser.add_argument('extra_install_zips', nargs='*',
help='The value of EXTRA_INSTALL_ZIPS from make. It should be a list of extraction_dir:zip_file pairs.')
args = parser.parse_args()
staging_dir = args.staging_dir.removesuffix('/') + '/'
for zip_pair in args.extra_install_zips:
d, z = zip_pair.split(':')
d = d.removesuffix('/') + '/'
if d.startswith(staging_dir):
d = os.path.relpath(d, staging_dir)
if d == '.':
d = ''
for f in list_files_in_zip(z):
print(os.path.join(d, f))
if __name__ == "__main__":
main()