summaryrefslogtreecommitdiff
path: root/morphlib/buildcommand.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2016-03-02 17:11:34 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2016-03-16 19:11:21 +0000
commitd58d8e8f7a4ec03ff14021a4515c8283dad52573 (patch)
tree5ece2d0524e4423bb953e6140831c9fde93b7219 /morphlib/buildcommand.py
parent014a029ade9a045a839ca86c35690b218098ea33 (diff)
downloadmorph-d58d8e8f7a4ec03ff14021a4515c8283dad52573.tar.gz
Unify local and remote repo cache modules
There's not really any reason you'd want to use the RemoteRepoCache class except as a workaround for the slow speed of some LocalRepoCache operations, so I can't see this ruining anyone's day. The main reason for doing this is so we can simply the sourceresolver code. One reason that the sourceresolver class is so hopelessly complicated is that it right now has to use two incompatible interfaces for Git repo caches. I've taken the opportunity to detangle the RepoCache class from the App class. Now all of the configuration for the RepoCache class is passed into the constructor explicitly. This makes the class usable from outside Morph: resolver = morphlib.repoaliasresolver.RepoAliasResolver(aliases=[]) repo_cache = morphlib.repocache.RepoCache('/src/cache/gits', resolver) Change-Id: I596c81d7645b67504c88e555172a8c238f4f8a66
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r--morphlib/buildcommand.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index a2ad3301..e185a808 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 Codethink Limited
+# Copyright (C) 2011-2016 Codethink Limited
# Copyright © 2015 Richard Ipsum
#
# This program is free software; you can redistribute it and/or modify
@@ -47,7 +47,7 @@ class BuildCommand(object):
def __init__(self, app, build_env = None):
self.app = app
self.lac, self.rac = self.new_artifact_caches()
- self.lrc, self.rrc = self.new_repo_caches()
+ self.repo_cache = morphlib.util.new_repo_cache(self.app)
def build(self, repo_name, ref, filename, original_ref=None):
'''Build a given system morphology.'''
@@ -76,9 +76,6 @@ class BuildCommand(object):
'''
return morphlib.util.new_artifact_caches(self.app.settings)
- def new_repo_caches(self):
- return morphlib.util.new_repo_caches(self.app)
-
def new_build_env(self, arch):
'''Create a new BuildEnvironment instance.'''
return morphlib.buildenvironment.BuildEnvironment(self.app.settings,
@@ -95,10 +92,8 @@ class BuildCommand(object):
'''
self.app.status(msg='Creating source pool', chatty=True)
srcpool = morphlib.sourceresolver.create_source_pool(
- self.lrc, self.rrc, repo_name, ref, filenames,
- cachedir=self.app.settings['cachedir'],
+ self.repo_cache, repo_name, ref, filenames,
original_ref=original_ref,
- update_repos=not self.app.settings['no-git-update'],
status_cb=self.app.status)
return srcpool
@@ -394,8 +389,9 @@ class BuildCommand(object):
'''Update the local git repository cache with the sources.'''
repo_name = source.repo_name
- source.repo = self.lrc.get_updated_repo(repo_name, ref=source.sha1)
- self.lrc.ensure_submodules(source.repo, source.sha1)
+ source.repo = self.repo_cache.get_updated_repo(repo_name,
+ ref=source.sha1)
+ self.repo_cache.ensure_submodules(source.repo, source.sha1)
def cache_artifacts_locally(self, artifacts):
'''Get artifacts missing from local cache from remote cache.'''
@@ -540,7 +536,7 @@ class BuildCommand(object):
'%(sha1)s',
name=source.name, sha1=source.sha1[:7])
builder = morphlib.builder.Builder(
- self.app, staging_area, self.lac, self.rac, self.lrc,
+ self.app, staging_area, self.lac, self.rac, self.repo_cache,
self.app.settings['max-jobs'], setup_mounts)
return builder.build_and_cache(source)