summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2022-06-07 14:12:08 -0700
committerGitHub <noreply@github.com>2022-06-07 14:12:08 -0700
commitc724e26ba98a0577f040ed4691a36a44a3c2ea5f (patch)
treef32ac3dd6c8d23bb58439559c13f74145bac81df /lib
parent1b9a1992fb389520d2f392f4e7a345115c117652 (diff)
downloadspack-c724e26ba98a0577f040ed4691a36a44a3c2ea5f.tar.gz
spack-c724e26ba98a0577f040ed4691a36a44a3c2ea5f.tar.bz2
spack-c724e26ba98a0577f040ed4691a36a44a3c2ea5f.tar.xz
spack-c724e26ba98a0577f040ed4691a36a44a3c2ea5f.zip
Staging: determine extensions from nonstandard URLs (#31027)
Fixes #31021 With #25185, we no longer default to using tar when we can't determine the extension type, opting to fail instead. This broke fetching for the pcre package, where we couldn't determine the extension. To determine the extension, we were attempting to extract it from the destination filename; however, this file name may omit details of the origin URL that are required to determine the extension, so instead we examine the URL directly. This also updates the decompressor_for method not to set ext=None by default: it must now always be set by the caller.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py2
-rw-r--r--lib/spack/spack/util/compression.py5
2 files changed, 2 insertions, 5 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index aaec9a40cd..bd7331e1a1 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -521,7 +521,7 @@ class URLFetchStrategy(FetchStrategy):
"Failed on expand() for URL %s" % self.url)
if not self.extension:
- self.extension = extension(self.archive_file)
+ self.extension = extension(self.url)
if self.stage.expanded:
tty.debug('Source already staged to %s' % self.stage.source_path)
diff --git a/lib/spack/spack/util/compression.py b/lib/spack/spack/util/compression.py
index 9a8eda0c91..18c0a9ea5e 100644
--- a/lib/spack/spack/util/compression.py
+++ b/lib/spack/spack/util/compression.py
@@ -246,7 +246,7 @@ unable to extract %s files. 7z can be installed via Spack" % ext)
return outfile
-def decompressor_for(path, ext=None):
+def decompressor_for(path, ext):
"""Returns a function pointer to appropriate decompression
algorithm based on extension type.
@@ -254,9 +254,6 @@ def decompressor_for(path, ext=None):
path (str): path of the archive file requiring decompression
ext (str): Extension of archive file
"""
- if not ext:
- ext = extension(path)
-
if not allowed_archive(ext):
raise CommandNotFoundError("Cannot extract archive, \
unrecognized file extension: '%s'" % ext)