Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11299 - in main/trunk: cnf doc/config pym/portage/sets
Date: Thu, 31 Jul 2008 12:47:21
Message-Id: E1KOXYs-0006c6-Ez@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-31 12:47:17 +0000 (Thu, 31 Jul 2008)
3 New Revision: 11299
4
5 Modified:
6 main/trunk/cnf/sets.conf
7 main/trunk/doc/config/sets.docbook
8 main/trunk/pym/portage/sets/dbapi.py
9 Log:
10 Bug #233253 - Implement a @downgrade set which selects packages for which
11 the highest visible ebuild version is lower than the currently installed
12 version. This is useful if you have installed packages from an overlay and
13 you want to downgrade to the highest visible after removing the overlay,
14 even though the packages that will be dowgraded are not necessarily masked
15 in any way.
16
17
18 Modified: main/trunk/cnf/sets.conf
19 ===================================================================
20 --- main/trunk/cnf/sets.conf 2008-07-31 11:44:28 UTC (rev 11298)
21 +++ main/trunk/cnf/sets.conf 2008-07-31 12:47:17 UTC (rev 11299)
22 @@ -53,3 +53,9 @@
23 class = portage.sets.dbapi.OwnerSet
24 world-candidate = False
25 files = /lib/modules
26 +
27 +# Installed packages for which the highest visible ebuild
28 +# version is lower than the currently installed version.
29 +[downgrade]
30 +class = portage.sets.dbapi.DowngradeSet
31 +world-candidate = False
32
33 Modified: main/trunk/doc/config/sets.docbook
34 ===================================================================
35 --- main/trunk/doc/config/sets.docbook 2008-07-31 11:44:28 UTC (rev 11298)
36 +++ main/trunk/doc/config/sets.docbook 2008-07-31 12:47:17 UTC (rev 11299)
37 @@ -479,6 +479,15 @@
38 </itemizedlist>
39 </para>
40 </sect2>
41 + <sect2 id='config-set-classes-DowngradeSet'>
42 + <title>portage.sets.dbapi.DowngradeSet</title>
43 + <para>
44 + Package set which contains all packages
45 + for which the highest visible ebuild version is lower than
46 + the currently installed version.
47 + This class doesn't support any extra options.
48 + </para>
49 + </sect2>
50 <sect2 id='config-set-classes-PreservedLibraryConsumerSet'>
51 <title>portage.sets.libs.PreservedLibraryConsumerSet</title>
52 <para>
53 @@ -518,6 +527,7 @@
54 <listitem><varname>preserved-rebuild</varname>: uses <classname>PreservedLibraryConsumerSet</classname></listitem>
55 <listitem><varname>live-rebuild</varname>: uses <classname>InheritSet</classname></listitem>
56 <listitem><varname>module-rebuild</varname>: uses <classname>OwnerSet</classname></listitem>
57 + <listitem><varname>downgrade</varname>: uses <classname>DowngradeSet</classname></listitem>
58 </itemizedlist>
59 Additionally the default configuration includes a multi set section based on
60 the <classname>StaticFileSet</classname> defaults that creates a set for each
61
62 Modified: main/trunk/pym/portage/sets/dbapi.py
63 ===================================================================
64 --- main/trunk/pym/portage/sets/dbapi.py 2008-07-31 11:44:28 UTC (rev 11298)
65 +++ main/trunk/pym/portage/sets/dbapi.py 2008-07-31 12:47:17 UTC (rev 11299)
66 @@ -2,7 +2,7 @@
67 # Distributed under the terms of the GNU General Public License v2
68 # $Id$
69
70 -from portage.versions import catpkgsplit, catsplit
71 +from portage.versions import catpkgsplit, catsplit, pkgcmp
72 from portage.sets.base import PackageSet
73 from portage.sets import SetConfigError, get_boolean
74
75 @@ -105,6 +105,44 @@
76
77 singleBuilder = classmethod(singleBuilder)
78
79 +class DowngradeSet(PackageSet):
80 +
81 + _operations = ["merge", "unmerge"]
82 +
83 + description = "Package set which contains all packages " + \
84 + "for which the highest visible ebuild version is lower than " + \
85 + "the currently installed version."
86 +
87 + def __init__(self, portdb=None, vardb=None):
88 + super(DowngradeSet, self).__init__()
89 + self._portdb = portdb
90 + self._vardb = vardb
91 +
92 + def load(self):
93 + atoms = []
94 + xmatch = self._portdb.xmatch
95 + xmatch_level = "bestmatch-visible"
96 + cp_list = self._vardb.cp_list
97 + aux_get = self._vardb.aux_get
98 + aux_keys = ["SLOT"]
99 + for cp in self._vardb.cp_all():
100 + for cpv in cp_list(cp):
101 + slot, = aux_get(cpv, aux_keys)
102 + slot_atom = "%s:%s" % (cp, slot)
103 + ebuild = xmatch(xmatch_level, slot_atom)
104 + ebuild_split = catpkgsplit(ebuild)[1:]
105 + installed_split = catpkgsplit(cpv)[1:]
106 + if pkgcmp(installed_split, ebuild_split) > 0:
107 + atoms.append(slot_atom)
108 +
109 + self._setAtoms(atoms)
110 +
111 + def singleBuilder(cls, options, settings, trees):
112 + return cls(portdb=trees["porttree"].dbapi,
113 + vardb=trees["vartree"].dbapi)
114 +
115 + singleBuilder = classmethod(singleBuilder)
116 +
117 class CategorySet(PackageSet):
118 _operations = ["merge", "unmerge"]