summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-08 08:36:34 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-08-08 15:22:50 +0000
commit2fbc0825bf6d716003f602fd1c410f2d02b27576 (patch)
tree171e26b82e68ed474a06d859200fb4989c2f57df
parent68f9fa2f0748540a27773160e1526600d7ee855b (diff)
downloadmorph-2fbc0825bf6d716003f602fd1c410f2d02b27576.tar.gz
morphloader: Change and add 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. Additionally, the default values for commands are changed to None rather than the empty list.
-rw-r--r--morphlib/morphloader.py45
-rw-r--r--morphlib/morphloader_tests.py36
2 files changed, 45 insertions, 36 deletions
diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py
index 21e10827..1729ddb2 100644
--- a/morphlib/morphloader.py
+++ b/morphlib/morphloader.py
@@ -338,22 +338,24 @@ 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',
},
'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):
diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py
index f4d2f9b6..e41f9c09 100644
--- a/morphlib/morphloader_tests.py
+++ b/morphlib/morphloader_tests.py
@@ -569,26 +569,28 @@ build-system: dummy
'name': 'foo',
'description': '',
'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': [],
'devices': [],
'max-jobs': None,
+ 'prefix': '/usr',
})
def test_unsets_defaults_for_chunks(self):
@@ -637,6 +639,7 @@ build-system: dummy
"morph": "bar",
'build-mode': 'bootstrap',
'build-depends': [],
+ 'prefix': '/usr',
},
],
'products': [],
@@ -650,8 +653,9 @@ build-system: dummy
{
'name': 'bar',
"ref": "bar",
- 'build-mode': 'bootstrap',
+ 'build-mode': 'staging',
'build-depends': [],
+ 'prefix': '/usr',
},
],
}
@@ -754,7 +758,7 @@ build-system: dummy
[{'morph': 'foo'},
{'morph': 'bar'}])
- def test_sets_stratum_chunks_repo_and_morph_from_name(self):
+ def test_sets_stratum_chunks_repo_from_name(self):
m = morphlib.morph3.Morphology(
{
"name": "foo",
@@ -771,9 +775,8 @@ build-system: dummy
self.loader.set_defaults(m)
self.loader.validate(m)
self.assertEqual(m['chunks'][0]['repo'], 'le-chunk')
- self.assertEqual(m['chunks'][0]['morph'], 'le-chunk')
- def test_collapses_stratum_chunks_repo_and_morph_from_name(self):
+ def test_collapses_stratum_chunks_repo_from_name(self):
m = morphlib.morph3.Morphology(
{
"name": "foo",
@@ -791,7 +794,6 @@ build-system: dummy
self.loader.unset_defaults(m)
self.assertTrue('repo' not in m['chunks'][0])
- self.assertTrue('morph' not in m['chunks'][0])
def test_convertes_max_jobs_to_an_integer(self):
m = morphlib.morph3.Morphology(