summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Klähn <github@web.jklaehn.de>2017-11-03 19:29:43 +0100
committerscheibelp <scheibel1@llnl.gov>2017-11-03 11:29:43 -0700
commit3fc8a71afb1fe7e6cd79c448e18ec03b4edae07d (patch)
treecd1f4526b9b43eaa904566a1944d1dfe2cf28cf3
parent12f0725e9f1afb70ab3b60bc398a19eb70d36100 (diff)
downloadspack-3fc8a71afb1fe7e6cd79c448e18ec03b4edae07d.tar.gz
spack-3fc8a71afb1fe7e6cd79c448e18ec03b4edae07d.tar.bz2
spack-3fc8a71afb1fe7e6cd79c448e18ec03b4edae07d.tar.xz
spack-3fc8a71afb1fe7e6cd79c448e18ec03b4edae07d.zip
Fix restaging of resources (#5681)
Part of the resource staging process is to place downloaded/expanded files in the root stage. This was not happening when a resource stage was restaged.
-rw-r--r--lib/spack/spack/stage.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 0fc75b1c08..f0bede952d 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -526,8 +526,18 @@ class ResourceStage(Stage):
self.root_stage = root
self.resource = resource
+ def restage(self):
+ super(ResourceStage, self).restage()
+ self._add_to_root_stage()
+
def expand_archive(self):
super(ResourceStage, self).expand_archive()
+ self._add_to_root_stage()
+
+ def _add_to_root_stage(self):
+ """
+ Move the extracted resource to the root stage (according to placement).
+ """
root_stage = self.root_stage
resource = self.resource
placement = os.path.basename(self.source_path) \
@@ -535,23 +545,23 @@ class ResourceStage(Stage):
else resource.placement
if not isinstance(placement, dict):
placement = {'': placement}
- # Make the paths in the dictionary absolute and link
+
+ target_path = join_path(
+ root_stage.source_path, resource.destination)
+
+ try:
+ os.makedirs(target_path)
+ except OSError as err:
+ if err.errno == errno.EEXIST and os.path.isdir(target_path):
+ pass
+ else:
+ raise
+
for key, value in iteritems(placement):
- target_path = join_path(
- root_stage.source_path, resource.destination)
destination_path = join_path(target_path, value)
source_path = join_path(self.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
-
if not os.path.exists(destination_path):
- # Create a symlink
tty.info('Moving resource stage\n\tsource : '
'{stage}\n\tdestination : {destination}'.format(
stage=source_path, destination=destination_path