summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-31 12:47:17 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-31 12:47:17 +0000
commite1c9b13944cc3c74bd6e0b98b0f98c08c270b307 (patch)
tree7e39e2d23067fbd81e430584e1d54a0912813e70
parentAlways invalidate results from _userpriv_test_write_file_cache when (diff)
downloadportage-idfetch-e1c9b13944cc3c74bd6e0b98b0f98c08c270b307.tar.gz
portage-idfetch-e1c9b13944cc3c74bd6e0b98b0f98c08c270b307.tar.bz2
portage-idfetch-e1c9b13944cc3c74bd6e0b98b0f98c08c270b307.zip
Bug #233253 - Implement a @downgrade set which selects packages for which
the highest visible ebuild version is lower than the currently installed version. This is useful if you have installed packages from an overlay and you want to downgrade to the highest visible after removing the overlay, even though the packages that will be dowgraded are not necessarily masked in any way. svn path=/main/trunk/; revision=11299
-rw-r--r--cnf/sets.conf6
-rw-r--r--doc/config/sets.docbook10
-rw-r--r--pym/portage/sets/dbapi.py40
3 files changed, 55 insertions, 1 deletions
diff --git a/cnf/sets.conf b/cnf/sets.conf
index eda003f4..b3dc132f 100644
--- a/cnf/sets.conf
+++ b/cnf/sets.conf
@@ -53,3 +53,9 @@ inherits = cvs darcs git mercurial subversion
class = portage.sets.dbapi.OwnerSet
world-candidate = False
files = /lib/modules
+
+# Installed packages for which the highest visible ebuild
+# version is lower than the currently installed version.
+[downgrade]
+class = portage.sets.dbapi.DowngradeSet
+world-candidate = False
diff --git a/doc/config/sets.docbook b/doc/config/sets.docbook
index 16fe5410..7cccbbc9 100644
--- a/doc/config/sets.docbook
+++ b/doc/config/sets.docbook
@@ -479,6 +479,15 @@
</itemizedlist>
</para>
</sect2>
+ <sect2 id='config-set-classes-DowngradeSet'>
+ <title>portage.sets.dbapi.DowngradeSet</title>
+ <para>
+ Package set which contains all packages
+ for which the highest visible ebuild version is lower than
+ the currently installed version.
+ This class doesn't support any extra options.
+ </para>
+ </sect2>
<sect2 id='config-set-classes-PreservedLibraryConsumerSet'>
<title>portage.sets.libs.PreservedLibraryConsumerSet</title>
<para>
@@ -518,6 +527,7 @@
<listitem><varname>preserved-rebuild</varname>: uses <classname>PreservedLibraryConsumerSet</classname></listitem>
<listitem><varname>live-rebuild</varname>: uses <classname>InheritSet</classname></listitem>
<listitem><varname>module-rebuild</varname>: uses <classname>OwnerSet</classname></listitem>
+ <listitem><varname>downgrade</varname>: uses <classname>DowngradeSet</classname></listitem>
</itemizedlist>
Additionally the default configuration includes a multi set section based on
the <classname>StaticFileSet</classname> defaults that creates a set for each
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py
index 66c01427..28632f43 100644
--- a/pym/portage/sets/dbapi.py
+++ b/pym/portage/sets/dbapi.py
@@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-from portage.versions import catpkgsplit, catsplit
+from portage.versions import catpkgsplit, catsplit, pkgcmp
from portage.sets.base import PackageSet
from portage.sets import SetConfigError, get_boolean
@@ -105,6 +105,44 @@ class InheritSet(PackageSet):
singleBuilder = classmethod(singleBuilder)
+class DowngradeSet(PackageSet):
+
+ _operations = ["merge", "unmerge"]
+
+ description = "Package set which contains all packages " + \
+ "for which the highest visible ebuild version is lower than " + \
+ "the currently installed version."
+
+ def __init__(self, portdb=None, vardb=None):
+ super(DowngradeSet, self).__init__()
+ self._portdb = portdb
+ self._vardb = vardb
+
+ def load(self):
+ atoms = []
+ xmatch = self._portdb.xmatch
+ xmatch_level = "bestmatch-visible"
+ cp_list = self._vardb.cp_list
+ aux_get = self._vardb.aux_get
+ aux_keys = ["SLOT"]
+ for cp in self._vardb.cp_all():
+ for cpv in cp_list(cp):
+ slot, = aux_get(cpv, aux_keys)
+ slot_atom = "%s:%s" % (cp, slot)
+ ebuild = xmatch(xmatch_level, slot_atom)
+ ebuild_split = catpkgsplit(ebuild)[1:]
+ installed_split = catpkgsplit(cpv)[1:]
+ if pkgcmp(installed_split, ebuild_split) > 0:
+ atoms.append(slot_atom)
+
+ self._setAtoms(atoms)
+
+ def singleBuilder(cls, options, settings, trees):
+ return cls(portdb=trees["porttree"].dbapi,
+ vardb=trees["vartree"].dbapi)
+
+ singleBuilder = classmethod(singleBuilder)
+
class CategorySet(PackageSet):
_operations = ["merge", "unmerge"]