Exemplo n.º 1
0
    def main(self, *args):
        del args  # Unused

        print("Checking benchbuild binary dependencies...")
        provide_package("cmake")
        provide_package("fusermount")
        provide_package("unionfs")
        provide_package("postgres")

        has_uchroot = find_package("uchroot")
        if not has_uchroot:
            install_uchroot()
            has_uchroot = find_package("uchroot")
            if not has_uchroot:
                print("NOT INSTALLED")
        if has_uchroot:
            check_uchroot_config()

        provide_packages([
            "mkdir", "git", "tar", "mv", "rm", "bash", "rmdir", "time",
            "chmod", "cp", "ln", "make", "unzip", "cat", "patch", "find",
            "echo", "grep", "sed", "sh", "autoreconf", "ruby", "curl", "tail",
            "kill", "virtualenv", "timeout"
        ])

        if self.store_config:
            config_path = ".benchbuild.yml"
            CFG.store(config_path)
            print("Storing config in {0}".format(os.path.abspath(config_path)))
            exit(0)
Exemplo n.º 2
0
 def main(self, *args):
     print("Checking container binary dependencies...")
     if not find_package("uchroot"):
         if not find_package("cmake"):
             self.install_cmake_and_exit()
         install_uchroot()
     print("...OK")
     config_file = CFG["config_file"].value()
     if not (config_file and os.path.exists(config_file)):
         config_file = ".benchbuild.json"
     CFG.store(config_file)
     print("Storing config in {0}".format(os.path.abspath(config_file)))
     print(
         "Future container commands from this directory will automatically"
         " source the config file.")
Exemplo n.º 3
0
 def main(self, *args):
     print("Checking container binary dependencies...")
     if not bootstrap.find_package("uchroot"):
         if not bootstrap.find_package("cmake"):
             self.install_cmake_and_exit()
         bootstrap.install_uchroot()
     print("...OK")
     config_file = str(CFG["config_file"])
     if not (config_file and os.path.exists(config_file)):
         config_file = ".benchbuild.json"
     CFG.store(config_file)
     print("Storing config in {0}".format(os.path.abspath(config_file)))
     print(
         "Future container commands from this directory will automatically"
         " source the config file.")
Exemplo n.º 4
0
def setup_bash_in_container(builddir, container, outfile, mounts, shell):
    """
    Setup a bash environment inside a container.

    Creates a new chroot, which the user can use as a bash to run the wanted
    projects inside the mounted container, that also gets returned afterwards.
    """
    with local.cwd(builddir):
        # Switch to bash inside uchroot
        print("Entering bash inside User-Chroot. Prepare your image and "
              "type 'exit' when you are done. If bash exits with a non-zero"
              "exit code, no new container will be stored.")
        store_new_container = True
        try:
            run_in_container(shell, container, mounts)
        except ProcessExecutionError:
            store_new_container = False

        if store_new_container:  # pylint: disable=W0104
            print("Packing new container image.")
            pack_container(container, outfile)
            config_path = CFG["config_file"].value()
            CFG.store(config_path)
            print("Storing config in {0}".format(os.path.abspath(config_path)))
Exemplo n.º 5
0
def setup_bash_in_container(builddir, _container, outfile, shell):
    """
    Setup a bash environment inside a container.

    Creates a new chroot, which the user can use as a bash to run the wanted
    projects inside the mounted container, that also gets returned afterwards.
    """
    with local.cwd(builddir):
        # Switch to bash inside uchroot
        print("Entering bash inside User-Chroot. Prepare your image and "
              "type 'exit' when you are done. If bash exits with a non-zero"
              "exit code, no new container will be stored.")
        store_new_container = True
        try:
            run_in_container(shell, _container)
        except ProcessExecutionError:
            store_new_container = False

        if store_new_container:
            print("Packing new container image.")
            pack_container(_container, outfile)
            config_path = str(CFG["config_file"])
            CFG.store(config_path)
            print("Storing config in {0}".format(os.path.abspath(config_path)))
Exemplo n.º 6
0
    def main(self):
        """Main entry point of benchbuild run."""
        project_names = self._project_names
        group_name = self._group_name

        experiments.discover()

        registry = experiment.ExperimentRegistry
        exps = registry.experiments

        if self._list_experiments:
            for exp_name in registry.experiments:
                exp_cls = exps[exp_name]
                print(exp_cls.NAME)
                docstring = exp_cls.__doc__ or "-- no docstring --"
                print(("    " + docstring))
            exit(0)

        if self._list:
            for exp_name in self._experiment_names:
                exp_cls = exps[exp_name]
                exp = exp_cls(self._project_names, self._group_name)
                print_projects(exp)
            exit(0)

        if self.show_config:
            print(repr(CFG))
            exit(0)

        if self.store_config:
            config_path = ".benchbuild.json"
            CFG.store(config_path)
            print("Storing config in {0}".format(os.path.abspath(config_path)))
            exit(0)

        if self._project_names:
            builddir = os.path.abspath(str(CFG["build_dir"]))
            if not os.path.exists(builddir):
                response = True
                if sys.stdin.isatty():
                    response = ui.query_yes_no(
                        "The build directory {dirname} does not exist yet."
                        "Should I create it?".format(dirname=builddir), "no")

                if response:
                    mkdir("-p", builddir)
                    print("Created directory {0}.".format(builddir))

        actns = []
        for exp_name in self._experiment_names:
            if exp_name in exps:
                exp_cls = exps[exp_name]
                exp = exp_cls(project_names, group_name)
                eactn = Experiment(exp, exp.actions())
                actns.append(eactn)
            else:
                from logging import error
                error("Could not find {} in the experiment registry.",
                      exp_name)

        num_actions = sum([len(x) for x in actns])
        print("Number of actions to execute: {}".format(num_actions))
        for a in actns:
            print(a)
        print()

        if not self.pretend:
            for a in actns:
                a()
Exemplo n.º 7
0
 def wrap_store_config(self, *args, **kwargs):
     """Wrapper that contains the actual storage call for the config."""
     p = os.path.abspath(os.path.join(self.builddir))
     CFG.store(os.path.join(p, ".benchbuild.json"))
     return func(self, *args, **kwargs)
Exemplo n.º 8
0
    def main(self):
        """Main entry point of benchbuild run."""
        from benchbuild.utils.cmd import mkdir  # pylint: disable=E0401

        project_names = self._project_names
        group_name = self._group_name

        experiments.discover()

        registry = experiment.ExperimentRegistry
        exps = registry.experiments

        if self._list_experiments:
            for exp_name in registry.experiments:
                exp_cls = exps[exp_name]
                print(exp_cls.NAME)
                docstring = exp_cls.__doc__ or "-- no docstring --"
                print(("    " + docstring))
            exit(0)

        if self._list:
            for exp_name in self._experiment_names:
                exp_cls = exps[exp_name]
                exp = exp_cls(self._project_names, self._group_name)
                print_projects(exp)
            exit(0)

        if self.show_config:
            print(repr(CFG))
            exit(0)

        if self.store_config:
            config_path = ".benchbuild.json"
            CFG.store(config_path)
            print("Storing config in {0}".format(os.path.abspath(config_path)))
            exit(0)

        if self._project_names:
            builddir = os.path.abspath(str(CFG["build_dir"]))
            if not os.path.exists(builddir):
                response = True
                if sys.stdin.isatty():
                    response = ui.query_yes_no(
                        "The build directory {dirname} does not exist yet."
                        "Should I create it?".format(dirname=builddir), "no")

                if response:
                    mkdir("-p", builddir)
                    print("Created directory {0}.".format(builddir))

        actns = []
        for exp_name in self._experiment_names:
            if exp_name in exps:
                exp_cls = exps[exp_name]
                exp = exp_cls(project_names, group_name)
                eactn = Experiment(exp, exp.actions())
                actns.append(eactn)
            else:
                from logging import error
                error("Could not find {} in the experiment registry.",
                      exp_name)

        num_actions = sum([len(x) for x in actns])
        print("Number of actions to execute: {}".format(num_actions))
        for a in actns:
            print(a)
        print()

        if not self.pretend:
            for a in actns:
                a()