diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2013-01-02 15:10:12 +0000 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2013-01-03 17:20:24 +0000 |
commit | ee1cb9b7e6366568a29016f09adbdb327073e470 (patch) | |
tree | 5fe04ad92d6ac21dc5c03fd33cda5f96c76671d6 /morphlib/builder2.py | |
parent | 4c7b6184fe12775ceb83cefb405921e961495e9c (diff) | |
download | morph-ee1cb9b7e6366568a29016f09adbdb327073e470.tar.gz |
Make ccache use the same directory for repos that are clones
This patch makes morph store its ccaches by the url's basename instead
of using the whole url. This fixes the problem of morph choking when it
tries to mount a directory with a colon in its path, and also makes
all clones of one repository use the same cache (probably). This will
cause projects with the same name to use the same cache, but that is
not likely to cause serious problems.
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r-- | morphlib/builder2.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 0c1acfde..a60c4a47 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ import traceback import subprocess import tempfile import gzip +from urlparse import urlparse import cliapp @@ -294,9 +295,19 @@ class ChunkBuilder(BuilderBase): if not os.path.isdir(ccache_dir): os.makedirs(ccache_dir) # Get a path for the repo's ccache - ccache_repobase = os.path.basename(self.artifact.source.repo.path) - ccache_repodir = os.path.join(ccache_dir, - ccache_repobase) + ccache_url = self.artifact.source.repo.url + ccache_path = urlparse(ccache_url).path + ccache_repobase = os.path.basename(ccache_path) + if ':' in ccache_repobase: # the basename is a repo-alias + resolver = morphlib.repoaliasresolver.RepoAliasResolver( + self.app.settings['repo-alias']) + ccache_url = resolver.pull_url(ccache_repobase) + ccache_path = urlparse(ccache_url).path + ccache_repobase = os.path.basename(ccache_path) + if ccache_repobase.endswith('.git'): + ccache_repobase = ccache_repobase[:-len('.git')] + + ccache_repodir = os.path.join(ccache_dir, ccache_repobase) # Make sure that directory exists if not os.path.isdir(ccache_repodir): os.mkdir(ccache_repodir) |