summaryrefslogtreecommitdiff
path: root/morphlib/buildcommand.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-11 17:08:26 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-11 17:40:08 +0100
commitf610e488854611a24782a973f8615e75fe1ed6e4 (patch)
tree41c0fb5986b4d6191e4c90827147e858ef43a6d1 /morphlib/buildcommand.py
parent3107bc357e6214897ae99dc8ecb26cfe624ab5d9 (diff)
downloadmorph-f610e488854611a24782a973f8615e75fe1ed6e4.tar.gz
Validate that systems, strata reference correct kinds
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r--morphlib/buildcommand.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 34468f1a..aa6c7d0e 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -79,6 +79,10 @@ class BuildCommand(object):
self.app.status(msg='Creating source pool', chatty=True)
srcpool = self.app.create_source_pool(
self.lrc, self.rrc, (repo_name, ref, filename))
+
+ self.app.status(
+ msg='Validating cross-morphology references', chatty=True)
+ self._validate_cross_morphology_references(srcpool)
self.app.status(msg='Creating artifact resolver', chatty=True)
ar = morphlib.artifactresolver.ArtifactResolver()
@@ -96,6 +100,45 @@ class BuildCommand(object):
return order
+ def _validate_cross_morphology_references(self, srcpool):
+ for src in srcpool:
+ kind = src.morphology['kind']
+ method_name = '_validate_cross_refs_for_%s' % kind
+ if hasattr(self, method_name):
+ logging.debug('Calling %s' % method_name)
+ getattr(self, method_name)(src, srcpool)
+ else:
+ logging.warning('No %s' % method_name)
+
+ def _validate_cross_refs_for_system(self, src, srcpool):
+ self._validate_cross_refs_for_xxx(
+ src, srcpool, src.morphology['strata'], 'stratum')
+
+ def _validate_cross_refs_for_stratum(self, src, srcpool):
+ self._validate_cross_refs_for_xxx(
+ src, srcpool, src.morphology['chunks'], 'chunk')
+
+ def _validate_cross_refs_for_xxx(self, src, srcpool, specs, wanted):
+ for spec in specs:
+ repo_name = spec['repo']
+ ref = spec['ref']
+ filename = '%s.morph' % spec['morph']
+ logging.debug(
+ 'Validating cross ref to %s:%s:%s' %
+ (repo_name, ref, filename))
+ other = srcpool.lookup(repo_name, ref, filename)
+ if other.morphology['kind'] != wanted:
+ raise morphlib.Error(
+ '%s %s references %s:%s:%s which is a %s, '
+ 'instead of a %s' %
+ (src.morphology['kind'],
+ src.morphology['name'],
+ repo_name,
+ ref,
+ filename,
+ other.morphology['kind'],
+ wanted))
+
def build_in_order(self, order):
'''Build everything specified in a build order.'''
self.app.status(msg='Building according to build ordering',