diff options
author | Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> | 2014-08-15 17:28:04 +0000 |
---|---|---|
committer | Francisco Redondo Marchena <francisco.marchena@codethink.co.uk> | 2014-08-15 17:28:04 +0000 |
commit | 4cce5cfb5ec6b092bf6411cb2cd375aa40898882 (patch) | |
tree | 95eec90a7545b8d7e887966ce07298e7aaa442cb | |
parent | 00837372abc82209e1e71693b2e1eefc54718bbc (diff) | |
parent | dbc508a019a55b31bf4481225894aca8340747a2 (diff) | |
download | morph-4cce5cfb5ec6b092bf6411cb2cd375aa40898882.tar.gz |
Merge branch 'baserock/franred/fixes-needed-for-organize-definitions'
Reviewed by: Richard Maw <richard.maw@codethink.co.uk>
Merged by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-rw-r--r-- | morphlib/morphloader.py | 41 | ||||
-rw-r--r-- | morphlib/morphloader_tests.py | 25 |
2 files changed, 40 insertions, 26 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 05dcb62c..bc7ab6ef 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -255,6 +255,7 @@ class MorphologyDumper(yaml.SafeDumper): 'artifact', 'include', 'systems', + 'deploy-defaults', 'deploy', 'type', 'location', @@ -338,24 +339,25 @@ class MorphologyLoader(object): _static_defaults = { 'chunk': { 'description': '', - 'pre-configure-commands': [], - 'configure-commands': [], - 'post-configure-commands': [], - 'pre-build-commands': [], - 'build-commands': [], - 'post-build-commands': [], - 'pre-test-commands': [], - 'test-commands': [], - 'post-test-commands': [], - 'pre-install-commands': [], - 'install-commands': [], - 'post-install-commands': [], + 'pre-configure-commands': None, + 'configure-commands': None, + 'post-configure-commands': None, + 'pre-build-commands': None, + 'build-commands': None, + 'post-build-commands': None, + 'pre-test-commands': None, + 'test-commands': None, + 'post-test-commands': None, + 'pre-install-commands': None, + 'install-commands': None, + 'post-install-commands': None, 'devices': [], 'products': [], 'max-jobs': None, 'build-system': 'manual', 'build-mode': 'staging', 'prefix': '/usr', + 'system-integration': [], }, 'stratum': { 'chunks': [], @@ -690,8 +692,7 @@ class MorphologyLoader(object): if key in morphology and morphology[key] == defaults[key]: del morphology[key] - if kind in ('system', 'stratum', 'cluster'): - getattr(self, '_unset_%s_defaults' % kind)(morphology) + getattr(self, '_unset_%s_defaults' % kind)(morphology) @classmethod def _set_stratum_specs_defaults(cls, morphology, specs_field): @@ -755,6 +756,18 @@ class MorphologyLoader(object): if morph['max-jobs'] is not None: morph['max-jobs'] = int(morph['max-jobs']) + def _unset_chunk_defaults(self, morph): # pragma: no cover + for key in self._static_defaults['chunk']: + if key not in morph: continue + if 'commands' not in key: continue + attr = key.replace('-', '_') + default_bs = self._static_defaults['chunk']['build-system'] + bs = morphlib.buildsystem.lookup_build_system( + morph.get('build-system', default_bs)) + default_value = getattr(bs, attr) + if morph[key] == default_value: + del morph[key] + def set_commands(self, morph): if morph['kind'] == 'chunk': for key in self._static_defaults['chunk']: diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py index d47ec750..e783bfdb 100644 --- a/morphlib/morphloader_tests.py +++ b/morphlib/morphloader_tests.py @@ -571,23 +571,24 @@ build-system: dummy 'build-system': 'manual', 'build-mode': 'staging', - 'configure-commands': [], - 'pre-configure-commands': [], - 'post-configure-commands': [], + 'configure-commands': None, + 'pre-configure-commands': None, + 'post-configure-commands': None, - 'build-commands': [], - 'pre-build-commands': [], - 'post-build-commands': [], + 'build-commands': None, + 'pre-build-commands': None, + 'post-build-commands': None, - 'test-commands': [], - 'pre-test-commands': [], - 'post-test-commands': [], + 'test-commands': None, + 'pre-test-commands': None, + 'post-test-commands': None, - 'install-commands': [], - 'pre-install-commands': [], - 'post-install-commands': [], + 'install-commands': None, + 'pre-install-commands': None, + 'post-install-commands': None, 'products': [], + 'system-integration': [], 'devices': [], 'max-jobs': None, 'prefix': '/usr', |