Merge "Put system_other in super.img" am: 6dc878bd87

am: 59823773b4

Change-Id: I764b0bf5b18d9df4e1ca1434e47bbab324ecf790
This commit is contained in:
Yifan Hong 2019-01-03 00:15:28 -08:00 committed by android-build-merger
commit 2f0ab84cd7
1 changed files with 34 additions and 18 deletions

View File

@ -67,6 +67,17 @@ def GetPartitionSizeFromImage(img):
return os.path.getsize(img)
def GetArgumentsForImage(partition, group, image=None):
image_size = GetPartitionSizeFromImage(image) if image else 0
cmd = ["--partition",
"{}:readonly:{}:{}".format(partition, image_size, group)]
if image:
cmd += ["--image", "{}={}".format(partition, image)]
return cmd
def BuildSuperImageFromDict(info_dict, output):
cmd = [info_dict["lpmake"],
@ -105,26 +116,25 @@ def BuildSuperImageFromDict(info_dict, output):
for partition in partition_list:
image = info_dict.get("{}_image".format(partition))
image_size = 0
if image:
image_size = GetPartitionSizeFromImage(image)
has_image = True
if append_suffix:
cmd += ["--partition",
"{}_a:readonly:{}:{}_a".format(partition, image_size, group),
"--partition",
"{}_b:readonly:0:{}_b".format(partition, group)]
if image:
if not append_suffix:
cmd += GetArgumentsForImage(partition, group, image)
continue
# For A/B devices, super partition always contains sub-partitions in
# the _a slot, because this image should only be used for
# bootstrapping / initializing the device. When flashing the image,
# bootloader fastboot should always mark _a slot as bootable.
cmd += ["--image", "{}_a={}".format(partition, image)]
else:
cmd += ["--partition",
"{}:readonly:{}:{}".format(partition, image_size, group)]
if image:
cmd += ["--image", "{}={}".format(partition, image)]
cmd += GetArgumentsForImage(partition + "_a", group + "_a", image)
other_image = None
if partition == "system" and "system_other_image" in info_dict:
other_image = info_dict["system_other_image"]
has_image = True
cmd += GetArgumentsForImage(partition + "_b", group + "_b", other_image)
if has_image:
cmd.append("--sparse")
@ -145,6 +155,12 @@ def BuildSuperImageFromExtractedTargetFiles(inp, out):
info_dict = common.LoadInfoDict(inp)
partition_list = shlex.split(
info_dict.get("dynamic_partition_list", "").strip())
if "system" in partition_list:
image_path = os.path.join(inp, "IMAGES", "system_other.img")
if os.path.isfile(image_path):
info_dict["system_other_image"] = image_path
missing_images = []
for partition in partition_list:
image_path = os.path.join(inp, "IMAGES", "{}.img".format(partition))