From 95c5f93d554883fdedaeb3e111e1be9f88e0045c Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 8 Aug 2014 08:36:34 +0000 Subject: morphloader: Add and remove some default values This commit stops morphloader setting the `morph` field in chunk specs, and also makes it set defaults for the prefix and build-mode fields. Not setting the `morph` field is necessary as its presence in chunk specs is used by `traverse_morphs` to mean that the morphology file is in the definitions repository, not the chunk source repository. If we set a default value here, we end up looking for files which do not exist. --- morphlib/morphloader.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'morphlib/morphloader.py') diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 21e10827..0249bbae 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -354,6 +354,8 @@ class MorphologyLoader(object): 'products': [], 'max-jobs': None, 'build-system': 'manual', + 'build-mode': 'staging', + 'prefix': '/usr', }, 'stratum': { 'chunks': [], @@ -438,9 +440,6 @@ class MorphologyLoader(object): self._require_field('kind', morph) # The rest of the validation is dependent on the kind. - - # FIXME: move validation of clusters from morph2 to - # here, and use morphload to load the morphology kind = morph['kind'] if kind not in ('system', 'stratum', 'chunk', 'cluster'): raise UnknownKindError(morph['kind'], morph.filename) @@ -731,16 +730,24 @@ class MorphologyLoader(object): for spec in morph['chunks']: if 'repo' not in spec: spec['repo'] = spec['name'] - if 'morph' not in spec: - spec['morph'] = spec['name'] + if 'build-mode' not in spec: + spec['build-mode'] = \ + self._static_defaults['chunk']['build-mode'] + if 'prefix' not in spec: + spec['prefix'] = \ + self._static_defaults['chunk']['prefix'] self._set_stratum_specs_defaults(morph, 'build-depends') def _unset_stratum_defaults(self, morph): for spec in morph['chunks']: if 'repo' in spec and spec['repo'] == spec['name']: del spec['repo'] - if 'morph' in spec and spec['morph'] == spec['name']: - del spec['morph'] + if 'build-mode' in spec and spec['build-mode'] == \ + self._static_defaults['chunk']['build-mode']: + del spec['build-mode'] + if 'prefix' in spec and spec['prefix'] == \ + self._static_defaults['chunk']['prefix']: + del spec['prefix'] self._unset_stratum_specs_defaults(morph, 'strata') def _set_chunk_defaults(self, morph): -- cgit v1.2.1 From 9e35ea90a1f2c41c3808633e76930f86da6336e5 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 8 Aug 2014 07:59:02 +0000 Subject: morphloader: Get commands when loading morphology Rather than having a `get_commands` method to obtain missing commands from the build system when they are needed, get the commands when loading a morphology. --- morphlib/morphloader.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'morphlib/morphloader.py') diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 0249bbae..d06c06dc 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -406,6 +406,7 @@ class MorphologyLoader(object): m = self.parse_morphology_text(string, filename) m.filename = filename self.validate(m) + self.set_commands(m) self.set_defaults(m) return m @@ -754,3 +755,13 @@ class MorphologyLoader(object): if morph['max-jobs'] is not None: morph['max-jobs'] = int(morph['max-jobs']) + def set_commands(self, morph): + if morph['kind'] == 'chunk': + for key in self._static_defaults['chunk']: + if 'commands' not in key: continue + if key not in morph: + attr = '_'.join(key.split('-')) + default = self._static_defaults['chunk']['build-system'] + bs = morphlib.buildsystem.lookup_build_system( + morph.get('build-system', default)) + morph[key] = getattr(bs, attr) -- cgit v1.2.1 From 5f705f1e2c95b988ae39df7820f4034c49f375e4 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 8 Aug 2014 15:42:03 +0000 Subject: Rename morph3 to morphology Instead of leaving morph3 with a potentially confusing name, rename it to `morphology` since it is now the only implementation of the Morphology class. --- morphlib/morphloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'morphlib/morphloader.py') diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index d06c06dc..05dcb62c 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -394,7 +394,7 @@ class MorphologyLoader(object): if not isinstance(obj, dict): raise NotADictionaryError(morph_filename) - return morphlib.morph3.Morphology(obj) + return morphlib.morphology.Morphology(obj) def load_from_string(self, string, filename='string'): '''Load a morphology from a string. -- cgit v1.2.1