From 1a6b4afe7f0c382f98534f57a0a859ebc21b3eb8 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 12 May 2017 09:52:01 -0500 Subject: Add helpful error message for uncompressed downloads (#4205) --- lib/spack/spack/mirror.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-70-g09d2