From 1e35d5d8eb2d08674ea76b59a6e09d738d25eb42 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 1 Jan 2013 18:42:18 -0800 Subject: [PATCH] FakeVartree: split _apply_dynamic_deps method This will eventually be used for parallelization of aux_get/regen processes. --- pym/_emerge/FakeVartree.py | 65 +++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py index a0a506e36..31ff65c2b 100644 --- a/pym/_emerge/FakeVartree.py +++ b/pym/_emerge/FakeVartree.py @@ -33,6 +33,9 @@ class FakeVardbapi(PackageVirtualDbapi): path =os.path.join(path, filename) return path +class _DynamicDepsNotApplicable(Exception): + pass + class FakeVartree(vartree): """This is implements an in-memory copy of a vartree instance that provides all the interfaces required for use by the depgraph. The vardb is locked @@ -102,28 +105,30 @@ class FakeVartree(vartree): self._aux_get_wrapper(cpv, []) return matches - def _aux_get_wrapper(self, pkg, wants, myrepo=None): - if pkg in self._aux_get_history: - return self._aux_get(pkg, wants) - self._aux_get_history.add(pkg) - # We need to check the EAPI, and this also raises - # a KeyError to the caller if appropriate. - pkg_obj = self.dbapi._cpv_map[pkg] - installed_eapi = pkg_obj.eapi - eapi_attrs = _get_eapi_attrs(installed_eapi) - built_slot_operator_atoms = None - - if eapi_attrs.slot_operator and not self._ignore_built_slot_operator_deps: - try: - built_slot_operator_atoms = find_built_slot_operator_atoms(pkg_obj) - except InvalidDependString: - pass + def _aux_get_wrapper(self, cpv, wants, myrepo=None): + if cpv in self._aux_get_history: + return self._aux_get(cpv, wants) + self._aux_get_history.add(cpv) + + # This raises a KeyError to the caller if appropriate. + pkg = self.dbapi._cpv_map[cpv] try: - # Use the live ebuild metadata if possible. live_metadata = dict(zip(self._portdb_keys, - self._portdb.aux_get(pkg, self._portdb_keys, - myrepo=pkg_obj.repo))) + self._portdb.aux_get(cpv, self._portdb_keys, + myrepo=pkg.repo))) + except (KeyError, portage.exception.PortageException): + live_metadata = None + + self._apply_dynamic_deps(pkg, live_metadata) + + return self._aux_get(cpv, wants) + + def _apply_dynamic_deps(self, pkg, live_metadata): + + try: + if live_metadata is None: + raise _DynamicDepsNotApplicable() # Use the metadata from the installed instance if the EAPI # of either instance is unsupported, since if the installed # instance has an unsupported or corrupt EAPI then we don't @@ -133,26 +138,34 @@ class FakeVartree(vartree): # order to respect dep updates without revision bump or EAPI # bump, as in bug #368725. if not (portage.eapi_is_supported(live_metadata["EAPI"]) and \ - portage.eapi_is_supported(installed_eapi)): - raise KeyError(pkg) + portage.eapi_is_supported(pkg.eapi)): + raise _DynamicDepsNotApplicable() # preserve built slot/sub-slot := operator deps + built_slot_operator_atoms = None + if not self._ignore_built_slot_operator_deps and \ + _get_eapi_attrs(pkg.eapi).slot_operator: + try: + built_slot_operator_atoms = \ + find_built_slot_operator_atoms(pkg) + except InvalidDependString: + pass + if built_slot_operator_atoms: live_eapi_attrs = _get_eapi_attrs(live_metadata["EAPI"]) if not live_eapi_attrs.slot_operator: - raise KeyError(pkg) + raise _DynamicDepsNotApplicable() for k, v in built_slot_operator_atoms.items(): live_metadata[k] += (" " + " ".join(_unicode(atom) for atom in v)) - self.dbapi.aux_update(pkg, live_metadata) - except (KeyError, portage.exception.PortageException): + self.dbapi.aux_update(pkg.cpv, live_metadata) + except _DynamicDepsNotApplicable: if self._global_updates is None: self._global_updates = \ grab_global_updates(self._portdb) perform_global_updates( - pkg, self.dbapi, self._global_updates) - return self._aux_get(pkg, wants) + pkg.cpv, self.dbapi, self._global_updates) def cpv_discard(self, pkg): """ -- 2.26.2