diff options
author | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-07-28 18:10:22 +0200 |
---|---|---|
committer | Stanislav Ochotnicky <sochotnicky@gmail.com> | 2009-07-28 18:49:21 +0200 |
commit | a1e85d408b598824b70452bd0398accd441adc2b (patch) | |
tree | 42e98f7e186e90d4127c4b897139aa959de95d13 /src/tinderbox | |
parent | Added override for package generation (diff) | |
download | collagen-a1e85d408b598824b70452bd0398accd441adc2b.tar.gz collagen-a1e85d408b598824b70452bd0398accd441adc2b.tar.bz2 collagen-a1e85d408b598824b70452bd0398accd441adc2b.zip |
Added handling for '||' groups of dependencies
it only picks first from the group of dependencies, but solves bug #15
also added simple unittest (not really simce I am not asserting anything,
just waiting for Exception to occur
Diffstat (limited to 'src/tinderbox')
-rw-r--r-- | src/tinderbox/__init__.py | 28 | ||||
-rw-r--r-- | src/tinderbox/test/TinderboxTest.py | 39 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/tinderbox/__init__.py b/src/tinderbox/__init__.py index ab88c4e..87fb515 100644 --- a/src/tinderbox/__init__.py +++ b/src/tinderbox/__init__.py @@ -85,6 +85,8 @@ class Tinderbox(object): # only count deps enabled by USE flags use_deps = portage.dep.use_reduce(deps, list(use_enabled & iuse)) + use_deps = self._normalize_dependencies(use_deps) + use_deps = flatten_deps(use_deps) dep_groups = self.create_dep_groups(use_deps) @@ -308,6 +310,32 @@ class Tinderbox(object): return string.join(infoout.content,sep='') + def _normalize_dependencies(self, deps): + """ + Normalizes dependencies by replacing '||' by with alternative + + @param deps: depedencies (list of package atoms) + @type deps: List + @rtype: List + @returns: Normalized list of package atoms with replaced || groups + + Example: + >>> from tinderbox import Tinderbox as tb + >>> t = tb() + >>> t._normalize_dependencies(['||', ['=virtual/jdk-1.5*', '=virtual/jdk-1.4*'], 'app-arch/unzip']) + ['=virtual/jdk-1.5*', 'app-arch/unzip'] + >>> + """ + new_deps = [] + for i in range(len(deps)): + if deps[i] == '||': + next = deps[i+1] + if type(next) is list and len(next) > i: + deps[i+1] = next[0] + else: + new_deps.append(deps[i]) + return new_deps + def create_dep_groups(self, deps): """ Create dependency groups from package dependencies diff --git a/src/tinderbox/test/TinderboxTest.py b/src/tinderbox/test/TinderboxTest.py new file mode 100644 index 0000000..17ce0da --- /dev/null +++ b/src/tinderbox/test/TinderboxTest.py @@ -0,0 +1,39 @@ +import sys +sys.path.append("../..") +from tinderbox import Tinderbox + +import unittest +import portage +from util import flatten_deps + +class TinderboxTest(unittest.TestCase): + + def setUp(self): + self.tb = Tinderbox() + self.trees = portage.create_trees() + self.portapi = self.trees[portage.root]["porttree"].dbapi + self.portset = portage.config(clone=portage.settings) + + def testCreateDepGroups(self): + settings = self.portset + portapi = self.portapi + pkg = 'dev-db/hsqldb-1.8.0.9-r1' + + deps = portapi.aux_get(pkg, ["DEPEND"]) + deps = portage.dep.paren_reduce(deps[0]) + settings.setcpv(pkg, mydb=self.portapi) + use_enabled = set(settings["PORTAGE_USE"].split()) + iuse = set(settings["IUSE"].split()) + use_deps = portage.dep.use_reduce(deps, list(use_enabled & iuse)) + + + use_deps = self.tb._normalize_dependencies(use_deps) + + use_deps = flatten_deps(use_deps) + self.tb.create_dep_groups(use_deps) + + + + +if __name__ == '__main__': + unittest.main() |