Skip to content

Commit 7d4364e

Browse files
committed
get_contents: use list instead of set for the partitions
Running get_contents multiple times with the same input files generate different output files. This is because the list of partitions from partitions.xml are parsed and stored in a set data structure, which is unsorted. Looping on the set will return different output. Convert the set into a list instead which leads to: 1. the output is sorted, and thus the generated file is stable 2. the order from partitions.xml is preserved While making this change, I decided to put dict elements in the list instead of a list, it's easier to refer to field by name than by index. Signed-off-by: Nicolas Dechesne <[email protected]>
1 parent fc12ab8 commit 7d4364e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

gen_contents.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
3737
DefaultStorageType = ChipId.get('storage_type')
3838

3939
PhyPartition = PartitionRoot.findall('physical_partition')
40-
PartitionsSet = set()
41-
Partitions = PartitionRoot.findall('physical_partition/partition')
42-
for partition in Partitions:
40+
Partitions = []
41+
for partition in PartitionRoot.findall('physical_partition/partition'):
4342
label = partition.get('label')
4443
filename = partition.get('filename')
4544
if label and filename:
46-
PartitionsSet.add((label, filename))
47-
print(f"PartitionsSet: {PartitionsSet}")
45+
Partitions.append({'label': label, 'filename': filename})
46+
print(f"Partitions: {Partitions}")
4847

4948
builds = TemplateRoot.findall('builds_flat/build')
5049
for build in builds:
@@ -56,11 +55,11 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
5655
if DownloadFile is not None:
5756
build.remove(DownloadFile)
5857
# Partition entires
59-
for Partition in PartitionsSet:
58+
for Partition in Partitions:
6059
new_download_file = ET.SubElement(build, "download_file")
61-
new_download_file.set("fastboot_complete", Partition[0])
60+
new_download_file.set("fastboot_complete", Partition['label'])
6261
new_file_name = ET.SubElement(new_download_file, "file_name")
63-
new_file_name.text = Partition[1]
62+
new_file_name.text = Partition['filename']
6463
new_file_path = ET.SubElement(new_download_file, "file_path")
6564
new_file_path.text = "."
6665
# GPT Main & GPT Backup entries

0 commit comments

Comments
 (0)