summaryrefslogtreecommitdiff
path: root/morphlib
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-14 13:28:50 +0000
commit95c5f93d554883fdedaeb3e111e1be9f88e0045c (patch)
tree27891ef793481fdea9cfa6dbf94c907309bb1a18 /morphlib
parente15c4fd713ee4222ebd0a0c1740e6fb91e15cbad (diff)
downloadmorph-95c5f93d554883fdedaeb3e111e1be9f88e0045c.tar.gz
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.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/morphloader.py21
-rw-r--r--morphlib/morphloader_tests.py12
2 files changed, 21 insertions, 12 deletions
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):
diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py
index f4d2f9b6..738f1c32 100644
--- a/morphlib/morphloader_tests.py
+++ b/morphlib/morphloader_tests.py
@@ -569,6 +569,7 @@ build-system: dummy
'name': 'foo',
'description': '',
'build-system': 'manual',
+ 'build-mode': 'staging',
'configure-commands': [],
'pre-configure-commands': [],
@@ -589,6 +590,7 @@ build-system: dummy
'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(