aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Ochotnicky <sochotnicky@gmail.com>2009-07-28 18:10:22 +0200
committerStanislav Ochotnicky <sochotnicky@gmail.com>2009-07-28 18:49:21 +0200
commita1e85d408b598824b70452bd0398accd441adc2b (patch)
tree42e98f7e186e90d4127c4b897139aa959de95d13 /src/tinderbox/__init__.py
parentAdded override for package generation (diff)
downloadcollagen-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/__init__.py')
-rw-r--r--src/tinderbox/__init__.py28
1 files changed, 28 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