예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
 def setUp(self):
     self.config = DummyConfig()
     cb = create_cookbook(self.config)
     store = create_store(self.config)
     cb.add_recipe(Recipe1(self.config))
     self.package = Package(self.config, store, cb)
     self.mergemodule = MergeModule(self.config, self.package.files_list(),
                                    self.package)