@@ -27,7 +27,7 @@ def ParseXML(XMLFile):
2727 return None
2828
2929
30- def UpdateMetaData (TemplateRoot , PartitionRoot ):
30+ def UpdateMetaData (TemplateRoot , PartitionRoot , BuildId ):
3131 ChipIdList = TemplateRoot .findall ('product_info/chipid' )
3232 DefaultStorageType = None
3333 for ChipId in ChipIdList :
@@ -64,6 +64,8 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
6464 for build in builds :
6565 Name = build .find ('name' )
6666 print (f"Build Name: { Name .text } " )
67+ new_build_id = ET .SubElement (build , "build_id" )
68+ new_build_id .text = BuildId
6769 if Name .text != "common" :
6870 continue
6971 DownloadFile = build .find ('download_file' )
@@ -113,14 +115,17 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
113115 if sys .argv [1 ] == "-h" or sys .argv [1 ] == "--help" :
114116 usage ()
115117 try :
116- opts , rem = getopt .getopt (sys .argv [1 :], "t:p:o:" )
118+ build_id = ""
119+ opts , rem = getopt .getopt (sys .argv [1 :], "t:p:o:b:" )
117120 for (opt , arg ) in opts :
118121 if opt in ["-t" ]:
119122 template = arg
120123 elif opt in ["-p" ]:
121124 partition_xml = arg
122125 elif opt in ["-o" ]:
123126 output_xml = arg
127+ elif opt in ["-b" ]:
128+ build_id = arg
124129 else :
125130 usage ()
126131 except Exception as argerr :
@@ -133,11 +138,11 @@ def _add_file_elements(parent_element, pathname, file_path_flavor=None):
133138 print ("Selected Partition XML: " + partition_xml )
134139 partition_root = ParseXML (partition_xml )
135140
136- UpdateMetaData (xml_root , partition_root )
141+ UpdateMetaData (xml_root , partition_root , build_id )
137142
138143 OutputTree = ET .ElementTree (xml_root )
139144 ET .indent (OutputTree , space = "\t " , level = 0 )
140- OutputTree .write (output_xml , encoding = "utf-8" , xml_declaration = True )
145+ OutputTree .write (output_xml , encoding = "utf-8" , xml_declaration = True , short_empty_elements = False )
141146except Exception as e :
142147 print (("Error: " , e ))
143148 sys .exit (1 )
0 commit comments