From 2a071ef057c953e81e1b8bd9b714373b4dbb26c2 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 28 Aug 2012 17:20:04 +0100 Subject: 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. --- morphlib/app.py | 4 +- morphlib/artifactresolver.py | 20 +++---- morphlib/artifactresolver_tests.py | 63 ++++++++++++++-------- morphlib/cachekeycomputer_tests.py | 12 ++++- tests.as-root/archless-system-fails.script | 6 ++- tests.as-root/disk-builds-rootfs-and-kernel.script | 6 ++- tests.as-root/make-patch.script | 1 + .../rootfs-tarball-builds-rootfs-and-kernel.script | 6 ++- tests.as-root/setup | 6 ++- .../syslinux-disk-builds-rootfs-and-kernel.script | 6 ++- .../syslinux-fails-if-no-mbr-found.script | 6 ++- tests.as-root/system-overlap.script | 12 ++++- tests.branching/edit-updates-stratum.stdout | 4 +- tests.branching/setup | 8 ++- tests/setup | 6 ++- tests/show-dependencies.setup | 6 ++- 16 files changed, 124 insertions(+), 48 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(): diff --git a/tests.as-root/archless-system-fails.script b/tests.as-root/archless-system-fails.script index 6e14c875..02372b5b 100755 --- a/tests.as-root/archless-system-fails.script +++ b/tests.as-root/archless-system-fails.script @@ -31,7 +31,11 @@ cat <archless-system.morph "kind": "system", "disk-size": "1G", "strata": [ - "hello-stratum" + { + "morph": "hello-stratum", + "repo": "tests:morphs-repo", + "ref": "archless" + } ] } EOF diff --git a/tests.as-root/disk-builds-rootfs-and-kernel.script b/tests.as-root/disk-builds-rootfs-and-kernel.script index aacebae8..475df6c1 100755 --- a/tests.as-root/disk-builds-rootfs-and-kernel.script +++ b/tests.as-root/disk-builds-rootfs-and-kernel.script @@ -35,7 +35,11 @@ cat <system.morph "arch": "$arch", "disk-size": "1G", "strata": [ - "stratum" + { + "morph": "stratum", + "repo": "test:morphs-repo", + "ref": "custom" + } ] } EOF diff --git a/tests.as-root/make-patch.script b/tests.as-root/make-patch.script index 9fd58303..5204fce1 100755 --- a/tests.as-root/make-patch.script +++ b/tests.as-root/make-patch.script @@ -58,6 +58,7 @@ sed -i s/hello/goodbye/ "$DATADIR/chunk-repo/hello.c" # branch for the morphs repo. "$SRCDIR/scripts/run-git-in" "$DATADIR/morphs-repo" checkout --quiet -b alfred sed -i 's/farrokh/alfred/' "$DATADIR/morphs-repo/hello-stratum.morph" +sed -i 's/master/alfred/' "$DATADIR/morphs-repo/hello-system.morph" "$SRCDIR/scripts/run-git-in" "$DATADIR/morphs-repo" commit -am goodbye \ > /dev/null diff --git a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script index ed1dd642..c9bd418c 100755 --- a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script +++ b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script @@ -37,7 +37,11 @@ cat <system.morph "arch": "$arch", "disk-size": "1G", "strata": [ - "stratum" + { + "morph": "stratum", + "repo": "test:morphs-repo", + "ref": "custom" + } ] } EOF diff --git a/tests.as-root/setup b/tests.as-root/setup index 5b63b685..2ba0adf9 100755 --- a/tests.as-root/setup +++ b/tests.as-root/setup @@ -110,7 +110,11 @@ cat < hello-system.morph "arch": "$(uname -m)", "disk-size": "1G", "strata": [ - "hello-stratum" + { + "morph": "hello-stratum", + "repo": "test:morphs-repo", + "ref": "master" + } ] } EOF diff --git a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script index 7f2a6f01..6a968563 100755 --- a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script +++ b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script @@ -42,7 +42,11 @@ cat <system.morph "arch": "$arch", "disk-size": "1G", "strata": [ - "stratum" + { + "morph": "stratum", + "repo": "test:morphs-repo", + "ref": "custom" + } ] } EOF diff --git a/tests.as-root/syslinux-fails-if-no-mbr-found.script b/tests.as-root/syslinux-fails-if-no-mbr-found.script index 3e46f918..bb5f28cb 100755 --- a/tests.as-root/syslinux-fails-if-no-mbr-found.script +++ b/tests.as-root/syslinux-fails-if-no-mbr-found.script @@ -42,7 +42,11 @@ cat <system.morph "arch": "$arch", "disk-size": "1G", "strata": [ - "stratum" + { + "morph": "stratum", + "repo": "test:morphs-repo", + "ref": "custom" + } ] } EOF diff --git a/tests.as-root/system-overlap.script b/tests.as-root/system-overlap.script index 17f1bf17..c7e6969a 100755 --- a/tests.as-root/system-overlap.script +++ b/tests.as-root/system-overlap.script @@ -34,8 +34,16 @@ cat <overlap-system.morph "arch": "$(uname -m)", "disk-size": "1G", "strata": [ - "foo-baz-stratum", - "foo-barqux-stratum" + { + "morph": "foo-baz-stratum", + "repo": "test:morphs-repo", + "ref": "overlap" + }, + { + "morph": "foo-barqux-stratum", + "repo": "test:morphs-repo", + "ref": "overlap" + } ] } EOF diff --git a/tests.branching/edit-updates-stratum.stdout b/tests.branching/edit-updates-stratum.stdout index e58e8187..01c67858 100644 --- a/tests.branching/edit-updates-stratum.stdout +++ b/tests.branching/edit-updates-stratum.stdout @@ -1,5 +1,5 @@ diff --git a/hello-stratum.morph b/hello-stratum.morph -index 06ae459..ad8c08b 100644 +index 006a96c..ad8c08b 100644 --- a/hello-stratum.morph +++ b/hello-stratum.morph @@ -1,12 +1,14 @@ @@ -10,8 +10,8 @@ index 06ae459..ad8c08b 100644 "chunks": [ { - "name": "hello", -- "ref": "master", - "repo": "baserock:hello", +- "ref": "master", - "build-depends": [] + "build-depends": [], + "morph": "hello", diff --git a/tests.branching/setup b/tests.branching/setup index b062f379..126714a0 100755 --- a/tests.branching/setup +++ b/tests.branching/setup @@ -63,7 +63,11 @@ cat < "$DATADIR/morphs/hello-system.morph" "system-kind": "syslinux-disk", "disk-size": "1G", "strata": [ - "hello-stratum" + { + "morph": "hello-stratum", + "repo": "baserock:hello", + "ref": "master" + } ] } EOF @@ -75,8 +79,8 @@ cat < "$DATADIR/morphs/hello-stratum.morph" "chunks": [ { "name": "hello", - "ref": "master", "repo": "baserock:hello", + "ref": "master", "build-depends": [] } ] diff --git a/tests/setup b/tests/setup index 19c400fa..25472dc7 100755 --- a/tests/setup +++ b/tests/setup @@ -109,7 +109,11 @@ cat < hello-system.morph "system-kind": "syslinux-disk", "disk-size": "1G", "strata": [ - "hello-stratum" + { + "morph": "hello-stratum", + "repo": "test:morphs-repo", + "ref": "master" + } ] } EOF diff --git a/tests/show-dependencies.setup b/tests/show-dependencies.setup index 924a626b..76711987 100755 --- a/tests/show-dependencies.setup +++ b/tests/show-dependencies.setup @@ -198,7 +198,11 @@ cat < xfce-core.morph "name": "xfce-core", "kind": "stratum", "build-depends": [ - "gtk-stack" + { + "morph": "gtk-stack", + "repo": "test:test-repo", + "ref": "master" + } ], "chunks": [ { -- cgit v1.2.1