summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-15 06:13:03 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-15 06:13:03 +0000
commit9bae76041ef0cf61cda0ae8dbd331bb4a370c2f5 (patch)
treebb189819353bc97c2c48d55d15eb2456120645b6
parent2326c8e24628a026ab078713dff1810d08f2f0ac (diff)
downloadportage-9bae76041ef0cf61cda0ae8dbd331bb4a370c2f5.tar.gz
portage-9bae76041ef0cf61cda0ae8dbd331bb4a370c2f5.tar.bz2
portage-9bae76041ef0cf61cda0ae8dbd331bb4a370c2f5.zip
Add support to depgraph._select_atoms() to take a "parent" parameter
and use that to try and avoid unresolvable direct circular dependencies when necessary. Also, make atom selection more consistent with the graph to solve some cases of bug #1343. This improves the fix from bug #141118 to work in cases when a virtual is not yet installed but it has been pulled into the graph. For example, see the case of in Bug #163801#c17, where we want kaffe to satisfy virtual/jdk-1.4 without an extra jvm being pulled in unnecessarily. svn path=/main/trunk/; revision=9901
-rw-r--r--pym/_emerge/__init__.py9
-rw-r--r--pym/portage/__init__.py39
2 files changed, 45 insertions, 3 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index e6a8f3dc0..e5c9b0ca9 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1609,6 +1609,7 @@ class depgraph(object):
pass
filtered_tree.dbapi = self._dep_check_composite_db(self, myroot)
self._filtered_trees[myroot]["porttree"] = filtered_tree
+ self._filtered_trees[myroot]["graph_db"] = graph_tree.dbapi
# Passing in graph_tree as the vartree here could lead to better
# atom selections in some cases by causing atoms for packages that
@@ -2070,7 +2071,7 @@ class depgraph(object):
vardb = self.roots[dep_root].trees["vartree"].dbapi
try:
selected_atoms = self._select_atoms(dep_root,
- dep_string, myuse=myuse, strict=strict)
+ dep_string, myuse=myuse, parent=pkg, strict=strict)
except portage.exception.InvalidDependString, e:
show_invalid_depstring_notice(jbigkey, dep_string, str(e))
return 0
@@ -2528,7 +2529,7 @@ class depgraph(object):
return self._select_atoms_highest_available(*pargs, **kwargs)
def _select_atoms_highest_available(self, root, depstring,
- myuse=None, strict=True, trees=None):
+ myuse=None, parent=None, strict=True, trees=None):
"""This will raise InvalidDependString if necessary. If trees is
None then self._filtered_trees is used."""
pkgsettings = self.pkgsettings[root]
@@ -2536,12 +2537,16 @@ class depgraph(object):
trees = self._filtered_trees
if True:
try:
+ if parent is not None:
+ trees[root]["parent"] = parent
if not strict:
portage.dep._dep_check_strict = False
mycheck = portage.dep_check(depstring, None,
pkgsettings, myuse=myuse,
myroot=root, trees=trees)
finally:
+ if parent is not None:
+ trees[root].pop("parent")
portage.dep._dep_check_strict = True
if not mycheck[0]:
raise portage.exception.InvalidDependString(mycheck[1])
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index a20e40ecb..13ded0fea 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -5467,6 +5467,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
other = []
# Alias the trees we'll be checking availability against
+ parent = trees[myroot].get("parent")
+ graph_db = trees[myroot].get("graph_db")
vardb = None
if "vartree" in trees[myroot]:
vardb = trees[myroot]["vartree"].dbapi
@@ -5528,8 +5530,43 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
preferred.append(this_choice)
else:
preferred_any_slot.append(this_choice)
- else:
+ elif graph_db is None:
possible_upgrades.append(this_choice)
+ else:
+ all_in_graph = True
+ for slot_atom in versions:
+ # New-style virtuals have zero cost to install.
+ if not graph_db.match(slot_atom) and \
+ not slot_atom.startswith("virtual/"):
+ all_in_graph = False
+ break
+ if all_in_graph:
+ if parent is None:
+ preferred.append(this_choice)
+ else:
+ # Check if the atom would result in a direct circular
+ # dependency and try to avoid that if it seems likely
+ # to be unresolvable.
+ cpv_slot_list = [parent.cpv_slot]
+ circular_atom = None
+ for atom in atoms:
+ if "!" == atom[:1]:
+ continue
+ if vardb.match(atom):
+ # If the atom is satisfied by an installed
+ # version then it's not a circular dep.
+ continue
+ if dep_getkey(atom) != parent.cp:
+ continue
+ if match_from_list(atom, cpv_slot_list):
+ circular_atom = atom
+ break
+ if circular_atom is None:
+ preferred.append(this_choice)
+ else:
+ other.append(this_choice)
+ else:
+ possible_upgrades.append(this_choice)
else:
other.append(this_choice)