From c95302b925922ca0b900421fe9ecf7842d1949cc Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 10 Jul 2012 15:43:26 +0000 Subject: 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. --- morphlib/morphologyfactory.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'morphlib/morphologyfactory.py') 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): -- cgit v1.2.1