URLFetchStrategy now contains exploding tarballs.

This commit is contained in:
Todd Gamblin 2014-12-25 17:55:43 -08:00
parent 887c29ddc4
commit 37bdbdd990

View file

@ -45,7 +45,7 @@
import shutil import shutil
from functools import wraps from functools import wraps
import llnl.util.tty as tty import llnl.util.tty as tty
from llnl.util.filesystem import *
import spack import spack
import spack.error import spack.error
import spack.util.crypto as crypto import spack.util.crypto as crypto
@ -205,8 +205,26 @@ def expand(self):
"Failed on expand() for URL %s" % self.url) "Failed on expand() for URL %s" % self.url)
decompress = decompressor_for(self.archive_file) 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) 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): def archive(self, destination):
"""Just moves this archive to the destination.""" """Just moves this archive to the destination."""