diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-07-10 15:43:26 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-07-11 12:11:23 +0100 |
commit | c95302b925922ca0b900421fe9ecf7842d1949cc (patch) | |
tree | a11f2a4526d8466a6e689ff81ebdf52535a7e5cb /morphlib/morphologyfactory.py | |
parent | f653e5fc67c521668d07896ca164c5615c2f9dae (diff) | |
download | morph-c95302b925922ca0b900421fe9ecf7842d1949cc.tar.gz |
Move stratum verification to morphologyfactory
I think morphologies should be verified closer to where they are
created, not when they are traversed, since this verification would
be useful in more code paths.
This is in morphologyfactory, rather than Morphology itself, since
it may be useful to be able to create morphologies without checking,
such as in unit tests.
Diffstat (limited to 'morphlib/morphologyfactory.py')
-rw-r--r-- | morphlib/morphologyfactory.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index 6f9915fb..c84acd52 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -45,7 +45,18 @@ class MorphologyFactory(object): text = self._cat_text(reponame, sha1, filename) except: text = self._autodetect_text(reponame, sha1, filename) - return morphlib.morph2.Morphology(text) + + morphology = morphlib.morph2.Morphology(text) + if morphology['kind'] == 'stratum': #pragma: no cover + for source in morphology['sources']: + if source.get('build-depends', None) is None: + name = source.get('name', source.get('repo', 'unknown')) + raise morphlib.Error('No build dependencies ' + 'stratum %s for chunk %s ' + '(build-depends is a mandatory ' + 'field)' % + (filename, name)) + return morphology def _cat_text(self, reponame, sha1, filename): if self._lrc.has_repo(reponame): |