summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2022-07-13 14:12:21 -0700
committerGitHub <noreply@github.com>2022-07-13 14:12:21 -0700
commit7741bfb7d1628d8f2e17284e34cbb8d4a69f3553 (patch)
tree63f78bc27ccd8d0b10c434c662fca6dccca62dee /lib
parentd25315c2f6e2be4aeda121dfbafc9ad943fb7a0c (diff)
downloadspack-7741bfb7d1628d8f2e17284e34cbb8d4a69f3553.tar.gz
spack-7741bfb7d1628d8f2e17284e34cbb8d4a69f3553.tar.bz2
spack-7741bfb7d1628d8f2e17284e34cbb8d4a69f3553.tar.xz
spack-7741bfb7d1628d8f2e17284e34cbb8d4a69f3553.zip
Decompression: use tar exe vs. built-in Python tarfile support (#31563)
Python's built-in tarfile support doesn't address some general cases of malformed tarfiles that are already handled by the system 'tar' utility; until these can be addressed, use that exclusively.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/compression.py23
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/spack/spack/util/compression.py b/lib/spack/spack/util/compression.py
index 859f4faa28..5be3fbf338 100644
--- a/lib/spack/spack/util/compression.py
+++ b/lib/spack/spack/util/compression.py
@@ -73,25 +73,10 @@ def _untar(archive_file):
"""
_, ext = os.path.splitext(archive_file)
outfile = os.path.basename(archive_file.strip(ext))
- uncompress_required = 'Z' in ext
- lzma_required = 'xz' in ext
- lzma_needed_and_not_available = not lzma_support() and lzma_required
- if tar_support() and not uncompress_required and\
- not lzma_needed_and_not_available:
- import tarfile
-
- # Extract all members but wipe ownership info. This ensures we
- # will not attempt to chown the files as superuser.
- def filter(tarinfo):
- tarinfo.uid = tarinfo.gid = 0
- tarinfo.uname = tarinfo.gname = 'root'
- return tarinfo
- with tarfile.open(archive_file) as tar:
- tar.extractall(members=map(filter, tar.getmembers()))
- else:
- tar = which('tar', required=True)
- tar.add_default_arg('-oxf')
- tar(archive_file)
+
+ tar = which('tar', required=True)
+ tar.add_default_arg('-oxf')
+ tar(archive_file)
return outfile