Add a new package set called @unavailable-binaries which matches
authorZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 07:59:04 +0000 (00:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 07:59:04 +0000 (00:59 -0700)
packages that are installed for which corresponding binary packages
are not available.

cnf/sets/portage.conf
pym/portage/_sets/dbapi.py
pym/portage/dbapi/bintree.py

index a21b587aa17e2be34f0d91d005b73f772812e23f..800ac7cb8b690e58ed6ca38eb071c122811ccf3f 100644 (file)
@@ -72,3 +72,8 @@ class = portage.sets.dbapi.DowngradeSet
 # corresponding to the same $CATEGORY/$PN:$SLOT.
 [unavailable]
 class = portage.sets.dbapi.UnavailableSet
+
+# Installed packages for which corresponding binary packages
+# are not available.
+[unavailable-binaries]
+class = portage.sets.dbapi.UnavailableBinaries
index 362cc91c6cb9b839a6073b2c1154b958b97711e7..ce693c19c34af83c147c65f5e09a574f2a494c2c 100644 (file)
@@ -209,6 +209,37 @@ class UnavailableSet(EverythingSet):
 
        singleBuilder = classmethod(singleBuilder)
 
+class UnavailableBinaries(EverythingSet):
+
+       _operations = ('merge', 'unmerge',)
+
+       description = "Package set which contains all installed " + \
+               "packages for which corresponding binary packages " + \
+               "are not available."
+
+       def __init__(self, vardb, metadatadb=None):
+               super(UnavailableBinaries, self).__init__(vardb)
+               self._metadatadb = metadatadb
+
+       def _filter(self, atom):
+               inst_pkg = self._db.match(atom)
+               if not inst_pkg:
+                       return False
+               inst_cpv = inst_pkg[0]
+               return not self._metadatadb.cpv_exists(inst_cpv)
+
+       def singleBuilder(cls, options, settings, trees):
+
+               metadatadb = options.get("metadata-source", "bintree")
+               if not metadatadb in trees:
+                       raise SetConfigError(_("invalid value '%s' for option "
+                               "metadata-source") % (metadatadb,))
+
+               return cls(trees["vartree"].dbapi,
+                       metadatadb=trees[metadatadb].dbapi)
+
+       singleBuilder = classmethod(singleBuilder)
+
 class CategorySet(PackageSet):
        _operations = ["merge", "unmerge"]
        
index dca683ee223671dbfe465387506a928d941d0397..e24c2d0bf31df3640ccf7aa634054ccd9c556dcb 100644 (file)
@@ -64,6 +64,11 @@ class bindbapi(fakedbapi):
                        self.bintree.populate()
                return fakedbapi.match(self, *pargs, **kwargs)
 
+       def cpv_exists(self, cpv):
+               if self.bintree and not self.bintree.populated:
+                       self.bintree.populate()
+               return fakedbapi.cpv_exists(self, cpv)
+
        def cpv_inject(self, cpv, **kwargs):
                self._aux_cache.pop(cpv, None)
                fakedbapi.cpv_inject(self, cpv, **kwargs)