diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-07-18 16:34:56 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-07-18 17:29:59 +0100 |
commit | b068b7fa1331a7c6e2ef0632d9566310bfa58b9d (patch) | |
tree | a5ba4624e87860920059cc4a4b931c75a5b5d778 /morphlib/artifactresolver.py | |
parent | 0a1c41a539adee00cf4eefa81d4ab8841b65b10f (diff) | |
download | morph-b068b7fa1331a7c6e2ef0632d9566310bfa58b9d.tar.gz |
Have MorphologyFactory set Morphology.builds_artifacts
This way we can have one place in the code where we determine what
artifacts get built from a specific morphology, rather than spreading
the information around the code base.
From now on, everything is supposed to use the builds_artifacts attribute
to get the list of artifacts. ArtifactResolver has been changed to do that.
Some of the tests are now a bit messier, and should really be changed
to create Morphology objects using MorphologyFactory, but that's a change
for another day.
Diffstat (limited to 'morphlib/artifactresolver.py')
-rw-r--r-- | morphlib/artifactresolver.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py index 9a589adf..1b47a722 100644 --- a/morphlib/artifactresolver.py +++ b/morphlib/artifactresolver.py @@ -93,13 +93,9 @@ class ArtifactResolver(object): source = queue.popleft() if source.morphology['kind'] == 'system': - if source.morphology['arch'] == 'arm': - systems = [self._get_artifact( - source, source.morphology['name'] + name) - for name in ('-rootfs', '-kernel')] - else: - systems = [self._get_artifact( - source, source.morphology['name']+'-rootfs')] + systems = [self._get_artifact(source, a) + for a in source.morphology.builds_artifacts] + if any(a not in self._added_artifacts for a in systems): artifacts.extend(systems) @@ -113,8 +109,9 @@ class ArtifactResolver(object): artifacts.append(artifact) self._added_artifacts.add(artifact) elif source.morphology['kind'] == 'stratum': - artifact = self._get_artifact( - source, source.morphology['name']) + assert len(source.morphology.builds_artifacts) == 1 + artifact = self._get_artifact(source, + source.morphology.builds_artifacts[0]) if not artifact in self._added_artifacts: artifacts.append(artifact) @@ -128,7 +125,7 @@ class ArtifactResolver(object): artifacts.append(artifact) self._added_artifacts.add(artifact) elif source.morphology['kind'] == 'chunk': - names = self._chunk_artifact_names(source) + names = source.morphology.builds_artifacts for name in names: artifact = self._get_artifact(source, name) if not artifact in self._added_artifacts: @@ -207,7 +204,7 @@ class ArtifactResolver(object): info['ref'], '%s.morph' % info['morph']) - possible_names = self._chunk_artifact_names(chunk_source) + possible_names = chunk_source.morphology.builds_artifacts if not info['name'] in possible_names: raise UndefinedChunkArtifactError(stratum.source, info['name']) @@ -248,8 +245,3 @@ class ArtifactResolver(object): return artifacts - def _chunk_artifact_names(self, source): - if len(source.morphology['chunks']) > 0: - return sorted(source.morphology['chunks'].keys()) - else: - return [source.morphology['name']] |