def create_merge_module(self, output_dir, package_type, force, version, keep_temp): self.package.set_mode(package_type) files_list = self.files_list(package_type, force) mergemodule = MergeModule(self.config, files_list, self.package) package_name = self._package_name(version) sources = os.path.join(output_dir, "%s.wsx" % package_name) mergemodule.write(sources) wixobj = os.path.join(output_dir, "%s.wixobj" % package_name) if self._with_wine: wixobj = to_winepath(wixobj) sources = to_winepath(sources) candle = Candle(self.wix_prefix, self._with_wine) candle.compile(sources, output_dir) light = Light(self.wix_prefix, self._with_wine) path = light.compile([wixobj], package_name, output_dir, True) # Clean up if not keep_temp: os.remove(sources) os.remove(wixobj) os.remove(wixobj.replace('.wixobj', '.wixpdb')) return path
def _create_msi(self, config_path): sources = os.path.join(self.output_dir, "%s.wsx" % self._package_name()) msi = MSI(self.config, self.package, self.packagedeps, config_path, self.store) msi.write(sources) wixobjs = [os.path.join(self.output_dir, "%s.wixobj" % self._package_name())] #FIXME: Don't use our custom UI yet #wixobjs.append(os.path.join(self.output_dir, "ui.wixobj")) if self._with_wine: wixobjs = [to_winepath(x) for x in wixobjs] sources = to_winepath(sources) candle = Candle(self.wix_prefix, self._with_wine) candle.compile(sources, self.output_dir) light = Light(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) path = light.compile(wixobjs, self._package_name(), self.output_dir) # Clean up if not self.keep_temp: os.remove(sources) os.remove(config_path) for p in wixobjs: os.remove(p) os.remove(p.replace('.wixobj', '.wixpdb')) return path
def create_merge_module(self, output_dir, package_type, force, version, keep_temp): self.package.set_mode(package_type) files_list = self.files_list(package_type, force) if isinstance(self.package, VSTemplatePackage): mergemodule = VSMergeModule(self.config, files_list, self.package) else: mergemodule = MergeModule(self.config, files_list, self.package) tmpdir = None # For application packages that requires stripping object files, we need # to copy all the files to a new tree and strip them there: if isinstance(self.package, App) and self.package.strip: tmpdir = tempfile.mkdtemp() for f in files_list: src = os.path.join(self.config.prefix, f) dst = os.path.join(tmpdir, f) if not os.path.exists(os.path.dirname(dst)): os.makedirs(os.path.dirname(dst)) shutil.copy(src, dst) s = strip.Strip(self.config, self.package.strip_excludes) for p in self.package.strip_dirs: s.strip_dir(os.path.join(tmpdir, p)) mergemodule = MergeModule(self.config, files_list, self.package) if tmpdir: mergemodule.prefix = tmpdir package_name = self._package_name(version) sources = [os.path.join(output_dir, "%s.wxs" % package_name)] mergemodule.write(sources[0]) wixobjs = [os.path.join(output_dir, "%s.wixobj" % package_name)] for x in ['utils']: wixobjs.append(os.path.join(output_dir, "%s.wixobj" % x)) sources.append( os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: wixobjs = [to_winepath(x) for x in wixobjs] sources = [to_winepath(x) for x in sources] candle = Candle(self.wix_prefix, self._with_wine) candle.compile(' '.join(sources), output_dir) light = Light(self.wix_prefix, self._with_wine) path = light.compile(wixobjs, package_name, output_dir, True) # Clean up if not keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass if tmpdir: shutil.rmtree(tmpdir) return path
def create_merge_module(self, output_dir, package_type, force, version, keep_temp): self.package.set_mode(package_type) files_list = self.files_list(package_type, force) if isinstance(self.package, VSTemplatePackage): mergemodule = VSMergeModule(self.config, files_list, self.package) else: mergemodule = MergeModule(self.config, files_list, self.package) tmpdir = None # For application packages that requires stripping object files, we need # to copy all the files to a new tree and strip them there: if isinstance(self.package, App) and self.package.strip: tmpdir = tempfile.mkdtemp() for f in files_list: src = os.path.join(self.config.prefix, f) dst = os.path.join(tmpdir, f) if not os.path.exists(os.path.dirname(dst)): os.makedirs(os.path.dirname(dst)) shutil.copy(src, dst) s = strip.Strip(self.config, self.package.strip_excludes) for p in self.package.strip_dirs: s.strip_dir(os.path.join(tmpdir, p)) mergemodule = MergeModule(self.config, files_list, self.package) if tmpdir: mergemodule.prefix = tmpdir package_name = self._package_name(version) sources = [os.path.join(output_dir, "%s.wxs" % package_name)] mergemodule.write(sources[0]) wixobjs = [os.path.join(output_dir, "%s.wixobj" % package_name)] for x in ['utils']: wixobjs.append(os.path.join(output_dir, "%s.wixobj" % x)) sources.append(os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: wixobjs = [to_winepath(x) for x in wixobjs] sources = [to_winepath(x) for x in sources] candle = Candle(self.wix_prefix, self._with_wine) candle.compile(' '.join(sources), output_dir) light = Light(self.wix_prefix, self._with_wine) path = light.compile(wixobjs, package_name, output_dir, True) # Clean up if not keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass if tmpdir: shutil.rmtree(tmpdir) return path
def _create_msi(self, config_path): sources = [os.path.join(self.output_dir, "%s.wxs" % self._package_name())] msi = MSI(self.config, self.package, self.packagedeps, config_path, self.store) if self.wix_wine_prefix: msi.prefix = self.wix_wine_prefix msi.write(sources[0]) wixobjs = [os.path.join(self.output_dir, "%s.wixobj" % self._package_name())] if self.package.wix_use_fragment: wixobjs.extend(self.merge_modules[self.package.package_mode]) for x in ['utils']: wixobjs.append(os.path.join(self.output_dir, "%s.wixobj" % x)) sources.append(os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: final_wixobjs = [to_winepath(x) for x in wixobjs] final_sources = [to_winepath(x) for x in sources] else: final_wixobjs = wixobjs final_sources = sources candle = Candle(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) candle.compile(' '.join(final_sources), self.output_dir) light = Light(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) path = light.compile(final_wixobjs, self._package_name(), self.output_dir) # Clean up if not self.keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass os.remove(config_path) for t in self.packager_tmpdirs: try: shutil.rmtree(t) except: pass return path
def _create_msi(self, config_path): sources = [ os.path.join(self.output_dir, "%s.wxs" % self._package_name()) ] msi = MSI(self.config, self.package, self.packagedeps, config_path, self.store) if self.wix_wine_prefix: msi.prefix = self.wix_wine_prefix msi.write(sources[0]) wixobjs = [ os.path.join(self.output_dir, "%s.wixobj" % self._package_name()) ] if self.package.wix_use_fragment: wixobjs.extend(self.merge_modules[self.package.package_mode]) for x in ['utils']: wixobjs.append(os.path.join(self.output_dir, "%s.wixobj" % x)) sources.append( os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: final_wixobjs = [to_winepath(x) for x in wixobjs] final_sources = [to_winepath(x) for x in sources] else: final_wixobjs = wixobjs final_sources = sources candle = Candle(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) candle.compile(' '.join(final_sources), self.output_dir) light = Light(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) path = light.compile(final_wixobjs, self._package_name(), self.output_dir) # Clean up if not self.keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass os.remove(config_path) return path
def _customize_ui(self): # Banner Dialog and License for path, var in [(self.BANNER_BMP, 'BannerBmp'), (self.DIALOG_BMP, 'DialogBmp'), (self.LICENSE_RTF, 'LicenseRtf')]: path = self.package.relative_path(path) if self._with_wine: path = to_winepath(path) if os.path.exists(path): etree.SubElement(self.product, 'WixVariable', Id='WixUI%s' % var, Value=path) # Icon path = self.package.relative_path(self.ICON) if self._with_wine: path = to_winepath(path) if os.path.exists(path): etree.SubElement(self.product, 'Icon', Id='MainIcon', SourceFile=path)
def _create_bundle(self, config_path, paths): sources = [ os.path.join(self.output_dir, "burn_%s.wxs" % self._package_name()) ] burn = Burn(self.config, self.package, self.packagedeps, config_path, self.store, paths) burn.write(sources[0]) wixobjs = ["%s.wixobj" % p.rsplit('.', 1)[0] for p in sources] for x in ['utils']: wixobjs.append(os.path.join(self.output_dir, "%s.wixobj" % x)) sources.append( os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: final_wixobjs = [to_winepath(x) for x in wixobjs] final_sources = [to_winepath(x) for x in sources] else: final_wixobjs = wixobjs final_sources = sources candle = Candle(self.wix_prefix, self._with_wine, "%s %s" % (self.BURN_EXT, self.UTIL_EXT)) candle.compile(' '.join(final_sources), self.output_dir) light = Light(self.wix_prefix, self._with_wine, "%s %s" % (self.BURN_EXT, self.UTIL_EXT)) path = light.compile(final_wixobjs, self._package_name(), self.output_dir, extension='exe') # Clean up if not self.keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass os.remove(config_path) return path
def _create_config(self): config = WixConfig(self.config, self.package) config_path = config.write(self.output_dir) candle = Candle(self.wix_prefix, self._with_wine) ui_path = os.path.join(os.path.abspath(self.config.data_dir), self.UI_SOURCES) if self._with_wine: ui_path = to_winepath(ui_path) candle.compile(ui_path, self.output_dir) return config_path
def _create_bundle(self, config_path, paths): sources = [os.path.join(self.output_dir, "burn_%s.wxs" % self._package_name())] burn = Burn(self.config, self.package, self.packagedeps, config_path, self.store, paths) burn.write(sources[0]) wixobjs = ["%s.wixobj" % p.rsplit('.',1)[0] for p in sources] extra_sources = ['utils'] if self.package.wix_bundle_netframework: extra_sources.append ('netfx472') for x in extra_sources: wixobjs.append(os.path.join(self.output_dir, "%s.wixobj" % x)) sources.append(os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: final_wixobjs = [to_winepath(x) for x in wixobjs] final_sources = [to_winepath(x) for x in sources] else: final_wixobjs = wixobjs final_sources = sources extras = "%s %s" % (self.BURN_EXT, self.UTIL_EXT) if self.package.wix_bundle_netframework: extras = "%s %s" % (extras, self.NETFX_EXT) candle = Candle(self.wix_prefix, self._with_wine, extras) candle.compile(' '.join(final_sources), self.output_dir) light = Light(self.wix_prefix, self._with_wine, extras) path = light.compile(final_wixobjs, self._package_name(), self.output_dir, extension='exe') # Clean up if not self.keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass os.remove(config_path) return path
def get_wine_runtime_env(self, prefix, env): ''' When we're creating a cross-winXX shell, these runtime environment variables are only useful if the built binaries will be run using Wine, so convert them to values that can be understood by programs running under Wine. ''' runtime_env = ( 'GI_TYPELIB_PATH', 'XDG_DATA_DIRS', 'XDG_CONFIG_DIRS', 'GST_PLUGIN_PATH', 'GST_PLUGIN_PATH_1_0', 'GST_REGISTRY', 'GST_REGISTRY_1_0', ) for each in runtime_env: env[each] = to_winepath(env[each]) env['WINEPATH'] = to_winepath(os.path.join(prefix, 'bin')) return env
def _add_file(self, filepath): dirpath, filename = os.path.split(filepath) self._add_directory(dirpath) dirid = self._dirids[dirpath] component = etree.SubElement(self.component_group, 'Component', Id=self._format_dir_id(self.package.name, filepath), Guid=self._get_uuid(), Directory=dirid) filepath = os.path.join(self.prefix, filepath) p_id = self._format_dir_id(self.package.name, filepath, True) if self._with_wine: filepath = to_winepath(filepath) etree.SubElement(component, 'File', Id=p_id, Name=filename, Source=filepath)
def create_merge_module(self, output_dir, package_type, force, version, keep_temp): self.package.set_mode(package_type) files_list = self.files_list(package_type, force) if isinstance(self.package, VSTemplatePackage): mergemodule = VSMergeModule(self.config, files_list, self.package) else: mergemodule = MergeModule(self.config, files_list, self.package) package_name = self._package_name(version) sources = [os.path.join(output_dir, "%s.wxs" % package_name)] mergemodule.write(sources[0]) wixobjs = [os.path.join(output_dir, "%s.wixobj" % package_name)] for x in ['utils']: wixobjs.append(os.path.join(output_dir, "%s.wixobj" % x)) sources.append(os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: wixobjs = [to_winepath(x) for x in wixobjs] sources = [to_winepath(x) for x in sources] candle = Candle(self.wix_prefix, self._with_wine) candle.compile(' '.join(sources), output_dir) light = Light(self.wix_prefix, self._with_wine) path = light.compile(wixobjs, package_name, output_dir, True) # Clean up if not keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass return path
def _add_file(self, filepath): dirpath, filename = os.path.split(filepath) self._add_directory(dirpath) dirnode = self._dirnodes[dirpath] component = etree.SubElement(dirnode, 'Component', Id=self._format_path_id(filepath), Guid=self._get_uuid()) filepath = os.path.join(self.prefix, filepath) p_id = self._format_path_id(filepath, True) if self._with_wine: filepath = to_winepath(filepath) etree.SubElement(component, 'File', Id=p_id, Name=filename, Source=filepath)
def _create_msi(self, config_path): sources = [os.path.join(self.output_dir, "%s.wxs" % self._package_name())] msi = MSI(self.config, self.package, self.packagedeps, config_path, self.store) msi.write(sources[0]) wixobjs = [os.path.join(self.output_dir, "%s.wixobj" % self._package_name())] for x in ['utils']: wixobjs.append(os.path.join(self.output_dir, "%s.wixobj" % x)) sources.append(os.path.join(os.path.abspath(self.config.data_dir), 'wix/%s.wxs' % x)) if self._with_wine: wixobjs = [to_winepath(x) for x in wixobjs] sources = [to_winepath(x) for x in sources] candle = Candle(self.wix_prefix, self._with_wine) candle.compile(' '.join(sources), self.output_dir) light = Light(self.wix_prefix, self._with_wine, "%s %s" % (self.UI_EXT, self.UTIL_EXT)) path = light.compile(wixobjs, self._package_name(), self.output_dir) # Clean up if not self.keep_temp: os.remove(sources[0]) for f in wixobjs: os.remove(f) try: os.remove(f.replace('.wixobj', '.wixpdb')) except: pass os.remove(config_path) return path
def _add_file(self, filepath): dirpath, filename = os.path.split(filepath) self._add_directory(dirpath) dirid = self._dirids[dirpath] component = etree.SubElement(self.component_group, 'Component', Id=self._format_dir_id( self.package.name, filepath), Guid=self._get_uuid(), Directory=dirid) filepath = os.path.join(self.prefix, filepath) p_id = self._format_dir_id(self.package.name, filepath, True) if self._with_wine: filepath = to_winepath(filepath) etree.SubElement(component, 'File', Id=p_id, Name=filename, Source=filepath)
def _add_include(self): if self._with_wine: self.wix_config = to_winepath(self.wix_config) inc = etree.PI('include %s' % self.wix_config) self.root.insert(0, inc)