summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-20 11:34:03 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-22 11:36:14 +0100
commit8bca8d9439f0118f831475f2ac1192e52745ac6e (patch)
tree38c61308b8aca1f0d5b93db3ee5057015d0299a4 /morphlib/app.py
parent1dfaa88a7e3f39d9479be25b60e27414e803f91b (diff)
downloadmorph-8bca8d9439f0118f831475f2ac1192e52745ac6e.tar.gz
Change install_artifacts to fetch missing artifacts
This is a behavioral change, and is useful when building and having access to an artifact cache server. Previously, nothing was actually fetching artifacts from the remote server when the staging area was being crafted. Morph could do with a bit of cleanup where we separate more cleanly the acts of fetching stuff to the local artifact cache from the remote one, when possible, and then using artifacts from the local cache. Currently this stuff is spread around a bit too much. I did not do that in this patch, however, to keep undiscussed changes small.
Diffstat (limited to 'morphlib/app.py')
-rwxr-xr-xmorphlib/app.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 18187a36..d149e76f 100755
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -252,9 +252,15 @@ class Morph(cliapp.Application):
os.path.exists(staging_area.tempdir)):
shutil.rmtree(staging_area.tempdir)
- def install_artifacts(self, staging_area, lac, chunk_artifacts):
+ def install_artifacts(self, staging_area, lac, rac, chunk_artifacts):
for chunk_artifact in chunk_artifacts:
self.msg(' Installing %s' % chunk_artifact.name)
+ if not lac.has(chunk_artifact) and rac:
+ remote = rac.get(chunk_artifact)
+ local = lac.put(chunk_artifact)
+ local.write(remote.read())
+ remote.close()
+ local.close()
handle = lac.get(chunk_artifact)
staging_area.install_artifact(handle)
@@ -347,7 +353,7 @@ class Morph(cliapp.Application):
to_install = []
for group in order.groups:
if install_chunks:
- self.install_artifacts(staging_area, lac, to_install)
+ self.install_artifacts(staging_area, lac, rac, to_install)
del to_install[:]
for artifact in set(group).difference(set(needed)):
self.msg('Using cached %s' % artifact.name)
@@ -360,7 +366,7 @@ class Morph(cliapp.Application):
# If we are running bootstrap we probably also want the last
# build group to be installed as well
if self.settings['bootstrap']:
- self.install_artifacts(staging_area, lac, to_install)
+ self.install_artifacts(staging_area, lac, rac, to_install)
self.remove_staging_area(staging_area)