diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-05-05 12:14:46 +0000 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-05-12 12:25:57 +0000 |
commit | 2d19611ace78aec071607fafd0e2798412cc4286 (patch) | |
tree | c9370d7e1b4b334fdc90118581f74e7db43d610b /morphlib | |
parent | 1c45305237674b71bfe3c896a9a14238d30ac9aa (diff) | |
download | morph-2d19611ace78aec071607fafd0e2798412cc4286.tar.gz |
Move duplicate fix_chunk_build_mode function to a common location
Change-Id: I11b4dbeb50d67068701f269ef6ac7cfbd89f6aed
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/plugins/deploy_plugin.py | 28 | ||||
-rw-r--r-- | morphlib/plugins/system_manifests_plugin.py | 29 | ||||
-rw-r--r-- | morphlib/util.py | 28 |
3 files changed, 33 insertions, 52 deletions
diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 0e4f32f9..c8e8959f 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -648,31 +648,6 @@ class DeployPlugin(cliapp.Plugin): msg='System unpacked at %(system_tree)s', system_tree=path) - def fix_chunk_build_mode(self, artifact): - """Give each chunk's in-memory morpholgy the correct build-mode. - - Currently, our definitions define build-mode in the entries in the - chunk list in a given stratum. However, morph expects it to be in - the chunk morphology when loading, and sets the in-memory - build-mode to 'staging' by default. - - """ - # This should probably be fixed in morphloader, but I held off on - # doing that following a discussion on #baserock. - # - # https://irclogs.baserock.org/%23baserock.2015-04-21.log.html - # (at 9:02) - strata = set(a for a in artifact.walk() - if a.source.morphology['kind'] == 'stratum') - chunks = set(a for a in artifact.walk() - if a.source.morphology['kind'] == 'chunk') - for chunk in chunks: - for stratum in strata: - for spec in stratum.source.morphology['chunks']: - if chunk.source.morphology['name'] == spec['name']: - chunk.source.morphology['build-mode'] = \ - spec['build-mode'] - def unpack_components(self, bc, components, path): if not components: raise cliapp.AppException('Deployment failed as no components ' @@ -716,7 +691,8 @@ class DeployPlugin(cliapp.Plugin): system_tree = tempfile.mkdtemp(dir=deploy_tempdir) try: - self.fix_chunk_build_mode(artifact) + # FIXME: This should be fixed in morphloader. + morphlib.util.fix_chunk_build_mode(artifact) if self.app.settings['partial']: self.unpack_components(build_command, components, system_tree) else: diff --git a/morphlib/plugins/system_manifests_plugin.py b/morphlib/plugins/system_manifests_plugin.py index 9d22488a..f5aa25b8 100644 --- a/morphlib/plugins/system_manifests_plugin.py +++ b/morphlib/plugins/system_manifests_plugin.py @@ -90,31 +90,6 @@ class SystemManifestsPlugin(cliapp.Plugin): for system_filename in system_filenames: self.system_manifest(repo, ref, system_filename) - def fix_chunk_build_mode(self, system_artifact): - """Give each chunk's in-memory morpholgy the correct build-mode. - - Currently, our definitions define build-mode in the entries in the - chunk list in a given stratum. However, morph expects it to be in - the chunk morphology when loading, and sets the in-memory - build-mode to 'staging' by default. - - """ - # This should probably be fixed in morphloader, but I held off on - # doing that following a discussion on #baserock. - # - # https://irclogs.baserock.org/%23baserock.2015-04-21.log.html - # (at 9:02) - strata = set(a for a in system_artifact.walk() - if a.source.morphology['kind'] == 'stratum') - chunks = set(a for a in system_artifact.walk() - if a.source.morphology['kind'] == 'chunk') - for chunk in chunks: - for stratum in strata: - for spec in stratum.source.morphology['chunks']: - if chunk.source.morphology['name'] == spec['name']: - chunk.source.morphology['build-mode'] = \ - spec['build-mode'] - @staticmethod def find_artifact_by_name(artifacts_list, filename): for a in artifacts_list: @@ -148,7 +123,9 @@ class SystemManifestsPlugin(cliapp.Plugin): build_env = morphlib.buildenvironment.BuildEnvironment( self.app.settings, system_artifact.source.morphology['arch']) ckc = morphlib.cachekeycomputer.CacheKeyComputer(build_env) - self.fix_chunk_build_mode(system_artifact) + + # FIXME: This should be fixed in morphloader. + morphlib.util.fix_chunk_build_mode(system_artifact) aliases = self.app.settings['repo-alias'] resolver = morphlib.repoaliasresolver.RepoAliasResolver(aliases) diff --git a/morphlib/util.py b/morphlib/util.py index ab774dd5..9668bac5 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -702,3 +702,31 @@ def word_join_list(l): # pragma: no cover else: commasep = ', '.join(l[:-1]) return ' and '.join((commasep, l[-1])) + + +def fix_chunk_build_mode(system_artifact): # pragma: no cover + """Give each chunk's in-memory morphology the correct build-mode. + + This function gives each chunk contained in `system_artifact` the + correct build-mode, rather than having them all be 'staging'. + + Currently, our definitions define build-mode in the entries in the + chunk list in a given stratum. However, morph expects it to be in + the chunk morphology when loading, and sets the in-memory + build-mode to 'staging' by default. + + """ + # This should probably be fixed in morphloader, but I held off on + # doing that following a discussion on #baserock. + # + # https://irclogs.baserock.org/%23baserock.2015-04-21.log.html + # (at 9:02) + strata = set(a for a in system_artifact.walk() + if a.source.morphology['kind'] == 'stratum') + chunks = set(a for a in system_artifact.walk() + if a.source.morphology['kind'] == 'chunk') + for chunk, stratum in itertools.product(chunks, strata): + for spec in stratum.source.morphology['chunks']: + if chunk.source.morphology['name'] == spec['name']: + chunk.source.morphology['build-mode'] = \ + spec['build-mode'] |