diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-28 17:20:04 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-08-30 11:19:01 +0000 |
commit | 2a071ef057c953e81e1b8bd9b714373b4dbb26c2 (patch) | |
tree | bffd06cb8a9d0c825cdc2274b7b4c55adc07def6 /morphlib | |
parent | ecefb2d1936221ccf21cbad6db2fe73cd229f4f5 (diff) | |
download | morph-2a071ef057c953e81e1b8bd9b714373b4dbb26c2.tar.gz |
Strata should be referred to with full repo/ref/morph triplets
This removes the requirement that all strata must be in the same
repo as the system morphology.
Both the system "strata" field and the stratum "build-depends" field
are affected.
Diffstat (limited to 'morphlib')
-rwxr-xr-x | morphlib/app.py | 4 | ||||
-rw-r--r-- | morphlib/artifactresolver.py | 20 | ||||
-rw-r--r-- | morphlib/artifactresolver_tests.py | 63 | ||||
-rw-r--r-- | morphlib/cachekeycomputer_tests.py | 12 |
4 files changed, 65 insertions, 34 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 5cb620eb..9135e440 100755 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -238,11 +238,11 @@ class Morph(cliapp.Application): reponame, absref, filename) visit(reponame, ref, filename, absref, morphology) if morphology['kind'] == 'system': - queue.extend((reponame, ref, '%s.morph' % s) + queue.extend((s['repo'], s['ref'], '%s.morph' % s['morph']) for s in morphology['strata']) elif morphology['kind'] == 'stratum': if morphology['build-depends']: - queue.extend((reponame, ref, '%s.morph' % s) + queue.extend((s['repo'], s['ref'], '%s.morph' % s['morph']) for s in morphology['build-depends']) queue.extend((c['repo'], c['ref'], '%s.morph' % c['morph']) for c in morphology['chunks']) diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py index c6e7fbf3..aed3c9c4 100644 --- a/morphlib/artifactresolver.py +++ b/morphlib/artifactresolver.py @@ -153,12 +153,13 @@ class ArtifactResolver(object): def _resolve_system_dependencies(self, systems, source, queue): artifacts = [] - for stratum_name in source.morphology['strata']: + for info in source.morphology['strata']: stratum_source = self._source_pool.lookup( - source.repo_name, - source.original_ref, - '%s.morph' % stratum_name) + info['repo'], + info['ref'], + '%s.morph' % info['morph']) + stratum_name = stratum_source.morphology.builds_artifacts[0] stratum = self._get_artifact(stratum_source, stratum_name) for system in systems: @@ -175,13 +176,14 @@ class ArtifactResolver(object): strata = [] if stratum.source.morphology['build-depends']: - for stratum_name in stratum.source.morphology['build-depends']: + for stratum_info in stratum.source.morphology['build-depends']: other_source = self._source_pool.lookup( - stratum.source.repo_name, - stratum.source.original_ref, - '%s.morph' % stratum_name) + stratum_info['repo'], + stratum_info['ref'], + '%s.morph' % stratum_info['morph']) - other_stratum = self._get_artifact(other_source, stratum_name) + other_stratum = self._get_artifact( + other_source, other_source.morphology.builds_artifacts[0]) strata.append(other_stratum) diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py index 952ffd85..65a9be7d 100644 --- a/morphlib/artifactresolver_tests.py +++ b/morphlib/artifactresolver_tests.py @@ -51,19 +51,26 @@ class FakeChunkMorphology(morphlib.morph2.Morphology): class FakeStratumMorphology(morphlib.morph2.Morphology): - def __init__(self, name, source_list=[], build_depends=[]): - assert(isinstance(source_list, list)) - assert(isinstance(build_depends, list)) - - if source_list: - chunks = [] - for source_name, morph, repo, ref in source_list: - chunks.append({ - 'name': source_name, - 'morph': morph, - 'repo': repo, - 'ref': ref - }) + def __init__(self, name, chunks_list=[], build_depends_list=[]): + assert(isinstance(chunks_list, list)) + assert(isinstance(build_depends_list, list)) + + chunks = [] + for source_name, morph, repo, ref in chunks_list: + chunks.append({ + 'name': source_name, + 'morph': morph, + 'repo': repo, + 'ref': ref + }) + build_depends = [] + for morph, repo, ref in build_depends_list: + build_depends.append({ + 'morph': morph, + 'repo': repo, + 'ref': ref + }) + if chunks: text = (''' { "name": "%s", @@ -367,7 +374,8 @@ class ArtifactResolverTests(unittest.TestCase): 'repo', 'ref', 'sha1', morph, 'stratum1.morph') pool.add(stratum1) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'ref')]) stratum2 = morphlib.source.Source( 'repo', 'ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -398,7 +406,9 @@ class ArtifactResolverTests(unittest.TestCase): 'stratum2', [ ('chunk1', 'chunk1', 'repo', 'original/ref'), ('chunk2', 'chunk2', 'repo', 'original/ref') - ], ['stratum1']) + ], [ + ('stratum1', 'repo', 'original/ref') + ]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -454,8 +464,16 @@ class ArtifactResolverTests(unittest.TestCase): "name": "system", "kind": "system", "strata": [ - "stratum1", - "stratum2" + { + "repo": "repo", + "ref": "ref", + "morph": "stratum1" + }, + { + "repo": "repo", + "ref": "ref", + "morph": "stratum2" + } ] } ''') @@ -464,7 +482,8 @@ class ArtifactResolverTests(unittest.TestCase): 'repo', 'ref', 'sha1', morph, 'system.morph') pool.add(system) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'ref')]) stratum2 = morphlib.source.Source( 'repo', 'ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -592,12 +611,14 @@ class ArtifactResolverTests(unittest.TestCase): def test_detection_of_mutual_dependency_between_two_strata(self): pool = morphlib.sourcepool.SourcePool() - morph = FakeStratumMorphology('stratum1', [], ['stratum2']) + morph = FakeStratumMorphology( + 'stratum1', [], [('stratum2', 'repo', 'original/ref')]) stratum1 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum1.morph') pool.add(stratum1) - morph = FakeStratumMorphology('stratum2', [], ['stratum1']) + morph = FakeStratumMorphology( + 'stratum2', [], [('stratum1', 'repo', 'original/ref')]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) @@ -621,7 +642,7 @@ class ArtifactResolverTests(unittest.TestCase): 'stratum2', [ ('chunk2', 'chunk2', 'repo', 'original/ref'), ('chunk1', 'chunk1', 'repo', 'original/ref') - ], ['stratum1']) + ], [('stratum1', 'repo', 'original/ref')]) stratum2 = morphlib.source.Source( 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph') pool.add(stratum2) diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 24cc636d..7ace9c36 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -77,8 +77,16 @@ class CacheKeyComputerTests(unittest.TestCase): "name": "system", "kind": "system", "strata": [ - "stratum", - "stratum2" + { + "morph": "stratum", + "repo": "repo", + "ref": "original/ref" + }, + { + "morph": "stratum2", + "repo": "repo", + "ref": "original/ref" + } ] }''', }.iteritems(): |