diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/package.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 84bcb15f7f..fe82d58394 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -34,7 +34,9 @@ rundown on spack and how it differs from homebrew, look at the README. """ import os +import errno import re +import shutil import time import itertools import subprocess @@ -696,7 +698,9 @@ class Package(object): ########## # Stage resources in appropriate path resources = self._get_resources() - for resource in resources: + # TODO: this is to allow nested resources, a better solution would be + # good + for resource in sorted(resources, key=lambda res: len(res.destination)): stage = resource.fetcher.stage _expand_archive(stage, resource.name) # Turn placement into a dict with relative paths @@ -705,11 +709,23 @@ class Package(object): placement = {'': placement} # Make the paths in the dictionary absolute and link for key, value in placement.iteritems(): - link_path = join_path(self.stage.source_path, resource.destination, value) + target_path = join_path(self.stage.source_path, resource.destination) + link_path = join_path(target_path, value) source_path = join_path(stage.source_path, key) + + try: + os.makedirs(target_path) + except OSError as err: + if err.errno == errno.EEXIST and os.path.isdir(target_path): + pass + else: raise + + # NOTE: a reasonable fix for the TODO above might be to have + # these expand in place, but expand_archive does not offer + # this + if not os.path.exists(link_path): - # Create a symlink - os.symlink(source_path, link_path) + shutil.move(source_path, link_path) ########## self.stage.chdir_to_source() |