aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2019-01-03 02:02:52 -0600
committerGerrit Code Review2019-01-03 02:02:52 -0600
commit6dc878bd87f29d488f7dc9a36ceb559ce78f5143 (patch)
treeba0863da01ed7a7d83c05fbed422749d072462f0
parent5723181c537d6d288b4554d9ded63634aec7f78e (diff)
parentcc46eae994d919d444edd8bb504ef476a7ec3541 (diff)
downloadplatform-build-6dc878bd87f29d488f7dc9a36ceb559ce78f5143.tar.gz
platform-build-6dc878bd87f29d488f7dc9a36ceb559ce78f5143.tar.xz
platform-build-6dc878bd87f29d488f7dc9a36ceb559ce78f5143.zip
Merge "Put system_other in super.img"
-rwxr-xr-xtools/releasetools/build_super_image.py52
1 files changed, 34 insertions, 18 deletions
diff --git a/tools/releasetools/build_super_image.py b/tools/releasetools/build_super_image.py
index e8730ae19..bb0e6413a 100755
--- a/tools/releasetools/build_super_image.py
+++ b/tools/releasetools/build_super_image.py
@@ -67,6 +67,17 @@ def GetPartitionSizeFromImage(img):
67 return os.path.getsize(img) 67 return os.path.getsize(img)
68 68
69 69
70def GetArgumentsForImage(partition, group, image=None):
71 image_size = GetPartitionSizeFromImage(image) if image else 0
72
73 cmd = ["--partition",
74 "{}:readonly:{}:{}".format(partition, image_size, group)]
75 if image:
76 cmd += ["--image", "{}={}".format(partition, image)]
77
78 return cmd
79
80
70def BuildSuperImageFromDict(info_dict, output): 81def BuildSuperImageFromDict(info_dict, output):
71 82
72 cmd = [info_dict["lpmake"], 83 cmd = [info_dict["lpmake"],
@@ -105,26 +116,25 @@ def BuildSuperImageFromDict(info_dict, output):
105 116
106 for partition in partition_list: 117 for partition in partition_list:
107 image = info_dict.get("{}_image".format(partition)) 118 image = info_dict.get("{}_image".format(partition))
108 image_size = 0
109 if image: 119 if image:
110 image_size = GetPartitionSizeFromImage(image)
111 has_image = True 120 has_image = True
112 if append_suffix: 121
113 cmd += ["--partition", 122 if not append_suffix:
114 "{}_a:readonly:{}:{}_a".format(partition, image_size, group), 123 cmd += GetArgumentsForImage(partition, group, image)
115 "--partition", 124 continue
116 "{}_b:readonly:0:{}_b".format(partition, group)] 125
117 if image: 126 # For A/B devices, super partition always contains sub-partitions in
118 # For A/B devices, super partition always contains sub-partitions in 127 # the _a slot, because this image should only be used for
119 # the _a slot, because this image should only be used for 128 # bootstrapping / initializing the device. When flashing the image,
120 # bootstrapping / initializing the device. When flashing the image, 129 # bootloader fastboot should always mark _a slot as bootable.
121 # bootloader fastboot should always mark _a slot as bootable. 130 cmd += GetArgumentsForImage(partition + "_a", group + "_a", image)
122 cmd += ["--image", "{}_a={}".format(partition, image)] 131
123 else: 132 other_image = None
124 cmd += ["--partition", 133 if partition == "system" and "system_other_image" in info_dict:
125 "{}:readonly:{}:{}".format(partition, image_size, group)] 134 other_image = info_dict["system_other_image"]
126 if image: 135 has_image = True
127 cmd += ["--image", "{}={}".format(partition, image)] 136
137 cmd += GetArgumentsForImage(partition + "_b", group + "_b", other_image)
128 138
129 if has_image: 139 if has_image:
130 cmd.append("--sparse") 140 cmd.append("--sparse")
@@ -145,6 +155,12 @@ def BuildSuperImageFromExtractedTargetFiles(inp, out):
145 info_dict = common.LoadInfoDict(inp) 155 info_dict = common.LoadInfoDict(inp)
146 partition_list = shlex.split( 156 partition_list = shlex.split(
147 info_dict.get("dynamic_partition_list", "").strip()) 157 info_dict.get("dynamic_partition_list", "").strip())
158
159 if "system" in partition_list:
160 image_path = os.path.join(inp, "IMAGES", "system_other.img")
161 if os.path.isfile(image_path):
162 info_dict["system_other_image"] = image_path
163
148 missing_images = [] 164 missing_images = []
149 for partition in partition_list: 165 for partition in partition_list:
150 image_path = os.path.join(inp, "IMAGES", "{}.img".format(partition)) 166 image_path = os.path.join(inp, "IMAGES", "{}.img".format(partition))