diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-24 13:33:56 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-24 13:33:56 +0000 |
commit | 238b1a44bda17ce49f424c4d874e0dd74c29c5c8 (patch) | |
tree | 0858a09e7ea58c19ae9e995348cffb8b63155d2b | |
parent | 87aa2c5a7c1f2cb0ca74959d5a082ccc80f6502a (diff) | |
parent | e335d4f25ff93ca3fba4c96d54131bbe1f646d3b (diff) | |
download | morph-238b1a44bda17ce49f424c4d874e0dd74c29c5c8.tar.gz |
Merge remote-tracking branch 'origin/master' into rm/timings-back
-rwxr-xr-x | morph | 4 | ||||
-rw-r--r-- | morphlib/builder2.py | 22 | ||||
-rw-r--r-- | morphlib/builder2_tests.py | 5 | ||||
-rwxr-xr-x | tests.as-root/make-patch.script | 2 |
4 files changed, 24 insertions, 9 deletions
@@ -236,16 +236,18 @@ class Morph(cliapp.Application): staging_area = morphlib.stagingarea.StagingArea(staging_root, staging_temp) - builder = morphlib.builder2.Builder(staging_area, lac, + builder = morphlib.builder2.Builder(staging_area, lac, lrc, build_env, self.settings['max-jobs']) for group in order.groups: for artifact in group: if artifact in needed: logging.debug('Need to build %s' % artifact.name) + self.msg('Building %s' % artifact.name) builder.build_and_cache(artifact) else: logging.debug('No need to build %s' % artifact.name) + self.msg('Using cached %s' % artifact.name) if install_chunks: logging.debug('installing chunks from just-built group') diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 6da07c1f..9a79dea4 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -26,11 +26,12 @@ class BuilderBase(object): '''Base class for building artifacts.''' - def __init__(self, staging_area, artifact_cache, artifact, build_env, - max_jobs): + def __init__(self, staging_area, artifact_cache, artifact, repo_cache, + build_env, max_jobs): self.staging_area = staging_area self.artifact_cache = artifact_cache self.artifact = artifact + self.repo_cache = repo_cache self.build_env = build_env self.max_jobs = max_jobs self.build_watch = morphlib.stopwatch.Stopwatch() @@ -141,6 +142,8 @@ class ChunkBuilder(BuilderBase): def get_sources(self, srcdir): # pragma: no cover '''Get sources from git to a source directory, for building.''' + cache_dir = os.path.dirname(self.artifact.source.repo.path) + def extract_repo(path, sha1, destdir): logging.debug('Extracting %s into %s' % (path, destdir)) if not os.path.exists(destdir): @@ -154,8 +157,12 @@ class ChunkBuilder(BuilderBase): except morphlib.git.NoModulesFileError: return [] else: - return [(sub.path, sub.commit, os.path.join(destdir, sub.path)) - for sub in submodules] + tuples = [] + for sub in submodules: + cached_repo = self.repo_cache.get_repo(sub.url) + sub_dir = os.path.join(destdir, sub.path) + tuples.append((cached_repo.path, sub.commit, sub_dir)) + return tuples s = self.artifact.source todo = [(s.repo.path, s.sha1, srcdir)] @@ -432,16 +439,19 @@ class Builder(object): # pragma: no cover 'system': SystemBuilder, } - def __init__(self, staging_area, artifact_cache, build_env, max_jobs): + def __init__(self, staging_area, artifact_cache, repo_cache, build_env, + max_jobs): self.staging_area = staging_area self.artifact_cache = artifact_cache + self.repo_cache = repo_cache self.build_env = build_env self.max_jobs = max_jobs def build_and_cache(self, artifact): kind = artifact.source.morphology['kind'] o = self.classes[kind](self.staging_area, self.artifact_cache, - artifact, self.build_env, self.max_jobs) + artifact, self.repo_cache, self.build_env, + self.max_jobs) logging.debug('Builder.build: artifact %s with %s' % (artifact.name, repr(o))) o.build_and_cache() diff --git a/morphlib/builder2_tests.py b/morphlib/builder2_tests.py index e3f81d16..67379341 100644 --- a/morphlib/builder2_tests.py +++ b/morphlib/builder2_tests.py @@ -134,11 +134,13 @@ class BuilderBaseTests(unittest.TestCase): self.staging_area = FakeStagingArea(self.fake_runcmd) self.artifact_cache = FakeArtifactCache() self.artifact = FakeArtifact('le-artifact') + self.repo_cache = None self.build_env = FakeBuildEnv() self.max_jobs = 1 self.builder = morphlib.builder2.BuilderBase(self.staging_area, self.artifact_cache, self.artifact, + self.repo_cache, self.build_env, self.max_jobs) @@ -202,7 +204,8 @@ class BuilderBaseTests(unittest.TestCase): class ChunkBuilderTests(unittest.TestCase): def setUp(self): - self.build = morphlib.builder2.ChunkBuilder(None, None, None, None, 1) + self.build = morphlib.builder2.ChunkBuilder(None, None, None, None, + None, 1) def test_uses_morphology_commands_when_given(self): m = { 'build-commands': ['build-it'] } diff --git a/tests.as-root/make-patch.script b/tests.as-root/make-patch.script index 2ffb58cf..5c7083ae 100755 --- a/tests.as-root/make-patch.script +++ b/tests.as-root/make-patch.script @@ -88,7 +88,7 @@ img2=$(find "$DATADIR/cache" -maxdepth 1 -name '*.system.*' \ patch="$DATADIR/patch" "$SRCDIR/scripts/test-morph" make-patch "$patch" \ morphs-repo master hello-system.morph \ - morphs-repo alfred hello-system.morph --log=/home/liw/foo.log + morphs-repo alfred hello-system.morph # Unpack the original stratum and run the program. mkdir "$DATADIR/unpacked" |