Fix bug in ota_from_raw_img when generating multiple images

Python argparse support for multiple arguments per flag is limited,
so we need to manually do parsing here(split by ",")

Test: generate a boot image OTA with boot and dtbo partition
Bug: 349590107
Change-Id: Ia9f7e0ab0836bddf15591a74b17a667e63080373
This commit is contained in:
Kelvin Zhang
2024-06-26 10:10:18 -07:00
parent 1d20ca9f72
commit 9ef8a02782

View File

@@ -54,7 +54,7 @@ def main(argv):
prog=argv[0], description="Given a series of .img files, produces a full OTA package that installs thoese images") prog=argv[0], description="Given a series of .img files, produces a full OTA package that installs thoese images")
parser.add_argument("images", nargs="+", type=str, parser.add_argument("images", nargs="+", type=str,
help="List of images to generate OTA") help="List of images to generate OTA")
parser.add_argument("--partition_names", nargs='+', type=str, parser.add_argument("--partition_names", nargs='?', type=str,
help="Partition names to install the images, default to basename of the image(no file name extension)") help="Partition names to install the images, default to basename of the image(no file name extension)")
parser.add_argument('--output', type=str, parser.add_argument('--output', type=str,
help='Paths to output merged ota', required=True) help='Paths to output merged ota', required=True)
@@ -74,18 +74,20 @@ def main(argv):
old_imgs[i], args.images[i] = img.split(":", maxsplit=1) old_imgs[i], args.images[i] = img.split(":", maxsplit=1)
if not args.partition_names: if not args.partition_names:
args.partition_names = [os.path.os.path.splitext(os.path.basename(path))[ args.partition_names = [os.path.splitext(os.path.basename(path))[
0] for path in args.images] 0] for path in args.images]
else:
args.partition_names = args.partition_names.split(",")
with tempfile.NamedTemporaryFile() as unsigned_payload, tempfile.NamedTemporaryFile() as dynamic_partition_info_file: with tempfile.NamedTemporaryFile() as unsigned_payload, tempfile.NamedTemporaryFile() as dynamic_partition_info_file:
dynamic_partition_info_file.writelines( dynamic_partition_info_file.writelines(
[b"virtual_ab=true\n", b"super_partition_groups=\n"]) [b"virtual_ab=true\n", b"super_partition_groups=\n"])
dynamic_partition_info_file.flush() dynamic_partition_info_file.flush()
cmd = [ResolveBinaryPath("delta_generator", args.search_path)] cmd = [ResolveBinaryPath("delta_generator", args.search_path)]
cmd.append("--partition_names=" + ",".join(args.partition_names)) cmd.append("--partition_names=" + ":".join(args.partition_names))
cmd.append("--dynamic_partition_info_file=" + cmd.append("--dynamic_partition_info_file=" +
dynamic_partition_info_file.name) dynamic_partition_info_file.name)
cmd.append("--old_partitions=" + ",".join(old_imgs)) cmd.append("--old_partitions=" + ":".join(old_imgs))
cmd.append("--new_partitions=" + ",".join(args.images)) cmd.append("--new_partitions=" + ":".join(args.images))
cmd.append("--out_file=" + unsigned_payload.name) cmd.append("--out_file=" + unsigned_payload.name)
cmd.append("--is_partial_update") cmd.append("--is_partial_update")
if args.max_timestamp: if args.max_timestamp: