summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/fetch_strategy.py17
-rw-r--r--lib/spack/spack/package.py2
-rw-r--r--lib/spack/spack/stage.py13
3 files changed, 14 insertions, 18 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 27fb38b7a6..d1b3ce9291 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -156,11 +156,6 @@ class URLFetchStrategy(FetchStrategy):
if self.archive_file:
tty.msg("Already downloaded %s" % self.archive_file)
return
- cached = self.search_cache()
- if cached:
- tty.msg("Cached %s." % cached)
- shutil.copy(cached, "./")
- return
tty.msg("Trying to fetch from %s" % self.url)
@@ -216,8 +211,6 @@ class URLFetchStrategy(FetchStrategy):
if not self.archive_file:
raise FailedDownloadError(self.url)
- elif self.digest:
- shutil.copy(self.archive_file, spack.cache_path)
@property
@@ -292,16 +285,6 @@ class URLFetchStrategy(FetchStrategy):
"Expected %s but got %s" % (self.digest, checker.sum))
- def search_cache(self):
- if not self.digest:
- return
- checker = crypto.Checker(self.digest)
- paths = (join_path(spack.cache_path, f) for f in os.listdir(spack.cache_path))
- for p in paths:
- if checker.check(p):
- return p
-
-
@_needs_stage
def reset(self):
"""Removes the source path if it exists, then re-expands the archive."""
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index b488e4c49d..d007f37aeb 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -715,6 +715,8 @@ class Package(object):
if spack.do_checksum and self.version in self.versions:
self.stage.check()
+ self.stage.cache_local()
+
def do_stage(self, mirror_only=False):
"""Unpacks the fetched tarball, then changes into the expanded tarball
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index f88f82fc2d..8933ad6da2 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -273,6 +273,7 @@ class Stage(object):
# the root, so we add a '/' if it is not present.
mirror_roots = [root if root.endswith('/') else root + '/'
for root in mirrors.values()]
+ mirror_roots.append("file://" + os.path.abspath(spack.cache_path) + os.sep)
urls = [urljoin(root, self.mirror_path) for root in mirror_roots]
# If this archive is normally fetched from a tarball URL,
@@ -305,6 +306,7 @@ class Stage(object):
self.fetcher = self.default_fetcher
raise fs.FetchError(errMessage, None)
+
def check(self):
"""Check the downloaded archive against a checksum digest.
No-op if this stage checks code out of a repository."""
@@ -318,6 +320,15 @@ class Stage(object):
else:
self.fetcher.check()
+
+ def cache_local(self):
+ archiveDst = join_path(os.path.abspath(spack.cache_path), self.mirror_path)
+ mkdirp(os.path.dirname(archiveDst))
+ # TODO: this moves the archive for URLFetchStrategy vs. a copy - edit
+ # to do a move?
+ self.fetcher.archive(archiveDst)
+
+
def expand_archive(self):
"""Changes to the stage directory and attempt to expand the downloaded
archive. Fail if the stage is not set up or if the archive is not yet
@@ -421,7 +432,7 @@ class ResourceStage(Stage):
shutil.move(source_path, destination_path)
-@pattern.composite(method_list=['fetch', 'create', 'check', 'expand_archive', 'restage', 'destroy'])
+@pattern.composite(method_list=['fetch', 'create', 'check', 'expand_archive', 'restage', 'destroy', 'cache_local'])
class StageComposite:
"""
Composite for Stage type objects. The first item in this composite is considered to be the root package, and