summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-05 11:26:55 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-05 11:26:55 +0100
commitdb39f34c4c1b7ca5620f466c34e7fbf8a81709d6 (patch)
tree3bc60dd092508278114078f75997c9d9c6f42769 /morphlib
parent3e31c8211d5ec1f642917d7609ed77fc54cf0a0b (diff)
parent6b0703a908e82dddd6c1a0cc8a944ba46ad96657 (diff)
downloadmorph-db39f34c4c1b7ca5620f466c34e7fbf8a81709d6.tar.gz
Merge remote branch 'remotes/origin/baserock/bugfix/S3152-systems-always-rebuild'
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/artifactresolver.py38
-rw-r--r--morphlib/artifactresolver_tests.py28
-rw-r--r--morphlib/cachekeycomputer_tests.py8
3 files changed, 52 insertions, 22 deletions
diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py
index a458f52a..9a589adf 100644
--- a/morphlib/artifactresolver.py
+++ b/morphlib/artifactresolver.py
@@ -93,15 +93,20 @@ class ArtifactResolver(object):
source = queue.popleft()
if source.morphology['kind'] == 'system':
- artifact = self._get_artifact(
- source, source.morphology['name'])
-
- if not artifact in self._added_artifacts:
- artifacts.append(artifact)
- self._added_artifacts.add(artifact)
+ 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')]
+
+ if any(a not in self._added_artifacts for a in systems):
+ artifacts.extend(systems)
+ self._added_artifacts.update(systems)
resolved_artifacts = self._resolve_system_dependencies(
- artifact, queue)
+ systems, source, queue)
for artifact in resolved_artifacts:
if not artifact in self._added_artifacts:
@@ -149,22 +154,23 @@ class ArtifactResolver(object):
self._cached_artifacts[info] = artifact
return artifact
- def _resolve_system_dependencies(self, system, queue):
+ def _resolve_system_dependencies(self, systems, source, queue):
artifacts = []
- for stratum_name in system.source.morphology['strata']:
- source = self._source_pool.lookup(
- system.source.repo_name,
- system.source.original_ref,
+ for stratum_name in source.morphology['strata']:
+ stratum_source = self._source_pool.lookup(
+ source.repo_name,
+ source.original_ref,
'%s.morph' % stratum_name)
- stratum = self._get_artifact(source, stratum_name)
+ stratum = self._get_artifact(stratum_source, stratum_name)
- system.add_dependency(stratum)
- queue.append(source)
+ for system in systems:
+ system.add_dependency(stratum)
+ queue.append(stratum_source)
artifacts.append(stratum)
-
+
return artifacts
def _resolve_stratum_dependencies(self, stratum, queue):
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 467c882d..5dc7f29a 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -187,10 +187,34 @@ class ArtifactResolverTests(unittest.TestCase):
artifacts = self.resolver.resolve_artifacts(pool)
self.assertEqual(artifacts[0].source, system)
- self.assertEqual(artifacts[0].name, 'foo')
+ self.assertEqual(artifacts[0].name, 'foo-rootfs')
self.assertEqual(artifacts[0].dependencies, [])
self.assertEqual(artifacts[0].dependents, [])
+ def test_resolve_a_single_empty_arm_system(self):
+ pool = morphlib.sourcepool.SourcePool()
+
+ morph = morphlib.morph2.Morphology(
+ '''
+ {
+ "name": "foo",
+ "kind": "system",
+ "arch": "arm"
+ }
+ ''')
+ system = morphlib.source.Source(
+ 'repo', 'original/ref', 'sha1', morph, 'foo.morph')
+ pool.add(system)
+
+ artifacts = self.resolver.resolve_artifacts(pool)
+
+ self.assertTrue(any((a.source == system and a.name == 'foo-rootfs' and
+ a.dependencies == [] and a.dependents == [])
+ for a in artifacts))
+ self.assertTrue(any((a.source == system and a.name == 'foo-kernel' and
+ a.dependencies == [] and a.dependents == [])
+ for a in artifacts))
+
def test_resolve_stratum_and_chunk_with_no_subartifacts(self):
pool = morphlib.sourcepool.SourcePool()
@@ -447,7 +471,7 @@ class ArtifactResolverTests(unittest.TestCase):
self.assertEqual(artifacts[0].dependents, [artifacts[1], artifacts[2]])
self.assertEqual(artifacts[1].source, system)
- self.assertEqual(artifacts[1].name, 'system')
+ self.assertEqual(artifacts[1].name, 'system-rootfs')
self.assertEqual(artifacts[1].dependencies,
[artifacts[0], artifacts[2]])
self.assertEqual(artifacts[1].dependents, [])
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py
index 807fbe89..82d3e6e5 100644
--- a/morphlib/cachekeycomputer_tests.py
+++ b/morphlib/cachekeycomputer_tests.py
@@ -117,7 +117,7 @@ class CacheKeyComputerTests(unittest.TestCase):
self.ckc._hash_list = inccount(self.ckc._hash_list, 'list')
self.ckc._hash_tuple = inccount(self.ckc._hash_tuple, 'tuple')
- artifact = self._find_artifact('system')
+ artifact = self._find_artifact('system-rootfs')
self.ckc.compute_key(artifact)
self.assertNotEqual(runcount['thing'], 0)
@@ -130,12 +130,12 @@ class CacheKeyComputerTests(unittest.TestCase):
return len(s) == 64 and all([c in validchars for c in s])
def test_compute_key_returns_sha256(self):
- artifact = self._find_artifact('system')
+ artifact = self._find_artifact('system-rootfs')
self.assertTrue(self._valid_sha256(
self.ckc.compute_key(artifact)))
def test_different_env_gives_different_key(self):
- artifact = self._find_artifact('system')
+ artifact = self._find_artifact('system-rootfs')
oldsha = self.ckc.compute_key(artifact)
build_env = DummyBuildEnvironment({
"USER": "foouser",
@@ -150,7 +150,7 @@ class CacheKeyComputerTests(unittest.TestCase):
self.assertNotEqual(oldsha, ckc.compute_key(artifact))
def test_same_morphology_text_but_changed_sha1_gives_same_cache_key(self):
- old_artifact = self._find_artifact('system')
+ old_artifact = self._find_artifact('system-rootfs')
morphology = old_artifact.source.morphology
new_source = morphlib.source.Source('repo', 'original/ref', 'newsha',
morphology,