def compile(self): with local.env(CC="gcc", CXX="g++"): emerge_in_chroot = uchroot.uchroot()["/usr/bin/emerge"] run.run(emerge_in_chroot["app-portage/portage-utils"]) run.run(emerge_in_chroot["app-portage/gentoolkit"]) qgrep_in_chroot = uchroot.uchroot()["/usr/bin/qgrep"] equery_in_chroot = uchroot.uchroot()["/usr/bin/equery"] ebuilds = set() languages = CFG["gentoo"]["autotest_lang"].value use_flags = CFG["gentoo"]["autotest_use"].value file_location = str(CFG["gentoo"]["autotest_loc"]) for language in languages: output = qgrep_in_chroot("-l", get_string_for_language(language)) for line in output.split('\n'): if "ebuild" in line: parts = line.split('.ebuild')[0].split('/') package_atom = '{0}/{1}'.format(parts[0], parts[1]) ebuilds.add(package_atom) for use in use_flags: output = equery_in_chroot("-q", "hasuse", "-p", use) ebuilds_use = set() for line in output.split('\n'): ebuilds_use.add(re.sub(r"(.*)-[0-9]+.*$", r"\1", line)) ebuilds = ebuilds.intersection(ebuilds_use) with open(file_location, "w") as output_file: for ebuild in sorted(ebuilds): output_file.write(str(ebuild) + "\n") output_file.flush()
def compile(self): emerge_in_chroot = uchroot.uchroot()["/usr/bin/emerge"] prog = self.DOMAIN + "/" + str(self.NAME)[len(self.DOMAIN) + 1:] with local.env(CONFIG_PROTECT="-*"): emerge_in_chroot("--autounmask-only=y", "--autounmask-write=y", prog, retcode=None) uchroot.uretry(emerge_in_chroot[prog])
def run(self, context): """Setup a gentoo container suitable for PolyJIT.""" # Don't do something when running non-interactive. if not sys.stdout.isatty(): return with local.cwd(context.in_container): from benchbuild.projects.gentoo import gentoo gentoo.setup_networking() gentoo.configure_portage() sed_in_chroot = uchroot.uchroot()["/bin/sed"] emerge_in_chroot = uchroot.uchroot()["/usr/bin/emerge"] has_pkg = uchroot.uchroot()["/usr/bin/qlist", "-I"] run.run(sed_in_chroot["-i", '/CC=/d', "/etc/portage/make.conf"]) run.run(sed_in_chroot["-i", '/CXX=/d', "/etc/portage/make.conf"]) want_sync = bool(CFG["container"]["strategy"]["polyjit"]["sync"]) want_upgrade = bool( CFG["container"]["strategy"]["polyjit"]["upgrade"]) packages = \ CFG["container"]["strategy"]["polyjit"]["packages"].value with local.env(MAKEOPTS="-j{0}".format(int(CFG["jobs"]))): if want_sync: LOG.debug("Synchronizing portage.") run.run(emerge_in_chroot["--sync"]) if want_upgrade: LOG.debug("Upgrading world.") run.run(emerge_in_chroot["--autounmask-only=y", "-uUDN", "--with-bdeps=y", "@world"]) for pkg in packages: if has_pkg[pkg["name"]] & TF: continue env = pkg["env"] with local.env(**env): run.run(emerge_in_chroot[pkg["name"]]) gentoo.setup_benchbuild() print("Packing new container image.") with local.cwd(context.builddir): pack_container(context.in_container, context.out_container)
def find_benchbuild(): try: uchrt = uchroot.clean_env(uchroot.uchroot(), ['HOME']) benchbuild_loc = uchrt("which", "benchbuild").strip() benchbuild = uchrt[benchbuild_loc] return benchbuild except ProcessExecutionError as err: LOG.error("Could not find Benchbuild inside container") LOG.debug("Reason: %s", str(err)) return None
def compile(self): emerge_in_chroot = uchroot.uchroot()["/usr/bin/emerge"] prog = self.DOMAIN + "/" + str(self.NAME)[len(self.DOMAIN) + 1:] with local.env(CONFIG_PROTECT="-*"): emerge_in_chroot( "--autounmask-only=y", "--autounmask-write=y", prog, retcode=None) uchroot.uretry(emerge_in_chroot[prog])
def __upgrade_from_source(venv_dir, with_deps=True): LOG.debug("Upgrading from source") uchrt_cmd = uchroot.clean_env(uchroot.uchroot(), ['HOME']) opts = ["--upgrade"] if not with_deps: opts.append("--no-deps") uchrt_cmd = uchrt_cmd[venv_dir / "bin" / "pip3", "install"] uchrt_cmd = uchrt_cmd[opts] uchrt_cmd = uchrt_cmd["/mnt/benchbuild"] uchroot.uretry(uchrt_cmd)
def wrap(name, project, sprefix=None, python=sys.executable): """ Wrap the binary :name: with the runtime extension of the project. This module generates a python tool that replaces :name: The function in runner only accepts the replaced binaries name as argument. We use the cloudpickle package to perform the serialization, make sure :runner: can be serialized with it and you're fine. Args: name: Binary we want to wrap project: The project that contains the runtime_extension we want to run instead of the binary. Returns: A plumbum command, ready to launch. """ env = __create_jinja_env() template = env.get_template('run_static.py.inc') name_absolute = os.path.abspath(name) real_f = name_absolute + PROJECT_BIN_F_EXT if sprefix: run(uchroot()["/bin/mv", strip_path_prefix(name_absolute, sprefix), strip_path_prefix(real_f, sprefix)]) else: run(mv[name_absolute, real_f]) project_file = persist(project, suffix=".project") env = CFG['env'].value bin_path = list_to_path(env.get('PATH', [])) bin_path = list_to_path([bin_path, os.environ["PATH"]]) bin_lib_path = list_to_path(env.get('LD_LIBRARY_PATH', [])) bin_lib_path = list_to_path([bin_lib_path, os.environ["LD_LIBRARY_PATH"]]) home = env.get("HOME", os.getenv("HOME", "")) with open(name_absolute, 'w') as wrapper: wrapper.write( template.render( runf=strip_path_prefix(real_f, sprefix), project_file=strip_path_prefix(project_file, sprefix), path=str(bin_path), ld_library_path=str(bin_lib_path), home=str(home), python=python, )) run(chmod["+x", name_absolute]) return local[name_absolute]
def wrap(name, project, sprefix=None, python=sys.executable): """ Wrap the binary :name: with the runtime extension of the project. This module generates a python tool that replaces :name: The function in runner only accepts the replaced binaries name as argument. We use the cloudpickle package to perform the serialization, make sure :runner: can be serialized with it and you're fine. Args: name: Binary we want to wrap project: The project that contains the runtime_extension we want to run instead of the binary. Returns: A plumbum command, ready to launch. """ env = __create_jinja_env() template = env.get_template('run_static.py.inc') name_absolute = os.path.abspath(name) real_f = name_absolute + PROJECT_BIN_F_EXT if sprefix: run(uchroot()["/bin/mv", strip_path_prefix(name_absolute, sprefix), strip_path_prefix(real_f, sprefix)]) else: run(mv[name_absolute, real_f]) project_file = persist(project, suffix=".project") env = CFG['env'].value bin_path = list_to_path(env.get('PATH', [])) bin_path = list_to_path([bin_path, os.environ["PATH"]]) bin_lib_path = list_to_path(env.get('LD_LIBRARY_PATH', [])) bin_lib_path = list_to_path([bin_lib_path, os.environ["LD_LIBRARY_PATH"]]) with open(name_absolute, 'w') as wrapper: wrapper.write( template.render( runf=strip_path_prefix(real_f, sprefix), project_file=strip_path_prefix(project_file, sprefix), path=str(bin_path), ld_library_path=str(bin_lib_path), python=python, )) run(chmod["+x", name_absolute]) return local[name_absolute]
def __upgrade_from_pip(venv_dir): LOG.debug("Upgrading from pip") uchrt_cmd = uchroot.clean_env(uchroot.uchroot(), ['HOME']) uchroot.uretry(uchrt_cmd[venv_dir / "bin" / "pip3", "install", "--upgrade", "benchbuild"])
def setup_virtualenv(_path="/benchbuild"): LOG.debug("Setting up Benchbuild virtualenv...") env = uchroot.uchroot()["/usr/bin/env"] env = env['-i', '--'] venv = env["/usr/bin/virtualenv"] venv = venv("-p", "/usr/bin/python3", _path)