Merge "Support for recovery snapshot." am: 91d34ce25e
Original change: https://android-review.googlesource.com/c/platform/development/+/1530445 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I9d783bfddbcd307b35bd1f6031dc807ade2d0f9b
This commit is contained in:
committed by
Automerger Merge Worker
commit
fd6fe9e768
@@ -145,12 +145,12 @@ def convert_json_to_bp_prop(json_path, bp_dir):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def gen_bp_module(variation, name, version, target_arch, arch_props, bp_dir):
|
def gen_bp_module(image, variation, name, version, target_arch, arch_props, bp_dir):
|
||||||
prop = {
|
prop = {
|
||||||
# These three are common for all snapshot modules.
|
# These three are common for all snapshot modules.
|
||||||
'version': str(version),
|
'version': str(version),
|
||||||
'target_arch': target_arch,
|
'target_arch': target_arch,
|
||||||
'vendor': True,
|
image: True,
|
||||||
'arch': {},
|
'arch': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ def gen_bp_module(variation, name, version, target_arch, arch_props, bp_dir):
|
|||||||
elif stem64:
|
elif stem64:
|
||||||
prop['compile_multilib'] = '64'
|
prop['compile_multilib'] = '64'
|
||||||
|
|
||||||
bp = 'vendor_snapshot_%s {\n' % variation
|
bp = '%s_snapshot_%s {\n' % (image, variation)
|
||||||
bp += gen_bp_prop(prop, INDENT)
|
bp += gen_bp_prop(prop, INDENT)
|
||||||
bp += '}\n\n'
|
bp += '}\n\n'
|
||||||
return bp
|
return bp
|
||||||
@@ -268,7 +268,7 @@ def build_props(install_dir):
|
|||||||
return props
|
return props
|
||||||
|
|
||||||
|
|
||||||
def gen_bp_files(install_dir, snapshot_version):
|
def gen_bp_files(image, install_dir, snapshot_version):
|
||||||
props = build_props(install_dir)
|
props = build_props(install_dir)
|
||||||
|
|
||||||
for target_arch in sorted(props):
|
for target_arch in sorted(props):
|
||||||
@@ -276,8 +276,8 @@ def gen_bp_files(install_dir, snapshot_version):
|
|||||||
bp_dir = os.path.join(install_dir, target_arch)
|
bp_dir = os.path.join(install_dir, target_arch)
|
||||||
for variation in sorted(props[target_arch]):
|
for variation in sorted(props[target_arch]):
|
||||||
for name in sorted(props[target_arch][variation]):
|
for name in sorted(props[target_arch][variation]):
|
||||||
androidbp += gen_bp_module(variation, name, snapshot_version,
|
androidbp += gen_bp_module(image, variation, name,
|
||||||
target_arch,
|
snapshot_version, target_arch,
|
||||||
props[target_arch][variation][name],
|
props[target_arch][variation][name],
|
||||||
bp_dir)
|
bp_dir)
|
||||||
with open(os.path.join(bp_dir, 'Android.bp'), 'w') as f:
|
with open(os.path.join(bp_dir, 'Android.bp'), 'w') as f:
|
||||||
@@ -307,13 +307,16 @@ def fetch_artifact(branch, build, target, pattern, destination):
|
|||||||
]
|
]
|
||||||
check_call(cmd)
|
check_call(cmd)
|
||||||
|
|
||||||
def install_artifacts(branch, build, target, local_dir, symlink, install_dir):
|
def install_artifacts(image, branch, build, target, local_dir, symlink,
|
||||||
|
install_dir):
|
||||||
"""Installs vendor snapshot build artifacts to {install_dir}/v{version}.
|
"""Installs vendor snapshot build artifacts to {install_dir}/v{version}.
|
||||||
|
|
||||||
1) Fetch build artifacts from Android Build server or from local_dir
|
1) Fetch build artifacts from Android Build server or from local_dir
|
||||||
2) Unzip or create symlinks to build artifacts
|
2) Unzip or create symlinks to build artifacts
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
image: string, img file for which the snapshot was created (vendor,
|
||||||
|
recovery, etc.)
|
||||||
branch: string or None, branch name of build artifacts
|
branch: string or None, branch name of build artifacts
|
||||||
build: string or None, build number of build artifacts
|
build: string or None, build number of build artifacts
|
||||||
target: string or None, target name of build artifacts
|
target: string or None, target name of build artifacts
|
||||||
@@ -324,7 +327,7 @@ def install_artifacts(branch, build, target, local_dir, symlink, install_dir):
|
|||||||
temp_artifact_dir: string, temp directory to hold build artifacts fetched
|
temp_artifact_dir: string, temp directory to hold build artifacts fetched
|
||||||
from Android Build server. For 'local' option, is set to None.
|
from Android Build server. For 'local' option, is set to None.
|
||||||
"""
|
"""
|
||||||
artifact_pattern = 'vendor-*.zip'
|
artifact_pattern = image + '-*.zip'
|
||||||
|
|
||||||
def unzip_artifacts(artifact_dir):
|
def unzip_artifacts(artifact_dir):
|
||||||
artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern))
|
artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern))
|
||||||
@@ -374,6 +377,11 @@ def get_args():
|
|||||||
'snapshot_version',
|
'snapshot_version',
|
||||||
type=int,
|
type=int,
|
||||||
help='Vendor snapshot version to install, e.g. "30".')
|
help='Vendor snapshot version to install, e.g. "30".')
|
||||||
|
parser.add_argument(
|
||||||
|
'--image',
|
||||||
|
help=('Image whose snapshot is being updated (e.g., vendor, '
|
||||||
|
'recovery , ramdisk, etc.)'),
|
||||||
|
default='vendor')
|
||||||
parser.add_argument('--branch', help='Branch to pull build from.')
|
parser.add_argument('--branch', help='Branch to pull build from.')
|
||||||
parser.add_argument('--build', help='Build number to pull.')
|
parser.add_argument('--build', help='Build number to pull.')
|
||||||
parser.add_argument('--target', help='Target to pull.')
|
parser.add_argument('--target', help='Target to pull.')
|
||||||
@@ -460,13 +468,14 @@ def main():
|
|||||||
check_call(['mkdir', '-p', install_dir])
|
check_call(['mkdir', '-p', install_dir])
|
||||||
|
|
||||||
install_artifacts(
|
install_artifacts(
|
||||||
|
image=args.image,
|
||||||
branch=args.branch,
|
branch=args.branch,
|
||||||
build=args.build,
|
build=args.build,
|
||||||
target=args.target,
|
target=args.target,
|
||||||
local_dir=local,
|
local_dir=local,
|
||||||
symlink=args.symlink,
|
symlink=args.symlink,
|
||||||
install_dir=install_dir)
|
install_dir=install_dir)
|
||||||
gen_bp_files(install_dir, snapshot_version)
|
gen_bp_files(args.image, install_dir, snapshot_version)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user