From 6d96059e910ceae249dd492a93eab424d4827955 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 7 Sep 2010 00:59:04 -0700 Subject: [PATCH] Add a new package set called @unavailable-binaries which matches packages that are installed for which corresponding binary packages are not available. --- cnf/sets/portage.conf | 5 +++++ pym/portage/_sets/dbapi.py | 31 +++++++++++++++++++++++++++++++ pym/portage/dbapi/bintree.py | 5 +++++ 3 files changed, 41 insertions(+) diff --git a/cnf/sets/portage.conf b/cnf/sets/portage.conf index a21b587aa..800ac7cb8 100644 --- a/cnf/sets/portage.conf +++ b/cnf/sets/portage.conf @@ -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 diff --git a/pym/portage/_sets/dbapi.py b/pym/portage/_sets/dbapi.py index 362cc91c6..ce693c19c 100644 --- a/pym/portage/_sets/dbapi.py +++ b/pym/portage/_sets/dbapi.py @@ -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"] diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index dca683ee2..e24c2d0bf 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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) -- 2.26.2