summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-12-22 23:28:07 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-12-22 23:28:07 -0800
commit887c29ddc4871a1d8568684bb0cc03a749724923 (patch)
treebf4a7d989601ebe817a675bb1ea515270c7d6941 /lib
parent983f35f32a9f421f93d9cae636aee6f182749b6f (diff)
parent722e73f3096e44240018475146e3d81b13d95937 (diff)
downloadspack-887c29ddc4871a1d8568684bb0cc03a749724923.tar.gz
spack-887c29ddc4871a1d8568684bb0cc03a749724923.tar.bz2
spack-887c29ddc4871a1d8568684bb0cc03a749724923.tar.xz
spack-887c29ddc4871a1d8568684bb0cc03a749724923.zip
Merge branch 'features/better-mirror-support' into develop
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/mirror.py3
-rw-r--r--lib/spack/spack/package.py14
-rw-r--r--lib/spack/spack/url.py21
3 files changed, 27 insertions, 11 deletions
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 9c700cd551..929c514b61 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -37,6 +37,7 @@ from llnl.util.filesystem import *
import spack
import spack.error
+import spack.url as url
import spack.fetch_strategy as fs
from spack.spec import Spec
from spack.stage import Stage
@@ -52,7 +53,7 @@ def mirror_archive_filename(spec):
fetcher = spec.package.fetcher
if isinstance(fetcher, fs.URLFetchStrategy):
# If we fetch this version with a URLFetchStrategy, use URL's archive type
- ext = extension(fetcher.url)
+ ext = url.downloaded_file_extension(fetcher.url)
else:
# Otherwise we'll make a .tar.gz ourselves
ext = 'tar.gz'
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 9c67b0bb51..fa91dbbbea 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -51,6 +51,7 @@ import spack
import spack.spec
import spack.error
import spack.compilers
+import spack.mirror
import spack.hooks
import spack.build_environment as build_env
import spack.url as url
@@ -453,9 +454,9 @@ class Package(object):
raise ValueError("Can only get a stage for a concrete package.")
if self._stage is None:
- self._stage = Stage(self.fetcher,
- mirror_path=self.mirror_path(),
- name=self.spec.short_spec)
+ mp = spack.mirror.mirror_archive_filename(self.spec)
+ self._stage = Stage(
+ self.fetcher, mirror_path=mp, name=self.spec.short_spec)
return self._stage
@@ -475,13 +476,6 @@ class Package(object):
self._fetcher = f
- def mirror_path(self):
- """Get path to this package's archive in a mirror."""
- filename = "%s-%s." % (self.name, self.version)
- filename += extension(self.url) if self.url else "tar.gz"
- return "%s/%s" % (self.name, filename)
-
-
def preorder_traversal(self, visited=None, **kwargs):
"""This does a preorder traversal of the package's dependence DAG."""
virtual = kwargs.get("virtual", False)
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
index 2948c12df5..58838306af 100644
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -140,6 +140,27 @@ def split_url_extension(path):
return prefix, ext, suffix
+def downloaded_file_extension(path):
+ """This returns the type of archive a URL refers to. This is
+ sometimes confusing becasue of URLs like:
+
+ (1) https://github.com/petdance/ack/tarball/1.93_02
+
+ Where the URL doesn't actually contain the filename. We need
+ to know what type it is so that we can appropriately name files
+ in mirrors.
+ """
+ match = re.search(r'github.com/.+/(zip|tar)ball/', path)
+ if match:
+ if match.group(1) == 'zip': return 'zip'
+ elif match.group(1) == 'tar': return 'tar.gz'
+
+ prefix, ext, suffix = split_url_extension(path)
+ if not ext:
+ raise UrlParseError("Cannot deduce archive type in %s" % path, path)
+ return ext
+
+
def parse_version_offset(path):
"""Try to extract a version string from a filename or URL. This is taken
largely from Homebrew's Version class."""