Allow the depgraph to add old-style virtual providers but
authorZac Medico <zmedico@gentoo.org>
Sat, 20 Oct 2007 08:18:48 +0000 (08:18 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 20 Oct 2007 08:18:48 +0000 (08:18 -0000)
prefer any pre-existing providers over new ones that are
added.

svn path=/main/trunk/; revision=8187

pym/_emerge/__init__.py
pym/portage/__init__.py

index 000e74d9e32dc5ffdda5e3b5538fb9e043480e5f..9aaa7ee7c651f074343715b2ef8d6f1e075883dd 100644 (file)
@@ -1339,6 +1339,22 @@ class depgraph(object):
                                self.digraph.addnode(jbigkey, myparent,
                                        priority=priority)
 
+                       if mytype != "installed":
+                               # Allow this package to satisfy old-style virtuals in case it
+                               # doesn't already. Any pre-existing providers will be preferred
+                               # over this one.
+                               try:
+                                       pkgsettings.setinst(mykey, metadata)
+                                       # For consistency, also update the global virtuals.
+                                       settings = self.roots[myroot].settings
+                                       settings.unlock()
+                                       settings.setinst(mykey, metadata)
+                                       settings.lock()
+                               except portage.exception.InvalidDependString, e:
+                                       show_invalid_depstring_notice(jbigkey, metadata["PROVIDE"], str(e))
+                                       del e
+                                       return 0
+
                if arg:
                        self._set_nodes.add(jbigkey)
 
index cf56a5c4a62ac162facb76b5b9947aa77ae328e3..a18765240ee7f00e3f0d9cc29c1812781c9bcb6e 100644 (file)
@@ -899,6 +899,8 @@ class config(object):
                self.userVirtuals = {}
                # Virtual negatives from user specifications.
                self.negVirtuals  = {}
+               # Virtuals added by the depgraph via self.setinst().
+               self._depgraphVirtuals = {}
 
                self.user_profile_dir = None
                self.local_config = local_config
@@ -921,6 +923,7 @@ class config(object):
                        self.treeVirtuals = copy.deepcopy(clone.treeVirtuals)
                        self.userVirtuals = copy.deepcopy(clone.userVirtuals)
                        self.negVirtuals  = copy.deepcopy(clone.negVirtuals)
+                       self._depgraphVirtuals = copy.deepcopy(clone._depgraphVirtuals)
 
                        self.use_defs = copy.deepcopy(clone.use_defs)
                        self.usemask  = copy.deepcopy(clone.usemask)
@@ -2044,12 +2047,17 @@ class config(object):
                if len(self.virtuals) == 0:
                        self.getvirtuals()
                # Grab the virtuals this package provides and add them into the tree virtuals.
-               provides = mydbapi.aux_get(mycpv, ["PROVIDE"])[0]
+               if isinstance(mydbapi, dict):
+                       provides = mydbapi["PROVIDE"]
+               else:
+                       provides = mydbapi.aux_get(mycpv, ["PROVIDE"])[0]
                if not provides:
                        return
                if isinstance(mydbapi, portdbapi):
                        self.setcpv(mycpv, mydb=mydbapi)
                        myuse = self["USE"]
+               elif isinstance(mydbapi, dict):
+                       myuse = mydbapi["USE"]
                else:
                        myuse = mydbapi.aux_get(mycpv, ["USE"])[0]
                virts = flatten(portage.dep.use_reduce(portage.dep.paren_reduce(provides), uselist=myuse.split()))
@@ -2058,10 +2066,10 @@ class config(object):
                cp = dep_getkey(mycpv)
                for virt in virts:
                        virt = dep_getkey(virt)
-                       providers = self.treeVirtuals.get(virt)
+                       providers = self._depgraphVirtuals.get(virt)
                        if providers is None:
                                providers = []
-                               self.treeVirtuals[virt] = providers
+                               self._depgraphVirtuals[virt] = providers
                        if cp not in providers:
                                providers.append(cp)
                                modified = True
@@ -2395,7 +2403,7 @@ class config(object):
                                        ptVirtuals[virt].append(cp)
 
                virtuals = stack_dictlist([ptVirtuals, self.treeVirtuals,
-                       self.dirVirtuals])
+                       self.dirVirtuals, self._depgraphVirtuals])
                return virtuals
 
        def __delitem__(self,mykey):