1 |
Author: zmedico |
2 |
Date: 2008-08-03 05:51:33 +0000 (Sun, 03 Aug 2008) |
3 |
New Revision: 11320 |
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 |
Add a more generic VariableSet to replace the InheritSet and RestrictSet |
11 |
classes. Thanks to Arfrever Frehtes Taifersar Arahesis for this patch from |
12 |
bug #233589 (with some minor adjustments from me). |
13 |
|
14 |
|
15 |
Modified: main/trunk/cnf/sets.conf |
16 |
=================================================================== |
17 |
--- main/trunk/cnf/sets.conf 2008-08-02 07:23:57 UTC (rev 11319) |
18 |
+++ main/trunk/cnf/sets.conf 2008-08-03 05:51:33 UTC (rev 11320) |
19 |
@@ -47,9 +47,10 @@ |
20 |
|
21 |
# Installed ebuilds that inherit from known live eclasses. |
22 |
[live-rebuild] |
23 |
-class = portage.sets.dbapi.InheritSet |
24 |
+class = portage.sets.dbapi.VariableSet |
25 |
world-candidate = False |
26 |
-inherits = cvs darcs git mercurial subversion |
27 |
+variable = INHERITED |
28 |
+includes = cvs darcs git mercurial subversion |
29 |
|
30 |
# Installed packages that own files inside /lib/modules. |
31 |
[module-rebuild] |
32 |
|
33 |
Modified: main/trunk/doc/config/sets.docbook |
34 |
=================================================================== |
35 |
--- main/trunk/doc/config/sets.docbook 2008-08-02 07:23:57 UTC (rev 11319) |
36 |
+++ main/trunk/doc/config/sets.docbook 2008-08-03 05:51:33 UTC (rev 11320) |
37 |
@@ -455,19 +455,6 @@ |
38 |
</para> |
39 |
</sect3> |
40 |
</sect2> |
41 |
- <sect2 id='config-set-classes-InheritSet'> |
42 |
- <title>portage.sets.dbapi.InheritSet</title> |
43 |
- <para> |
44 |
- Package set which contains all packages |
45 |
- that inherit one or more specific eclasses. |
46 |
- This class supports the following options: |
47 |
- <itemizedlist> |
48 |
- <listitem><varname>inherits</varname>: Required. A list of eclass names |
49 |
- which should be used to create the package set. |
50 |
- </listitem> |
51 |
- </itemizedlist> |
52 |
- </para> |
53 |
- </sect2> |
54 |
<sect2 id='config-set-classes-OwnerSet'> |
55 |
<title>portage.sets.dbapi.OwnerSet</title> |
56 |
<para> |
57 |
@@ -481,20 +468,23 @@ |
58 |
</itemizedlist> |
59 |
</para> |
60 |
</sect2> |
61 |
- <sect2 id='config-set-classes-RestrictSet'> |
62 |
- <title>portage.sets.dbapi.RestrictSet</title> |
63 |
+ <sect2 id='config-set-classes-VariableSet'> |
64 |
+ <title>portage.sets.dbapi.VariableSet</title> |
65 |
<para> |
66 |
Package set which contains all packages |
67 |
- that match specified RESTRICT values. |
68 |
+ that match specified values of specified variable. |
69 |
This class supports the following options: |
70 |
<itemizedlist> |
71 |
+ <listitem><varname>variable</varname>: The name of |
72 |
+ the specified variable whose values are checked. |
73 |
+ </listitem> |
74 |
<listitem><varname>includes</varname>: A list of |
75 |
- values that must be contained within the RESTRICT |
76 |
- metadata. |
77 |
+ values that must be contained within the specified |
78 |
+ variable. |
79 |
</listitem> |
80 |
<listitem><varname>excludes</varname>: A list of |
81 |
- values that must not be contained within the RESTRICT |
82 |
- metadata. |
83 |
+ values that must not be contained within the specified |
84 |
+ variable. |
85 |
</listitem> |
86 |
</itemizedlist> |
87 |
</para> |
88 |
@@ -545,7 +535,7 @@ |
89 |
<listitem><varname>security</varname>: uses <classname>NewAffectedSet</classname> with default options</listitem> |
90 |
<listitem><varname>everything</varname>: uses <classname>EverythingSet</classname></listitem> |
91 |
<listitem><varname>preserved-rebuild</varname>: uses <classname>PreservedLibraryConsumerSet</classname></listitem> |
92 |
- <listitem><varname>live-rebuild</varname>: uses <classname>InheritSet</classname></listitem> |
93 |
+ <listitem><varname>live-rebuild</varname>: uses <classname>VariableSet</classname></listitem> |
94 |
<listitem><varname>module-rebuild</varname>: uses <classname>OwnerSet</classname></listitem> |
95 |
<listitem><varname>downgrade</varname>: uses <classname>DowngradeSet</classname></listitem> |
96 |
</itemizedlist> |
97 |
|
98 |
Modified: main/trunk/pym/portage/sets/dbapi.py |
99 |
=================================================================== |
100 |
--- main/trunk/pym/portage/sets/dbapi.py 2008-08-02 07:23:57 UTC (rev 11319) |
101 |
+++ main/trunk/pym/portage/sets/dbapi.py 2008-08-03 05:51:33 UTC (rev 11320) |
102 |
@@ -8,7 +8,7 @@ |
103 |
from portage.sets import SetConfigError, get_boolean |
104 |
|
105 |
__all__ = ["CategorySet", "DowngradeSet", |
106 |
- "EverythingSet", "InheritSet", "OwnerSet", "RestrictSet"] |
107 |
+ "EverythingSet", "OwnerSet", "VariableSet"] |
108 |
|
109 |
class EverythingSet(PackageSet): |
110 |
_operations = ["merge", "unmerge"] |
111 |
@@ -89,63 +89,17 @@ |
112 |
|
113 |
singleBuilder = classmethod(singleBuilder) |
114 |
|
115 |
-class InheritSet(PackageSet): |
116 |
+class VariableSet(EverythingSet): |
117 |
|
118 |
_operations = ["merge", "unmerge"] |
119 |
|
120 |
description = "Package set which contains all packages " + \ |
121 |
- "that inherit one or more specific eclasses." |
122 |
+ "that match specified values of a specified variable." |
123 |
|
124 |
- def __init__(self, portdb=None, vardb=None, inherits=None): |
125 |
- super(InheritSet, self).__init__() |
126 |
+ def __init__(self, vardb, portdb=None, variable=None, includes=None, excludes=None): |
127 |
+ super(VariableSet, self).__init__(vardb) |
128 |
self._portdb = portdb |
129 |
- self._db = vardb |
130 |
- self._inherits = inherits |
131 |
- |
132 |
- def load(self): |
133 |
- atoms = [] |
134 |
- inherits = self._inherits |
135 |
- xmatch = self._portdb.xmatch |
136 |
- xmatch_level = "bestmatch-visible" |
137 |
- cp_list = self._db.cp_list |
138 |
- aux_get = self._db.aux_get |
139 |
- portdb_aux_get = self._portdb.aux_get |
140 |
- vardb_keys = ["SLOT"] |
141 |
- portdb_keys = ["INHERITED"] |
142 |
- for cp in self._db.cp_all(): |
143 |
- for cpv in cp_list(cp): |
144 |
- slot, = aux_get(cpv, vardb_keys) |
145 |
- slot_atom = "%s:%s" % (cp, slot) |
146 |
- ebuild = xmatch(xmatch_level, slot_atom) |
147 |
- if not ebuild: |
148 |
- continue |
149 |
- inherited, = portdb_aux_get(ebuild, portdb_keys) |
150 |
- if inherits.intersection(inherited.split()): |
151 |
- atoms.append(slot_atom) |
152 |
- |
153 |
- self._setAtoms(atoms) |
154 |
- |
155 |
- def singleBuilder(cls, options, settings, trees): |
156 |
- if not "inherits" in options: |
157 |
- raise SetConfigError("no inherits given") |
158 |
- |
159 |
- inherits = options["inherits"] |
160 |
- return cls(portdb=trees["porttree"].dbapi, |
161 |
- vardb=trees["vartree"].dbapi, |
162 |
- inherits=frozenset(inherits.split())) |
163 |
- |
164 |
- singleBuilder = classmethod(singleBuilder) |
165 |
- |
166 |
-class RestrictSet(EverythingSet): |
167 |
- |
168 |
- _operations = ["merge", "unmerge"] |
169 |
- |
170 |
- description = "Package set which contains all packages " + \ |
171 |
- "that match specified RESTRICT values." |
172 |
- |
173 |
- def __init__(self, vardb, portdb=None, includes=None, excludes=None): |
174 |
- super(RestrictSet, self).__init__(vardb) |
175 |
- self._portdb = portdb |
176 |
+ self._variable = variable |
177 |
self._includes = includes |
178 |
self._excludes = excludes |
179 |
|
180 |
@@ -153,16 +107,20 @@ |
181 |
ebuild = self._portdb.xmatch("bestmatch-visible", atom) |
182 |
if not ebuild: |
183 |
return False |
184 |
- restrict, = self._portdb.aux_get(ebuild, ["RESTRICT"]) |
185 |
- restrict = restrict.split() |
186 |
- if self._includes and not self._includes.intersection(restrict): |
187 |
+ values, = self._portdb.aux_get(ebuild, [self._variable]) |
188 |
+ values = values.split() |
189 |
+ if self._includes and not self._includes.intersection(values): |
190 |
return False |
191 |
- if self._excludes and self._excludes.intersection(restrict): |
192 |
+ if self._excludes and self._excludes.intersection(values): |
193 |
return False |
194 |
return True |
195 |
|
196 |
def singleBuilder(cls, options, settings, trees): |
197 |
|
198 |
+ variable = options.get("variable") |
199 |
+ if variable is None: |
200 |
+ raise SetConfigError("missing required attribute: 'variable'") |
201 |
+ |
202 |
includes = options.get("includes", "") |
203 |
excludes = options.get("excludes", "") |
204 |
|
205 |
@@ -172,7 +130,8 @@ |
206 |
return cls(trees["vartree"].dbapi, |
207 |
portdb=trees["porttree"].dbapi, |
208 |
excludes=frozenset(excludes.split()), |
209 |
- includes=frozenset(includes.split())) |
210 |
+ includes=frozenset(includes.split()), |
211 |
+ variable=variable) |
212 |
|
213 |
singleBuilder = classmethod(singleBuilder) |