diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-24 13:44:20 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-24 13:44:20 +0100 |
commit | 3e2c2794dd4ed46dea304fdf2edd1effefebb5f3 (patch) | |
tree | 83907c28e1a623c01e514b0f2c52c9643a2a00f8 | |
parent | 4198108ef0b09566fe26a251bcf16fc81b06e7e8 (diff) | |
download | morph-3e2c2794dd4ed46dea304fdf2edd1effefebb5f3.tar.gz |
Make builder get submodule cache repo path cleanly
-rwxr-xr-x | morph | 2 | ||||
-rw-r--r-- | morphlib/builder2.py | 25 | ||||
-rw-r--r-- | morphlib/builder2_tests.py | 5 |
3 files changed, 19 insertions, 13 deletions
@@ -236,7 +236,7 @@ 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: diff --git a/morphlib/builder2.py b/morphlib/builder2.py index b5ef89e3..a27c35ab 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -27,11 +27,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 @@ -135,13 +136,12 @@ class ChunkBuilder(BuilderBase): except morphlib.git.NoModulesFileError: return [] else: - # FIXME: This is ugly, but the best I can do atm. We need - # to combine sub.path, which is a relative path, with the - # directory in the cache where the git repos are. --liw - return [(os.path.join(cache_dir, 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.repo) + 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)] @@ -393,16 +393,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 44608c75..4f94d6c2 100644 --- a/morphlib/builder2_tests.py +++ b/morphlib/builder2_tests.py @@ -83,11 +83,13 @@ class BuilderBaseTests(unittest.TestCase): self.staging_area = FakeStagingArea(self.fake_runcmd) self.artifact_cache = None # Not used by tests 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) @@ -134,7 +136,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'] } |