implement new set to group all consumers of preserved libraries
authorMarius Mauch <genone@gentoo.org>
Thu, 11 Oct 2007 05:19:32 +0000 (05:19 -0000)
committerMarius Mauch <genone@gentoo.org>
Thu, 11 Oct 2007 05:19:32 +0000 (05:19 -0000)
svn path=/main/trunk/; revision=8044

pym/portage/sets/__init__.py
pym/portage/sets/dbapi.py

index c13c37252996d5ab23581c825c898fda31041359..124e6892443805e9b8020f05b94c4993b8dcb726 100644 (file)
@@ -263,9 +263,12 @@ def make_default_config(settings, trees):
        sc.set("config", "class", "portage.sets.files.ConfigFileSet")
        sc.set("config", "multiset", "true")
        
-       sc.add_section("user_sets")
-       sc.set("user_sets", "class", "portage.sets.files.StaticFileSet")
-       sc.set("user_sets", "multiset", "true")
+       sc.add_section("user-sets")
+       sc.set("user-sets", "class", "portage.sets.files.StaticFileSet")
+       sc.set("user-sets", "multiset", "true")
+
+       sc.add_section("rebuild-needed")
+       sc.set("rebuild-needed", "class", "portage.sets.dbapi.PreservedLibraryConsumerSet")
        
        return sc
 
index 164027943700d9dc9840c0c114b7caef679a2ec5..ed333ce005aa0d43aa5330df126f681304d8ca02 100644 (file)
@@ -2,8 +2,11 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-from portage.versions import catsplit
+from portage.versions import catsplit, catpkgsplit
 from portage.sets import PackageSet, SetConfigError
+from portage.dbapi.vartree import dblink
+
+import os
 
 __all__ = ["CategorySet", "EverythingSet"]
 
@@ -105,3 +108,33 @@ class CategorySet(PackageSet):
                        rValue[myname] = myset
                return rValue
        multiBuilder = classmethod(multiBuilder)
+
+class PreservedLibraryConsumerSet(PackageSet):
+       _operations = ["merge", "unmerge"]
+       
+       def __init__(self, vardbapi):
+               super(PreservedLibraryConsumerSet, self).__init__()
+               self.dbapi = vardbapi
+       
+       def load(self):
+               reg = self.dbapi.plib_registry
+               libmap = self.dbapi.libmap.get()
+               atoms = set()
+               consumers = set()
+               if reg:
+                       for libs in reg.getPreservedLibs().values():
+                               for lib in libs:
+                                       paths = libmap.get(os.path.basename(lib), [])
+                                       consumers.update(paths)
+               for cpv in self.dbapi.cpv_all():
+                       mysplit = catsplit(cpv)
+                       link = dblink(mysplit[0], mysplit[1], myroot=self.dbapi.root, \
+                                       mysettings=self.dbapi.settings, treetype='vartree', \
+                                       vartree=self.dbapi.vartree)
+                       if consumers.intersection(link.getcontents().keys()):
+                               atoms.add("/".join(catpkgsplit(cpv)[:2]))
+               self._setAtoms(atoms)
+
+       def singleBuilder(cls, options, settings, trees):
+               return PreservedLibraryConsumerSet(trees["vartree"].dbapi)
+       singleBuilder = classmethod(singleBuilder)