Exemplo n.º 1
0
    def create_executable(self,
                          installer: Installer,
                          extension: str = None,
                          version_number: int = None,
                          force: bool = False,
                          *args,
                          **kwargs) -> int:
        """
        Creates a special executable to run for this plugin if needed. If a patch is supplied by the form
        "program-name-version-extension.patch", it will automatically get used to create a new version

        :param installer: the installer instance that is used
        :param extension: the extension to add to the binary, usually the plugin name
        :param version_number: if multiple version are required for a plugin, this will get appended to it
        :param force: force creation even if no patch is provided
        :param args: additional arguments
        :param kwargs: additional keyword arguments
        :return: None|0 if nothing happened or installation is successful
        """
        extension = extension or self.extension
        executable_suffix = "{}-{}".format(
            extension, version_number) if version_number else extension

        for lib in installer.conf.getlist("libraries"):
            lib_installer = Installer.factory(installer.conf.get_library(lib),
                                              False)
            with ExtensionPatcherManager(lib_installer,
                                         extension) as lib_patcher:
                if lib_patcher.is_patched or force:
                    lib_installer.configure()
                    lib_installer.make()
                    lib_installer.install()
                    force = True

        with ExtensionPatcherManager(installer, extension) as patcher:
            if not patcher.is_patched and not force:
                logging.verbose(
                    "No need to create special executable for {}".format(
                        extension))
                return

            installer.make()
            executable = os.path.join(installer.working_dir,
                                      installer.conf.get("bitcode_file"))
            destination = "{}-{}".format(installer.conf.get_executable(),
                                         executable_suffix)
            logging.verbose("Copying {} to {}".format(
                executable, os.path.join(installer.install_dir, destination)))
            shutil.copy(executable,
                        os.path.join(installer.install_dir, destination))

        for lib in installer.conf.getlist("libraries"):
            lib_installer = Installer.factory(installer.conf.get_library(lib),
                                              False)
            if force:
                lib_installer.configure()
                lib_installer.make()
                lib_installer.install()

        return 0
Exemplo n.º 2
0
    def create_executable(self, installer: Installer, extension: str=None, version_number: int=None, force: bool=False,
                          *args, **kwargs) -> int:
        """
        Creates a special executable to run for this plugin if needed. If a patch is supplied by the form
        "program-name-version-extension.patch", it will automatically get used to create a new version

        :param installer: the installer instance that is used
        :param extension: the extension to add to the binary, usually the plugin name
        :param version_number: if multiple version are required for a plugin, this will get appended to it
        :param force: force creation even if no patch is provided
        :param args: additional arguments
        :param kwargs: additional keyword arguments
        :return: None|0 if nothing happened or installation is successful
        """
        extension = extension or self.extension
        executable_suffix = "{}-{}".format(extension, version_number) if version_number else extension

        for lib in installer.conf.getlist("libraries"):
            lib_installer = Installer.factory(installer.conf.get_library(lib), False)
            with ExtensionPatcherManager(lib_installer, extension) as lib_patcher:
                if lib_patcher.is_patched or force:
                    lib_installer.configure()
                    lib_installer.make()
                    lib_installer.install()
                    force = True

        with ExtensionPatcherManager(installer, extension) as patcher:
            if not patcher.is_patched and not force:
                logging.verbose("No need to create special executable for {}".format(extension))
                return

            installer.make()
            executable = os.path.join(installer.working_dir, installer.conf.get("bitcode_file"))
            destination = "{}-{}".format(installer.conf.get_executable(), executable_suffix)
            logging.verbose("Copying {} to {}".format(executable, os.path.join(installer.install_dir, destination)))
            shutil.copy(executable, os.path.join(installer.install_dir, destination))

        for lib in installer.conf.getlist("libraries"):
            lib_installer = Installer.factory(installer.conf.get_library(lib), False)
            if force:
                lib_installer.configure()
                lib_installer.make()
                lib_installer.install()

        return 0