summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-12-25 17:55:43 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-12-25 17:57:55 -0800
commit37bdbdd9906bb4d89f917732325a346c5cdbb31f (patch)
tree254b95120d435e9047874aef0d9f056ce455d7e9 /lib
parent887c29ddc4871a1d8568684bb0cc03a749724923 (diff)
downloadspack-37bdbdd9906bb4d89f917732325a346c5cdbb31f.tar.gz
spack-37bdbdd9906bb4d89f917732325a346c5cdbb31f.tar.bz2
spack-37bdbdd9906bb4d89f917732325a346c5cdbb31f.tar.xz
spack-37bdbdd9906bb4d89f917732325a346c5cdbb31f.zip
URLFetchStrategy now contains exploding tarballs.
Diffstat (limited to 'lib')
-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."""