Exemplo n.º 1
0
def install(force: bool) -> None:
    """
    Install all the necessary above programs and modules

    :param force: force installation if package is already installed
    :raise subprocess.CalledProcessError on error
    """
    logging.info("Installing required programs and modules")
    packages_to_install = set(get_global_conf().getlist("install", "dependencies"))

    if get_global_conf().getboolean("install", "module_handling"):
        packages_to_install.add("python3-pip")  # pylint: disable=no-member

    compiler = get_global_conf().get("install", "compiler")
    compiler_conf = get_compiler_conf(*compiler.split("."))

    for section in compiler_conf.sections():
        if section in ["env", "install"]:
            continue

        packages_to_install.update(compiler_conf[section].getlist("depend", fallback=[]))

    packages_to_install.update(get_programs_dependencies())
    packages_to_install.update(compiler_conf.getlist("install", "depend", fallback=[]))

    dependency_installer.DependenciesInstaller.factory(list(packages_to_install)).run()

    Installer.factory(compiler_conf["install"], force).run()

    if get_global_conf().getboolean("install", "module_handling"):
        install_python_modules()

    if get_global_conf().getboolean("install", "llvm_bitcode"):
        install_wllvm(force)
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
Exemplo n.º 3
0
def install_wllvm(force: bool) -> None:
    """
    Installs wllvm
    :param force: force installation if package is already installed
    """
    conf = ProgramParser()
    conf.read([os.path.join(constants.CONF_PATH, "utils/wllvm.conf")])
    Installer.factory(conf["WLLVM"], force).run()
Exemplo n.º 4
0
 def configure(force: bool) -> None:
     """
     Downloads RR from Github and installs it
     :param force: True to install even if nothing has changed
     """
     mozilla_rr = get_plugin_conf("base", "rr")
     installer = Installer.factory(mozilla_rr["rr"], force)
     installer.run()
Exemplo n.º 5
0
Arquivo: rr.py Projeto: taolee/bugbase
 def configure(force: bool) -> None:
     """
     Downloads RR from Github and installs it
     :param force: True to install even if nothing has changed
     """
     mozilla_rr = get_plugin_conf("base", "rr")
     installer = Installer.factory(mozilla_rr["rr"], force)
     installer.run()
Exemplo n.º 6
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.º 7
0
 def onAddDict(self, event):
     installer = Installer(self, self.app.config)
     installer.showGUI()
Exemplo n.º 8
0
    # }
    answers = {
        'path': path,
        'package_name': questions.package_name(default='mreschke.wiki'),
        'friendly_name': questions.friendly_name(default="mReschke Wiki"),
        'your_name': questions.your_name(default="Matthew Reschke"),
        'your_email': questions.your_email(default="*****@*****.**"),
        'environment': questions.environment(default='Poetry'),
    }

    # Confirm answers before install
    nl(2); line("#", LIGHTBLUE); nl(2)
    info("You are are about to customize this blank uvicore package schema as follows:")
    for answer in answers.items(): item(answer)
    nl(); go = user_confirm("Continue"); nl()

    # Install package with question answers
    if go:
        installer = Installer(answers, __version__)
        installer.handle()

    # User cancelled, abort installation
    if not go:
        error("Installation aborted.")
        info("This package is in an error state and is not configured to actually run.")
        info("You can manually re-run:")
        info("  python ./.install/install.py", DARKGRAY)
        info("Or you can go ahead and delete this {}".format(path))
        info("folder and start over with the 'uvicore-new-app' command. Bye.")
        error("Installation aborted.")
Exemplo n.º 9
0
def main(programs, force_installation, processes, **kwargs):
    """
    the main function. runs installers
    :param programs: the programs to install
    :param force_installation: if the installation must be done if the program was already installed
    :param kwargs: additional parameters to pass to the plugins
    """

    # pylint: disable=no-member,too-few-public-methods
    class InstallerProcess(multiprocessing.Process):
        """
        An Installer for a list of programs.
        :param _programs: the list of programs to launch
        :param _report_queue: the queue where to report the return value
        :param _max_tasks: the semaphore to acquire at the end to release a new worker
        """
        def __init__(self, _programs: list,
                     _report_queue: multiprocessing.Queue,
                     _max_tasks: multiprocessing.Semaphore):
            super().__init__()
            self.programs = _programs
            self.report_queue = _report_queue
            self.max_tasks = _max_tasks

        def run(self):
            """ Installs the programs and reports the value """
            error = None
            try:
                for _installer in self.programs:
                    try:
                        if (not _installer.run()) and _installer.conf.get(
                                "executable", None):
                            hooks.create_executables(installer=_installer)
                            hooks.post_install_run(installer=_installer,
                                                   **kwargs)
                    except InstallationErrorException as exception:
                        logging.error(exception.error_message)
                        logging.error(
                            "Won't install %(program)s",
                            dict(program=_installer.conf.get("name")))
                        error = constants.INSTALL_FAIL
            except Exception as exc:  # pylint: disable=broad-except
                error = constants.INSTALL_FAIL
                logging.error(exc)
                logging.debug("".join(traceback.format_tb(exc.__traceback__)))

            finally:
                logging.verbose("Cleaning environment")
                hooks.post_install_clean(**kwargs)
                self.max_tasks.release()
                self.report_queue.put(
                    (error or 0, self.programs[0].conf.get("name")))

    installers = []
    report_queue = multiprocessing.Queue()
    max_tasks = multiprocessing.Semaphore(processes)

    for program in programs:
        max_tasks.acquire()
        lib.logger.start_new_log_section(program, "installation")
        program_conf = get_program_conf(program)

        installer = InstallerProcess([
            Installer.factory(program_conf[prog], force_installation)
            for prog in program_conf.sections()
        ], report_queue, max_tasks)
        installer.start()
        installers.append(installer)

    return_value = 0
    counter = 0
    for _ in installers:
        counter += 1
        value, program = report_queue.get(block=True)
        if value:
            return_value = value
            logging.error("%(prog)s failed to compile correctly",
                          dict(prog=program))

        show_progress(counter, len(installers))

    return return_value
Exemplo n.º 10
0
def main(programs, force_installation, processes, **kwargs):
    """
    the main function. runs installers
    :param programs: the programs to install
    :param force_installation: if the installation must be done if the program was already installed
    :param kwargs: additional parameters to pass to the plugins
    """
    # pylint: disable=no-member,too-few-public-methods
    class InstallerProcess(multiprocessing.Process):
        """
        An Installer for a list of programs.
        :param _programs: the list of programs to launch
        :param _report_queue: the queue where to report the return value
        :param _max_tasks: the semaphore to acquire at the end to release a new worker
        """

        def __init__(
            self, _programs: list, _report_queue: multiprocessing.Queue, _max_tasks: multiprocessing.Semaphore
        ):
            super().__init__()
            self.programs = _programs
            self.report_queue = _report_queue
            self.max_tasks = _max_tasks

        def run(self):
            """ Installs the programs and reports the value """
            error = None
            try:
                for _installer in self.programs:
                    try:
                        if (not _installer.run()) and _installer.conf.get("executable", None):
                            hooks.create_executables(installer=_installer)
                            hooks.post_install_run(installer=_installer, **kwargs)
                    except InstallationErrorException as exception:
                        logging.error(exception.error_message)
                        logging.error("Won't install %(program)s", dict(program=_installer.conf.get("name")))
                        error = constants.INSTALL_FAIL
            except Exception as exc:  # pylint: disable=broad-except
                error = constants.INSTALL_FAIL
                logging.error(exc)
                logging.debug("".join(traceback.format_tb(exc.__traceback__)))

            finally:
                logging.verbose("Cleaning environment")
                hooks.post_install_clean(**kwargs)
                self.max_tasks.release()
                self.report_queue.put((error or 0, self.programs[0].conf.get("name")))

    installers = []
    report_queue = multiprocessing.Queue()
    max_tasks = multiprocessing.Semaphore(processes)

    for program in programs:
        max_tasks.acquire()
        lib.logger.start_new_log_section(program, "installation")
        program_conf = get_program_conf(program)

        installer = InstallerProcess(
            [Installer.factory(program_conf[prog], force_installation) for prog in program_conf.sections()],
            report_queue,
            max_tasks,
        )
        installer.start()
        installers.append(installer)

    return_value = 0
    counter = 0
    for _ in installers:
        counter += 1
        value, program = report_queue.get(block=True)
        if value:
            return_value = value
            logging.error("%(prog)s failed to compile correctly", dict(prog=program))

        show_progress(counter, len(installers))

    return return_value