summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/fetch_strategy.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 180e8eb069..a71f3a1531 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -45,7 +45,7 @@ import re
import shutil
from functools import wraps
import llnl.util.tty as tty
-
+from llnl.util.filesystem import *
import spack
import spack.error
import spack.util.crypto as crypto
@@ -205,8 +205,26 @@ class URLFetchStrategy(FetchStrategy):
"Failed on expand() for URL %s" % self.url)
decompress = decompressor_for(self.archive_file)
+
+ # Expand all tarballs in their own directory to contain
+ # exploding tarballs.
+ tarball_container = os.path.join(self.stage.path, "spack-expanded-archive")
+ mkdirp(tarball_container)
+ os.chdir(tarball_container)
decompress(self.archive_file)
+ # If the tarball *didn't* explode, move
+ # the expanded directory up & remove the protector directory.
+ files = os.listdir(tarball_container)
+ if len(files) == 1:
+ expanded_dir = os.path.join(tarball_container, files[0])
+ if os.path.isdir(expanded_dir):
+ shutil.move(expanded_dir, self.stage.path)
+ os.rmdir(tarball_container)
+
+ # Set the wd back to the stage when done.
+ self.stage.chdir()
+
def archive(self, destination):
"""Just moves this archive to the destination."""