summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-09-21 15:36:08 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-09-21 15:36:08 +0100
commit0bc1d47f2d9d5255f93cefcfe404212abd68427a (patch)
tree5c9e5f506bedf7631509574ea63b8ebafedca4d3 /morphlib
parent3bb5094acbd08ecd5acf2a36a86317619abab027 (diff)
parent5d9d28c77853be925c216cfa9f046bac1fc7d8fa (diff)
downloadmorph-0bc1d47f2d9d5255f93cefcfe404212abd68427a.tar.gz
Merge branch 'master' of git://git.baserock.org/baserock/morph
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/buildcommand.py7
-rw-r--r--morphlib/localartifactcache.py8
-rw-r--r--morphlib/localartifactcache_tests.py9
3 files changed, 20 insertions, 4 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 652bf303..34468f1a 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -131,6 +131,7 @@ class BuildCommand(object):
self.app.status(msg='The %(kind)s %(name)s is already built',
kind=artifact.source.morphology['kind'],
name=artifact.name)
+ self.cache_artifacts_locally([artifact])
else:
self.app.status(msg='Building %(kind)s %(name)s',
kind=artifact.source.morphology['kind'],
@@ -149,6 +150,12 @@ class BuildCommand(object):
self.install_chunk_artifacts(staging_area,
(artifact,))
self.remove_staging_area(staging_area)
+ self.app.status(msg='%(kind)s %(name)s is cached at %(cachepath)s',
+ kind=artifact.source.morphology['kind'],
+ name=artifact.name,
+ cachepath=self.lac.artifact_filename(artifact),
+ chatty=(artifact.source.morphology['kind'] !=
+ "system"))
def is_built(self, artifact):
'''Does either cache already have the artifact?'''
diff --git a/morphlib/localartifactcache.py b/morphlib/localartifactcache.py
index 51ccb4f6..893359d8 100644
--- a/morphlib/localartifactcache.py
+++ b/morphlib/localartifactcache.py
@@ -25,7 +25,7 @@ class LocalArtifactCache(object):
self.cachedir = cachedir
def put(self, artifact):
- filename = self._artifact_filename(artifact)
+ filename = self.artifact_filename(artifact)
return morphlib.savefile.SaveFile(filename, mode='w')
def put_artifact_metadata(self, artifact, name):
@@ -37,7 +37,7 @@ class LocalArtifactCache(object):
return morphlib.savefile.SaveFile(filename, mode='w')
def has(self, artifact):
- filename = self._artifact_filename(artifact)
+ filename = self.artifact_filename(artifact)
return os.path.exists(filename)
def has_artifact_metadata(self, artifact, name):
@@ -49,7 +49,7 @@ class LocalArtifactCache(object):
return os.path.exists(filename)
def get(self, artifact):
- filename = self._artifact_filename(artifact)
+ filename = self.artifact_filename(artifact)
return open(filename)
def get_artifact_metadata(self, artifact, name):
@@ -60,7 +60,7 @@ class LocalArtifactCache(object):
filename = self._source_metadata_filename(source, cachekey, name)
return open(filename)
- def _artifact_filename(self, artifact):
+ def artifact_filename(self, artifact):
basename = artifact.basename()
return os.path.join(self.cachedir, basename)
diff --git a/morphlib/localartifactcache_tests.py b/morphlib/localartifactcache_tests.py
index c3deb9dc..8e25e5c9 100644
--- a/morphlib/localartifactcache_tests.py
+++ b/morphlib/localartifactcache_tests.py
@@ -15,6 +15,7 @@
import unittest
+import os
import morphlib
@@ -52,6 +53,14 @@ class LocalArtifactCacheTests(unittest.TestCase):
def tearDown(self):
self.tempdir.remove()
+ def test_artifact_filename(self):
+ cache = morphlib.localartifactcache.LocalArtifactCache(
+ self.tempdir.dirname)
+ filename = cache.artifact_filename(self.devel_artifact)
+ expected_name = os.path.join(self.tempdir.dirname,
+ self.devel_artifact.basename())
+ self.assertEqual(filename, expected_name)
+
def test_put_artifacts_and_check_whether_the_cache_has_them(self):
cache = morphlib.localartifactcache.LocalArtifactCache(
self.tempdir.dirname)