summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-31 06:11:18 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-31 06:11:18 +0000
commitf342d9635b9da4ab09d7185900d8e5f470593734 (patch)
tree9e610b94029ac8f9e1d712be14b851fbf77fc163
parentImplement a new @live-ebuilds which is generated from installed packages (diff)
downloadportage-idfetch-f342d9635b9da4ab09d7185900d8e5f470593734.tar.gz
portage-idfetch-f342d9635b9da4ab09d7185900d8e5f470593734.tar.bz2
portage-idfetch-f342d9635b9da4ab09d7185900d8e5f470593734.zip
Add a new @module-rebuild set which emulates the behavior of the
module-rebuild tool. The /lib/modules path is set in sets.conf via a "files" attribute of an OwnerSet instance. This can be easily used to define similar sets based on paths on installed files. svn path=/main/trunk/; revision=11293
-rw-r--r--cnf/sets.conf6
-rw-r--r--pym/portage/sets/dbapi.py38
2 files changed, 43 insertions, 1 deletions
diff --git a/cnf/sets.conf b/cnf/sets.conf
index 13c09a36..9f08c50a 100644
--- a/cnf/sets.conf
+++ b/cnf/sets.conf
@@ -47,3 +47,9 @@ world-candidate = False
class = portage.sets.dbapi.InheritSet
world-candidate = False
inherits = "cvs darcs git mercurial subversion"
+
+# Installed packages that own files inside /lib/modules.
+[module-rebuild]
+class = portage.sets.dbapi.OwnerSet
+world-candidate = False
+files = /lib/modules
diff --git a/pym/portage/sets/dbapi.py b/pym/portage/sets/dbapi.py
index c31db554..66c01427 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 catsplit
+from portage.versions import catpkgsplit, catsplit
from portage.sets.base import PackageSet
from portage.sets import SetConfigError, get_boolean
@@ -32,6 +32,42 @@ class EverythingSet(PackageSet):
return EverythingSet(trees["vartree"].dbapi)
singleBuilder = classmethod(singleBuilder)
+class OwnerSet(PackageSet):
+
+ _operations = ["merge", "unmerge"]
+
+ description = "Package set which contains all packages " + \
+ "that own one or more files."
+
+ def __init__(self, vardb=None, files=None):
+ super(OwnerSet, self).__init__()
+ self._db = vardb
+ self._files = files
+
+ def mapPathsToAtoms(self, paths):
+ rValue = set()
+ vardb = self._db
+ aux_get = vardb.aux_get
+ aux_keys = ["SLOT"]
+ for link, p in vardb._owners.iter_owners(paths):
+ cat, pn = catpkgsplit(link.mycpv)[:2]
+ slot, = aux_get(link.mycpv, aux_keys)
+ rValue.add("%s/%s:%s" % (cat, pn, slot))
+ return rValue
+
+ def load(self):
+ self._setAtoms(self.mapPathsToAtoms(self._files))
+
+ def singleBuilder(cls, options, settings, trees):
+ if not "files" in options:
+ raise SetConfigError("no files given")
+
+ import shlex
+ return cls(vardb=trees["vartree"].dbapi,
+ files=frozenset(shlex.split(options["files"])))
+
+ singleBuilder = classmethod(singleBuilder)
+
class InheritSet(PackageSet):
_operations = ["merge", "unmerge"]