summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/fetch_strategy.py10
-rw-r--r--lib/spack/spack/mirror.py5
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index b696a12e7a..9938f011d0 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -107,6 +107,8 @@ class FetchStrategy(object):
def archive(self, destination): pass # Used to create tarball for mirror.
+ def file_hash(self): pass # Identifies the resource to be retrieved
+
def __str__(self): # Should be human readable URL.
return "FetchStrategy.__str___"
@@ -217,6 +219,10 @@ class URLFetchStrategy(FetchStrategy):
"""Path to the source archive within this stage directory."""
return self.stage.archive_file
+ @property
+ def file_hash(self):
+ return self.digest
+
@_needs_stage
def expand(self):
if not self.expand_archive:
@@ -349,6 +355,10 @@ class VCSFetchStrategy(FetchStrategy):
self.stage.chdir()
tar('-czf', destination, os.path.basename(self.stage.source_path))
+ @property
+ def file_hash(self):
+ return None
+
def __str__(self):
return "VCS: %s" % self.url
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 6981f69ac0..cb2588fb29 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -61,7 +61,10 @@ def mirror_archive_filename(spec, fetcher):
# Otherwise we'll make a .tar.gz ourselves
ext = 'tar.gz'
- filename = "%s-%s" % (spec.package.name, spec.version)
+ tokens = [spec.package.name, spec.version]
+ if fetcher.file_hash:
+ tokens.append(fetcher.file_hash)
+ filename = '-'.join(str(t) for t in tokens)
if ext:
filename += ".%s" % ext
return filename