summaryrefslogtreecommitdiff
path: root/morphlib/morphloader.py
diff options
context:
space:
mode:
authorAdam Coldrick <adam@sotk.co.uk>2015-05-06 20:43:13 +0000
committerBaserock Gerrit <gerrit@baserock.org>2015-05-08 08:09:52 +0000
commitf9a0607b654ee1adb85f4c1bfedd3571a22ac21a (patch)
tree1d8b32ed5793f71c090883b9fa9c97a410f6ca11 /morphlib/morphloader.py
parent4c0d2a9f9c3b71345d1a59a403c81d2795917a75 (diff)
downloadmorph-f9a0607b654ee1adb85f4c1bfedd3571a22ac21a.tar.gz
Raise an error if a stratum build-depends on itself
If a stratum build-depends on itself, the build graph calculation gets stuck in an infinite loop as it adds the same stratum to the queue of morphologies to inspect over and over again. This commit causes MorphologyLoader.validate_stratum to raise an error if a stratum contains itself in it's build-depends, as depending on itself makes no sense and will cause the above problem. Change-Id: I76df5b7d63d010ae3b17f72bfa39b273e74279dd
Diffstat (limited to 'morphlib/morphloader.py')
-rw-r--r--morphlib/morphloader.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py
index 47cb03d7..0c69baac 100644
--- a/morphlib/morphloader.py
+++ b/morphlib/morphloader.py
@@ -195,6 +195,14 @@ class EmptySystemError(MorphologyValidationError):
self, 'System %(system_name)s has no strata.' % locals())
+class DependsOnSelfError(MorphologyValidationError):
+
+ def __init__(self, name, filename):
+ msg = ("Stratum %(name)s build-depends on itself (%(filename)s)"
+ % locals())
+ MorphologyValidationError.__init__(self, msg)
+
+
class MultipleValidationErrors(MorphologyValidationError):
def __init__(self, name, errors):
@@ -536,6 +544,9 @@ class MorphologyLoader(object):
raise InvalidTypeError(
'build-depends', list, type(morph['build-depends']),
morph['name'])
+ for dep in morph['build-depends']:
+ if dep['morph'] == morph.filename:
+ raise DependsOnSelfError(morph['name'], morph.filename)
else:
for spec in morph['chunks']:
if spec.get('build-mode') in ['bootstrap', 'test']: