summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cnf/sets.conf5
-rw-r--r--doc/config/sets.docbook32
-rw-r--r--pym/portage/sets/dbapi.py73
3 files changed, 30 insertions, 80 deletions
diff --git a/cnf/sets.conf b/cnf/sets.conf
index b0e331b00..0825f70a1 100644
--- a/cnf/sets.conf
+++ b/cnf/sets.conf
@@ -47,9 +47,10 @@ world-candidate = False
# Installed ebuilds that inherit from known live eclasses.
[live-rebuild]
-class = portage.sets.dbapi.InheritSet
+class = portage.sets.dbapi.VariableSet
world-candidate = False
-inherits = cvs darcs git mercurial subversion
+variable = INHERITED
+includes = cvs darcs git mercurial subversion
# Installed packages that own files inside /lib/modules.
[module-rebuild]
diff --git a/doc/config/sets.docbook b/doc/config/sets.docbook
index 052ace0d4..14e171fb2 100644
--- a/doc/config/sets.docbook
+++ b/doc/config/sets.docbook
@@ -455,19 +455,6 @@
</para>
</sect3>
</sect2>
- <sect2 id='config-set-classes-InheritSet'>
- <title>portage.sets.dbapi.InheritSet</title>
- <para>
- Package set which contains all packages
- that inherit one or more specific eclasses.
- This class supports the following options:
- <itemizedlist>
- <listitem><varname>inherits</varname>: Required. A list of eclass names
- which should be used to create the package set.
- </listitem>
- </itemizedlist>
- </para>
- </sect2>
<sect2 id='config-set-classes-OwnerSet'>
<title>portage.sets.dbapi.OwnerSet</title>
<para>
@@ -481,20 +468,23 @@
</itemizedlist>
</para>
</sect2>
- <sect2 id='config-set-classes-RestrictSet'>
- <title>portage.sets.dbapi.RestrictSet</title>
+ <sect2 id='config-set-classes-VariableSet'>
+ <title>portage.sets.dbapi.VariableSet</title>
<para>
Package set which contains all packages
- that match specified RESTRICT values.
+ that match specified values of specified variable.
This class supports the following options:
<itemizedlist>
+ <listitem><varname>variable</varname>: The name of
+ the specified variable whose values are checked.
+ </listitem>
<listitem><varname>includes</varname>: A list of
- values that must be contained within the RESTRICT
- metadata.
+ values that must be contained within the specified
+ variable.
</listitem>
<listitem><varname>excludes</varname>: A list of
- values that must not be contained within the RESTRICT
- metadata.
+ values that must not be contained within the specified
+ variable.
</listitem>
</itemizedlist>
</para>
@@ -545,7 +535,7 @@
<listitem><varname>security</varname>: uses <classname>NewAffectedSet</classname> with default options</listitem>
<listitem><varname>everything</varname>: uses <classname>EverythingSet</classname></listitem>
<listitem><varname>preserved-rebuild</varname>: uses <classname>PreservedLibraryConsumerSet</classname></listitem>
- <listitem><varname>live-rebuild</varname>: uses <classname>InheritSet</classname></listitem>
+ <listitem><varname>live-rebuild</varname>: uses <classname>VariableSet</classname></listitem>
<listitem><varname>module-rebuild</varname>: uses <classname>OwnerSet</classname></listitem>
<listitem><varname>downgrade</varname>: uses <classname>DowngradeSet</classname></listitem>
</itemizedlist>
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py
index c4ac95498..2ddefb861 100644
--- a/pym/portage/sets/dbapi.py
+++ b/pym/portage/sets/dbapi.py
@@ -8,7 +8,7 @@ from portage.sets.base import PackageSet
from portage.sets import SetConfigError, get_boolean
__all__ = ["CategorySet", "DowngradeSet",
- "EverythingSet", "InheritSet", "OwnerSet", "RestrictSet"]
+ "EverythingSet", "OwnerSet", "VariableSet"]
class EverythingSet(PackageSet):
_operations = ["merge", "unmerge"]
@@ -89,63 +89,17 @@ class OwnerSet(PackageSet):
singleBuilder = classmethod(singleBuilder)
-class InheritSet(PackageSet):
+class VariableSet(EverythingSet):
_operations = ["merge", "unmerge"]
description = "Package set which contains all packages " + \
- "that inherit one or more specific eclasses."
+ "that match specified values of a specified variable."
- def __init__(self, portdb=None, vardb=None, inherits=None):
- super(InheritSet, self).__init__()
- self._portdb = portdb
- self._db = vardb
- self._inherits = inherits
-
- def load(self):
- atoms = []
- inherits = self._inherits
- xmatch = self._portdb.xmatch
- xmatch_level = "bestmatch-visible"
- cp_list = self._db.cp_list
- aux_get = self._db.aux_get
- portdb_aux_get = self._portdb.aux_get
- vardb_keys = ["SLOT"]
- portdb_keys = ["INHERITED"]
- for cp in self._db.cp_all():
- for cpv in cp_list(cp):
- slot, = aux_get(cpv, vardb_keys)
- slot_atom = "%s:%s" % (cp, slot)
- ebuild = xmatch(xmatch_level, slot_atom)
- if not ebuild:
- continue
- inherited, = portdb_aux_get(ebuild, portdb_keys)
- if inherits.intersection(inherited.split()):
- atoms.append(slot_atom)
-
- self._setAtoms(atoms)
-
- def singleBuilder(cls, options, settings, trees):
- if not "inherits" in options:
- raise SetConfigError("no inherits given")
-
- inherits = options["inherits"]
- return cls(portdb=trees["porttree"].dbapi,
- vardb=trees["vartree"].dbapi,
- inherits=frozenset(inherits.split()))
-
- singleBuilder = classmethod(singleBuilder)
-
-class RestrictSet(EverythingSet):
-
- _operations = ["merge", "unmerge"]
-
- description = "Package set which contains all packages " + \
- "that match specified RESTRICT values."
-
- def __init__(self, vardb, portdb=None, includes=None, excludes=None):
- super(RestrictSet, self).__init__(vardb)
+ def __init__(self, vardb, portdb=None, variable=None, includes=None, excludes=None):
+ super(VariableSet, self).__init__(vardb)
self._portdb = portdb
+ self._variable = variable
self._includes = includes
self._excludes = excludes
@@ -153,16 +107,20 @@ class RestrictSet(EverythingSet):
ebuild = self._portdb.xmatch("bestmatch-visible", atom)
if not ebuild:
return False
- restrict, = self._portdb.aux_get(ebuild, ["RESTRICT"])
- restrict = restrict.split()
- if self._includes and not self._includes.intersection(restrict):
+ values, = self._portdb.aux_get(ebuild, [self._variable])
+ values = values.split()
+ if self._includes and not self._includes.intersection(values):
return False
- if self._excludes and self._excludes.intersection(restrict):
+ if self._excludes and self._excludes.intersection(values):
return False
return True
def singleBuilder(cls, options, settings, trees):
+ variable = options.get("variable")
+ if variable is None:
+ raise SetConfigError("missing required attribute: 'variable'")
+
includes = options.get("includes", "")
excludes = options.get("excludes", "")
@@ -172,7 +130,8 @@ class RestrictSet(EverythingSet):
return cls(trees["vartree"].dbapi,
portdb=trees["porttree"].dbapi,
excludes=frozenset(excludes.split()),
- includes=frozenset(includes.split()))
+ includes=frozenset(includes.split()),
+ variable=variable)
singleBuilder = classmethod(singleBuilder)