def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, env=None, writemsg_level=None, vardbapi=None): """ Parse /etc/env.d and use it to generate /etc/profile.env, csh.env, ld.so.conf, and prelink.conf. Finally, run ldconfig. When ldconfig is called, its -X option will be used in order to avoid potential interference with installed soname symlinks that are required for correct operation of FEATURES=preserve-libs for downgrade operations. It's not necessary for ldconfig to create soname symlinks, since portage will use NEEDED.ELF.2 data to automatically create them after src_install if they happen to be missing. @param makelinks: True if ldconfig should be called, False otherwise @param target_root: root that is passed to the ldconfig -r option, defaults to portage.settings["ROOT"]. @type target_root: String (Path) """ settings = getattr(portage, 'settings', None) if settings is None: settings = config(config_root=target_root, target_root=target_root) if 'no-env-update' in settings.features: return if vardbapi is None: if isinstance(env, config): vardbapi = vartree(settings=env).dbapi else: if target_root is None: eprefix = portage.settings["EPREFIX"] target_root = portage.settings["ROOT"] target_eroot = portage.settings['EROOT'] else: eprefix = portage.const.EPREFIX target_eroot = os.path.join(target_root, eprefix.lstrip(os.sep)) target_eroot = target_eroot.rstrip(os.sep) + os.sep if hasattr(portage, "db") and target_eroot in portage.db: vardbapi = portage.db[target_eroot]["vartree"].dbapi else: settings = config(config_root=target_root, target_root=target_root, eprefix=eprefix) target_root = settings["ROOT"] if env is None: env = settings vardbapi = vartree(settings=settings).dbapi # Lock the config memory file to prevent symlink creation # in merge_contents from overlapping with env-update. vardbapi._fs_lock() try: return _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_level) finally: vardbapi._fs_unlock()
def __init__(self, debug=False, cb_enter=None, cb_done=None): self._publish_installed_packages = Gate().grants('gentoo', 'installed_packages') self._publish_installed_packages_use_flags = Gate().grants('gentoo', 'installed_packages_use_flags') self._publish_repos = Gate().grants('gentoo', 'repositories') self._cpv_flag_list = [] self._private_count = 0 self._private_use_flags = 0 self._non_private_use_flags = 0 if self._publish_installed_packages: var_tree = vartree() installed_cpvs = var_tree.getallcpv() # TODO upstream plans rename? self._total_count = len(installed_cpvs) i = 0 for cpv in sorted(installed_cpvs): i = i + 1 if cb_enter: cb_enter(cpv, i, self._total_count) entry = self._process(var_tree, cpv, debug=debug) if entry: self._cpv_flag_list.append(entry) else: self._private_count = self._private_count + 1 else: self._total_count = 0 if cb_done: cb_done()
def _load_config(self): env = { "ACCEPT_KEYWORDS": "x86", "PORTDIR": self.portdir, 'PORTAGE_TMPDIR' : os.path.join(self.eroot, 'var/tmp'), } # Pass along PORTAGE_USERNAME and PORTAGE_GRPNAME since they # need to be inherited by ebuild subprocesses. if 'PORTAGE_USERNAME' in os.environ: env['PORTAGE_USERNAME'] = os.environ['PORTAGE_USERNAME'] if 'PORTAGE_GRPNAME' in os.environ: env['PORTAGE_GRPNAME'] = os.environ['PORTAGE_GRPNAME'] settings = config(_eprefix=self.eprefix, env=env) settings.lock() trees = { self.root: { "vartree": vartree(settings=settings), "porttree": portagetree(self.root, settings=settings), "bintree": binarytree(self.root, os.path.join(self.eroot, "usr/portage/packages"), settings=settings) } } for root, root_trees in trees.items(): settings = root_trees["vartree"].settings settings._init_dirs() setconfig = load_default_config(settings, root_trees) root_trees["root_config"] = RootConfig(settings, root_trees, setconfig) return settings, trees
def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None, env=None, writemsg_level=None, vardbapi=None): """ Parse /etc/env.d and use it to generate /etc/profile.env, csh.env, ld.so.conf, and prelink.conf. Finally, run ldconfig. When ldconfig is called, its -X option will be used in order to avoid potential interference with installed soname symlinks that are required for correct operation of FEATURES=preserve-libs for downgrade operations. It's not necessary for ldconfig to create soname symlinks, since portage will use NEEDED.ELF.2 data to automatically create them after src_install if they happen to be missing. @param makelinks: True if ldconfig should be called, False otherwise @param target_root: root that is passed to the ldconfig -r option, defaults to portage.settings["ROOT"]. @type target_root: String (Path) """ if vardbapi is None: if isinstance(env, config): vardbapi = vartree(settings=env).dbapi else: if target_root is None: eprefix = portage.settings["EPREFIX"] target_root = portage.settings["ROOT"] target_eroot = portage.settings['EROOT'] else: eprefix = portage.const.EPREFIX target_eroot = os.path.join(target_root, eprefix.lstrip(os.sep)) target_eroot = target_eroot.rstrip(os.sep) + os.sep if hasattr(portage, "db") and target_eroot in portage.db: vardbapi = portage.db[target_eroot]["vartree"].dbapi else: settings = config(config_root=target_root, target_root=target_root, eprefix=eprefix) target_root = settings["ROOT"] if env is None: env = settings vardbapi = vartree(settings=settings).dbapi # Lock the config memory file to prevent symlink creation # in merge_contents from overlapping with env-update. vardbapi._fs_lock() try: return _env_update(makelinks, target_root, prev_mtimes, contents, env, writemsg_level) finally: vardbapi._fs_unlock()
def _load_config(self): env = { "ACCEPT_KEYWORDS": "x86", "PORTDIR": self.portdir, 'PORTAGE_TMPDIR': os.path.join(self.eroot, 'var/tmp'), } # Pass along PORTAGE_USERNAME and PORTAGE_GRPNAME since they # need to be inherited by ebuild subprocesses. if 'PORTAGE_USERNAME' in os.environ: env['PORTAGE_USERNAME'] = os.environ['PORTAGE_USERNAME'] if 'PORTAGE_GRPNAME' in os.environ: env['PORTAGE_GRPNAME'] = os.environ['PORTAGE_GRPNAME'] settings = config(_eprefix=self.eprefix, env=env) settings.lock() trees = { self.root: { "vartree": vartree(settings=settings), "porttree": portagetree(self.root, settings=settings), "bintree": binarytree(self.root, os.path.join(self.eroot, "usr/portage/packages"), settings=settings) } } for root, root_trees in trees.items(): settings = root_trees["vartree"].settings settings._init_dirs() setconfig = load_default_config(settings, root_trees) root_trees["root_config"] = RootConfig(settings, root_trees, setconfig) return settings, trees