From: Zac Medico Date: Sat, 20 Oct 2007 08:18:48 +0000 (-0000) Subject: Allow the depgraph to add old-style virtual providers but X-Git-Tag: v2.2_pre1~584 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ed6c09b010c621b1edaeb8a234952aafcfe34c99;p=portage.git Allow the depgraph to add old-style virtual providers but prefer any pre-existing providers over new ones that are added. svn path=/main/trunk/; revision=8187 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 000e74d9e..9aaa7ee7c 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -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) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index cf56a5c4a..a18765240 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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):