summaryrefslogtreecommitdiff
path: root/morphlib/buildcommand.py
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-03-30 12:16:50 +0000
committerMorph (on behalf of Adam Coldrick) <adam.coldrick@codethink.co.uk>2015-03-30 12:16:50 +0000
commitac44d4f5994dbc1d579dfb7e95c8672bf01caa5b (patch)
tree9b4054c06ee0dcd38da78bd9e78a5aa7292464b3 /morphlib/buildcommand.py
parentaa047d1b4ea195c1a5a70568a2b75f958f47fa99 (diff)
downloadmorph-ac44d4f5994dbc1d579dfb7e95c8672bf01caa5b.tar.gz
Morph build c2397bf4873742a3ba9202cbdcfffea8
System branch: master
Diffstat (limited to 'morphlib/buildcommand.py')
-rw-r--r--morphlib/buildcommand.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index be8a1507..c83abca6 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -418,8 +418,10 @@ class BuildCommand(object):
# module into morphlib.remoteartififactcache first.
to_fetch = []
if not self.lac.has(artifact):
- to_fetch.append((self.rac.get(artifact),
- self.lac.put(artifact)))
+ self.app.status(
+ msg='Fetching to local cache: artifact %(name)s',
+ name=artifact.name)
+ self.lac.copy_from_remote(artifact, self.rac)
if artifact.source.morphology.needs_artifact_metadata_cached:
if not self.lac.has_artifact_metadata(artifact, 'meta'):
@@ -428,9 +430,6 @@ class BuildCommand(object):
self.lac.put_artifact_metadata(artifact, 'meta')))
if len(to_fetch) > 0:
- self.app.status(
- msg='Fetching to local cache: artifact %(name)s',
- name=artifact.name)
fetch_files(to_fetch)
def create_staging_area(self, build_env, use_chroot=True, extra_env={},
@@ -493,8 +492,27 @@ class BuildCommand(object):
chunk_name=artifact.name,
cache=artifact.source.cache_key[:7],
chatty=True)
- handle = self.lac.get(artifact)
- staging_area.install_artifact(handle)
+ chunk_cache_dir = os.path.join(self.app.settings['tempdir'],
+ 'chunks')
+ artifact_checkout = os.path.join(
+ chunk_cache_dir, os.path.basename(artifact.basename()) + '.d')
+ if not os.path.exists(artifact_checkout):
+ self.app.status(
+ msg='Checking out %(chunk)s from cache.',
+ chunk=artifact.name
+ )
+ temp_checkout = os.path.join(self.app.settings['tempdir'],
+ artifact.basename())
+ try:
+ self.lac.get(artifact, temp_checkout)
+ except BaseException:
+ shutil.rmtree(temp_checkout)
+ raise
+ # TODO: This rename is not concurrency safe if two builds are
+ # extracting the same chunk, one build will fail because
+ # the other renamed its tempdir here first.
+ os.rename(temp_checkout, artifact_checkout)
+ staging_area.install_artifact(artifact, artifact_checkout)
if target_source.build_mode == 'staging':
morphlib.builder.ldconfig(self.app.runcmd, staging_area.dirname)