summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-10 17:57:51 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-10 17:57:51 +0000
commit82318e429057fa3e4f76f686a7e59fddf9a1becd (patch)
tree9b65059228b62c5f51370dc982a27dba0c4720e4
parent4088b8572629223e29ec3e439dcc9888c9c72a54 (diff)
downloadportage-82318e429057fa3e4f76f686a7e59fddf9a1becd.tar.gz
portage-82318e429057fa3e4f76f686a7e59fddf9a1becd.tar.bz2
portage-82318e429057fa3e4f76f686a7e59fddf9a1becd.zip
Implement expansion of catgories in DepcheckCompositeDB.match() for old
installed packages that may contain atoms that are not fully qualified. svn path=/main/trunk/; revision=9808
-rw-r--r--pym/_emerge/__init__.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index f99ba7bcd..c2f059889 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1456,6 +1456,9 @@ class DepcheckCompositeDB(object):
ret = self._match_cache.get(atom)
if ret is not None:
return ret[:]
+ orig_atom = atom
+ if "/" not in atom:
+ atom = self._dep_expand(atom)
pkg, existing = self._depgraph._select_package(self._root, atom)
if not pkg:
ret = []
@@ -1475,9 +1478,47 @@ class DepcheckCompositeDB(object):
if ret is None:
self._cpv_pkg_map[pkg.cpv] = pkg
ret = [pkg.cpv]
- self._match_cache[atom] = ret
+ self._match_cache[orig_atom] = ret
return ret[:]
+ def _dep_expand(self, atom):
+ """
+ This is only needed for old installed packages that may
+ contain atoms that are not fully qualified with a specific
+ category. Emulate the cpv_expand() function that's used by
+ dbapi.match() in cases like this. If there are multiple
+ matches, it's often due to a new-style virtual that has
+ been added, so try to filter those out to avoid raising
+ a ValueError.
+ """
+ root_config = self._depgraph.roots[self._root]
+ orig_atom = atom
+ expanded_atoms = self._depgraph._dep_expand(root_config, atom)
+ if len(expanded_atoms) > 1:
+ non_virtual_atoms = []
+ for x in expanded_atoms:
+ if not portage.dep_getkey(x).startswith("virtual/"):
+ non_virtual_atoms.append(x)
+ if len(non_virtual_atoms) == 1:
+ expanded_atoms = non_virtual_atoms
+ if len(expanded_atoms) > 1:
+ # compatible with portage.cpv_expand()
+ raise ValueError([portage.dep_getkey(x) \
+ for x in expanded_atoms])
+ if expanded_atoms:
+ atom = expanded_atoms[0]
+ else:
+ null_atom = insert_category_into_atom(atom, "null")
+ null_cp = portage.dep_getkey(null_atom)
+ cat, atom_pn = portage.catsplit(null_cp)
+ virts_p = root_config.settings.get_virts_p().get(atom_pn)
+ if virts_p:
+ # Allow the resolver to choose which virtual.
+ atom = insert_category_into_atom(atom, "virtual")
+ else:
+ atom = insert_category_into_atom(atom, "null")
+ return atom
+
def aux_get(self, cpv, wants):
metadata = self._cpv_pkg_map[cpv].metadata
return [metadata.get(x, "") for x in wants]