summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2017-05-12 09:52:01 -0500
committerGitHub <noreply@github.com>2017-05-12 09:52:01 -0500
commit1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8 (patch)
treee1dc37b6ba580da22401861e4f0d4dcb76c5453e /lib
parentd972ba7fbcb61b245d9c19eb84adb34fe02e4da1 (diff)
downloadspack-1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8.tar.gz
spack-1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8.tar.bz2
spack-1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8.tar.xz
spack-1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8.zip
Add helpful error message for uncompressed downloads (#4205)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/mirror.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index c9ed617dc8..1c0618e6e0 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -53,13 +53,33 @@ def mirror_archive_filename(spec, fetcher, resourceId=None):
if fetcher.expand_archive:
# If we fetch with a URLFetchStrategy, use URL's archive type
ext = url.determine_url_file_extension(fetcher.url)
- ext = ext or spec.package.versions[spec.package.version].get(
- 'extension', None)
- ext = ext.lstrip('.')
+
+ # If the filename does not end with a normal suffix,
+ # see if the package explicitly declares the extension
if not ext:
- raise MirrorError(
- "%s version does not specify an extension" % spec.name +
- " and could not parse extension from %s" % fetcher.url)
+ ext = spec.package.versions[spec.package.version].get(
+ 'extension', None)
+
+ if ext:
+ # Remove any leading dots
+ ext = ext.lstrip('.')
+
+ if not ext:
+ msg = """\
+Unable to parse extension from {0}.
+
+If this URL is for a tarball but does not include the file extension
+in the name, you can explicitly declare it with the following syntax:
+
+ version('1.2.3', 'hash', extension='tar.gz')
+
+If this URL is for a download like a .jar or .whl that does not need
+to be expanded, or an uncompressed installation script, you can tell
+Spack not to expand it with the following syntax:
+
+ version('1.2.3', 'hash', expand=False)
+"""
+ raise MirrorError(msg.format(fetcher.url))
else:
# If the archive shouldn't be expanded, don't check extension.
ext = None