From 37bdbdd9906bb4d89f917732325a346c5cdbb31f Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 25 Dec 2014 17:55:43 -0800 Subject: URLFetchStrategy now contains exploding tarballs. --- lib/spack/spack/fetch_strategy.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib') 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.""" -- cgit v1.2.3-70-g09d2