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
This commit is contained in:
parent
dd4f5537b8
commit
99bec75197
3 changed files with 49 additions and 1 deletions
|
@ -473,7 +473,7 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks, katiVintfManifestI
|
||||||
|
|
||||||
# Values written by Soong to generate install rules that can be amended by Kati.
|
# Values written by Soong to generate install rules that can be amended by Kati.
|
||||||
|
|
||||||
|
EXTRA_INSTALL_ZIPS :=
|
||||||
`)
|
`)
|
||||||
|
|
||||||
preserveSymlinksFlag := "-d"
|
preserveSymlinksFlag := "-d"
|
||||||
|
@ -507,9 +507,12 @@ func (s *makeVarsSingleton) writeInstalls(installs, symlinks, katiVintfManifestI
|
||||||
if extraFiles := install.extraFiles; extraFiles != nil {
|
if extraFiles := install.extraFiles; extraFiles != nil {
|
||||||
fmt.Fprintf(buf, "\t( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} ) || \\\n", extraFiles.dir.String(), extraFiles.zip.String())
|
fmt.Fprintf(buf, "\t( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} ) || \\\n", extraFiles.dir.String(), extraFiles.zip.String())
|
||||||
fmt.Fprintf(buf, "\t ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )\n")
|
fmt.Fprintf(buf, "\t ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )\n")
|
||||||
|
fmt.Fprintf(buf, "EXTRA_INSTALL_ZIPS += %s:%s\n", extraFiles.dir.String(), extraFiles.zip.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(buf)
|
fmt.Fprintln(buf)
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(buf, ".KATI_READONLY := EXTRA_INSTALL_ZIPS\n")
|
||||||
|
|
||||||
for _, symlink := range symlinks {
|
for _, symlink := range symlinks {
|
||||||
fmt.Fprintf(buf, "%s:", symlink.to.String())
|
fmt.Fprintf(buf, "%s:", symlink.to.String())
|
||||||
|
|
|
@ -296,3 +296,9 @@ python_binary_host {
|
||||||
main: "buildinfo.py",
|
main: "buildinfo.py",
|
||||||
srcs: ["buildinfo.py"],
|
srcs: ["buildinfo.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "extra_install_zips_file_list",
|
||||||
|
main: "extra_install_zips_file_list.py",
|
||||||
|
srcs: ["extra_install_zips_file_list.py"],
|
||||||
|
}
|
||||||
|
|
39
scripts/extra_install_zips_file_list.py
Executable file
39
scripts/extra_install_zips_file_list.py
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/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()
|
Loading…
Reference in a new issue