diff --git a/msi/createmsi.py b/msi/createmsi.py old mode 100644 new mode 100755 index bb6492c3b146..1c9142777c03 --- a/msi/createmsi.py +++ b/msi/createmsi.py @@ -22,50 +22,6 @@ sys.path.append(os.getcwd()) from mesonbuild import coredata -xml_templ = ''' - - - - - - - - - -''' - -xml_footer_templ = ''' - - - - - -%s - - - - - - - -''' - -file_templ = ''' -''' - -comp_ref_templ = ''' -''' - -path_addition_xml = ''' -''' - - def gen_guid(): return str(uuid.uuid4()).upper() @@ -165,31 +121,24 @@ def generate_files(self): 'Id': 'WixUI_InstallDir', }) assert(os.path.isdir(self.staging_dir)) - comp_ref_xml = '' nodes = {} - with open(self.main_xml, 'w') as ofile: - for root, dirs, files in os.walk(self.staging_dir): - cur_node = Node(dirs, files) - nodes[root] = cur_node - ofile.write(xml_templ % (self.guid, self.update_guid, self.version, self.version, - self.platform_str, self.progfile_dir)) - self.component_num = 0 - self.create_xml(nodes, ofile, self.staging_dir, installdir) - feature = ET.SubElement(product, 'Feature', { - 'Id': 'DefaultFeature', - 'Level': '1', + for root, dirs, files in os.walk(self.staging_dir): + cur_node = Node(dirs, files) + nodes[root] = cur_node + self.component_num = 0 + self.create_xml(nodes, self.staging_dir, installdir) + feature = ET.SubElement(product, 'Feature', { + 'Id': 'DefaultFeature', + 'Level': '1', + }) + + for i in range(self.component_num): + ET.SubElement(feature, 'ComponentRef', { + 'Id': 'ApplicationFiles%d' % i, }) - - for i in range(self.component_num): - ET.SubElement(feature, 'ComponentRef', { - 'Id': 'ApplicationFiles%d' % i, - }) - comp_ref_xml += comp_ref_templ % ('ApplicationFiles%d' % i) - ofile.write(xml_footer_templ % comp_ref_xml) - ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8',xml_declaration=True) - def create_xml(self, nodes, ofile, current_dir, parent_xml_node): + def create_xml(self, nodes, current_dir, parent_xml_node): cur_node = nodes[current_dir] if cur_node.files: comp_xml_node = ET.SubElement(parent_xml_node, 'Component', { @@ -207,9 +156,6 @@ def create_xml(self, nodes, ofile, current_dir, parent_xml_node): 'Action': 'set', 'Value': '[INSTALLDIR]', }) - ofile.write("\n" % (self.component_num, gen_guid(), self.component_platform)) - if self.component_num == 0: - ofile.write(path_addition_xml) self.component_num += 1 for f in cur_node.files: file_source = os.path.join(current_dir, f).replace('\\', '\\\\') @@ -219,8 +165,6 @@ def create_xml(self, nodes, ofile, current_dir, parent_xml_node): 'Name': f, 'Source': os.path.join(current_dir, f), }) - ofile.write(file_templ % (file_id, f, file_source)) - ofile.write('\n') for dirname in cur_node.dirs: dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_') @@ -228,11 +172,7 @@ def create_xml(self, nodes, ofile, current_dir, parent_xml_node): 'Id': dir_id, 'Name': dirname, }) - ofile.write('''\n''' % (dir_id, dirname)) - self.create_xml(nodes, ofile, os.path.join(current_dir, dirname), dir_node) - ofile.write('\n') - - + self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node) def build_package(self): wixdir = 'c:\\Program Files\\Wix Toolset v3.11\\bin'