summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-07 01:31:13 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-07 01:31:13 -0700
commit8ba3e00107cae56cfb8acbc4d9e0f94d89acdfe8 (patch)
tree5734d1e116bd54e6d0335025397016dfcee7694c
parent6d96059e910ceae249dd492a93eab424d4827955 (diff)
downloadportage-8ba3e00107cae56cfb8acbc4d9e0f94d89acdfe8.tar.gz
portage-8ba3e00107cae56cfb8acbc4d9e0f94d89acdfe8.tar.bz2
portage-8ba3e00107cae56cfb8acbc4d9e0f94d89acdfe8.zip
Add support for a exclude-files option to OwnerSet, and use it to
implement a new @x11-module-rebuild set.
-rw-r--r--cnf/sets/portage.conf7
-rw-r--r--pym/portage/_sets/dbapi.py36
2 files changed, 35 insertions, 8 deletions
diff --git a/cnf/sets/portage.conf b/cnf/sets/portage.conf
index 800ac7cb8..34819fb22 100644
--- a/cnf/sets/portage.conf
+++ b/cnf/sets/portage.conf
@@ -58,6 +58,13 @@ includes = bzr cvs darcs git mercurial subversion tla
class = portage.sets.dbapi.OwnerSet
files = %(EROOT)slib/modules
+# Installed packages that own files inside /usr/lib/xorg/modules,
+# excluding the package that owns /usr/bin/Xorg.
+[x11-module-rebuild]
+class = portage.sets.dbapi.OwnerSet
+files = %(EROOT)susr/lib/xorg/modules
+exclude-files = %(EROOT)susr/bin/Xorg
+
# Binary packages that have a different build time from a currently
# installed package of the exact same version.
[rebuilt-binaries]
diff --git a/pym/portage/_sets/dbapi.py b/pym/portage/_sets/dbapi.py
index ce693c19c..9bbc6df3d 100644
--- a/pym/portage/_sets/dbapi.py
+++ b/pym/portage/_sets/dbapi.py
@@ -64,30 +64,50 @@ class OwnerSet(PackageSet):
description = "Package set which contains all packages " + \
"that own one or more files."
- def __init__(self, vardb=None, files=None):
+ def __init__(self, vardb=None, exclude_files=None, files=None):
super(OwnerSet, self).__init__()
self._db = vardb
+ self._exclude_files = exclude_files
self._files = files
- def mapPathsToAtoms(self, paths):
+ def mapPathsToAtoms(self, paths, exclude_paths=None):
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))
+ if exclude_paths is None:
+ 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))
+ else:
+ all_paths = set()
+ all_paths.update(paths)
+ all_paths.update(exclude_paths)
+ exclude_atoms = set()
+ for link, p in vardb._owners.iter_owners(all_paths):
+ cat, pn = catpkgsplit(link.mycpv)[:2]
+ slot, = aux_get(link.mycpv, aux_keys)
+ atom = "%s/%s:%s" % (cat, pn, slot)
+ rValue.add(atom)
+ if p in exclude_paths:
+ exclude_atoms.add(atom)
+ rValue.difference_update(exclude_atoms)
+
return rValue
def load(self):
- self._setAtoms(self.mapPathsToAtoms(self._files))
+ self._setAtoms(self.mapPathsToAtoms(self._files,
+ exclude_paths=self._exclude_files))
def singleBuilder(cls, options, settings, trees):
if not "files" in options:
raise SetConfigError(_("no files given"))
- return cls(vardb=trees["vartree"].dbapi,
+ exclude_files = options.get("exclude-files")
+ if exclude_files is not None:
+ exclude_files = frozenset(portage.util.shlex_split(exclude_files))
+ return cls(vardb=trees["vartree"].dbapi, exclude_files=exclude_files,
files=frozenset(portage.util.shlex_split(options["files"])))
singleBuilder = classmethod(singleBuilder)