Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11293 - in main/trunk: cnf pym/portage/sets
Date: Thu, 31 Jul 2008 06:11:21
Message-Id: E1KORNe-0004Fs-WB@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-31 06:11:18 +0000 (Thu, 31 Jul 2008)
3 New Revision: 11293
4
5 Modified:
6 main/trunk/cnf/sets.conf
7 main/trunk/pym/portage/sets/dbapi.py
8 Log:
9 Add a new @module-rebuild set which emulates the behavior of the
10 module-rebuild tool. The /lib/modules path is set in sets.conf
11 via a "files" attribute of an OwnerSet instance. This can be easily
12 used to define similar sets based on paths on installed files.
13
14
15 Modified: main/trunk/cnf/sets.conf
16 ===================================================================
17 --- main/trunk/cnf/sets.conf 2008-07-31 05:45:56 UTC (rev 11292)
18 +++ main/trunk/cnf/sets.conf 2008-07-31 06:11:18 UTC (rev 11293)
19 @@ -47,3 +47,9 @@
20 class = portage.sets.dbapi.InheritSet
21 world-candidate = False
22 inherits = "cvs darcs git mercurial subversion"
23 +
24 +# Installed packages that own files inside /lib/modules.
25 +[module-rebuild]
26 +class = portage.sets.dbapi.OwnerSet
27 +world-candidate = False
28 +files = /lib/modules
29
30 Modified: main/trunk/pym/portage/sets/dbapi.py
31 ===================================================================
32 --- main/trunk/pym/portage/sets/dbapi.py 2008-07-31 05:45:56 UTC (rev 11292)
33 +++ main/trunk/pym/portage/sets/dbapi.py 2008-07-31 06:11:18 UTC (rev 11293)
34 @@ -2,7 +2,7 @@
35 # Distributed under the terms of the GNU General Public License v2
36 # $Id$
37
38 -from portage.versions import catsplit
39 +from portage.versions import catpkgsplit, catsplit
40 from portage.sets.base import PackageSet
41 from portage.sets import SetConfigError, get_boolean
42
43 @@ -32,6 +32,42 @@
44 return EverythingSet(trees["vartree"].dbapi)
45 singleBuilder = classmethod(singleBuilder)
46
47 +class OwnerSet(PackageSet):
48 +
49 + _operations = ["merge", "unmerge"]
50 +
51 + description = "Package set which contains all packages " + \
52 + "that own one or more files."
53 +
54 + def __init__(self, vardb=None, files=None):
55 + super(OwnerSet, self).__init__()
56 + self._db = vardb
57 + self._files = files
58 +
59 + def mapPathsToAtoms(self, paths):
60 + rValue = set()
61 + vardb = self._db
62 + aux_get = vardb.aux_get
63 + aux_keys = ["SLOT"]
64 + for link, p in vardb._owners.iter_owners(paths):
65 + cat, pn = catpkgsplit(link.mycpv)[:2]
66 + slot, = aux_get(link.mycpv, aux_keys)
67 + rValue.add("%s/%s:%s" % (cat, pn, slot))
68 + return rValue
69 +
70 + def load(self):
71 + self._setAtoms(self.mapPathsToAtoms(self._files))
72 +
73 + def singleBuilder(cls, options, settings, trees):
74 + if not "files" in options:
75 + raise SetConfigError("no files given")
76 +
77 + import shlex
78 + return cls(vardb=trees["vartree"].dbapi,
79 + files=frozenset(shlex.split(options["files"])))
80 +
81 + singleBuilder = classmethod(singleBuilder)
82 +
83 class InheritSet(PackageSet):
84
85 _operations = ["merge", "unmerge"]