summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-01-26 12:08:28 +0100
committeralalazo <massimiliano.culpo@googlemail.com>2016-01-26 12:08:28 +0100
commit093b8317998c395ed3e2dee7f19d1bdcea1b0560 (patch)
treeadb7d2430a9be9aabae5036ff57a729a795af868 /lib
parent6f11a64af5b994b31100e0313c25dfb4f6227255 (diff)
downloadspack-093b8317998c395ed3e2dee7f19d1bdcea1b0560.tar.gz
spack-093b8317998c395ed3e2dee7f19d1bdcea1b0560.tar.bz2
spack-093b8317998c395ed3e2dee7f19d1bdcea1b0560.tar.xz
spack-093b8317998c395ed3e2dee7f19d1bdcea1b0560.zip
Fixes issues introduced after merge with conflicts
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/package.py3
-rw-r--r--lib/spack/spack/stage.py43
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 06aecf11bd..14cbc0dbce 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -804,6 +804,9 @@ class Package(object):
for when_spec, resource_list in self.resources.items():
if when_spec in self.spec:
resources.extend(resource_list)
+ # Sorts the resources by the length of the string representing their destination. Since any nested resource
+ # must contain another resource's name in its path, it seems that should work
+ resources = sorted(resources, key=lambda res: len(res.destination))
return resources
def _resource_stage(self, resource):
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 1deac1137c..6ba301d95f 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -1,4 +1,4 @@
-##############################################################################
+1 ##############################################################################
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
@@ -23,7 +23,7 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
-import re
+import errno
import shutil
import tempfile
from urlparse import urljoin
@@ -38,7 +38,6 @@ import spack.config
import spack.fetch_strategy as fs
import spack.error
-
STAGE_PREFIX = 'spack-stage-'
@@ -95,7 +94,7 @@ class Stage(object):
raise ValueError("Can't construct Stage without url or fetch strategy")
self.fetcher.set_stage(self)
self.default_fetcher = self.fetcher # self.fetcher can change with mirrors.
- self.skip_checksum_for_mirror = True # used for mirrored archives of repositories.
+ self.skip_checksum_for_mirror = True # used for mirrored archives of repositories.
self.name = kwargs.get('name')
self.mirror_path = kwargs.get('mirror_path')
@@ -104,7 +103,6 @@ class Stage(object):
self.path = None
self._setup()
-
def _cleanup_dead_links(self):
"""Remove any dead links in the stage directory."""
for file in os.listdir(spack.stage_path):
@@ -114,7 +112,6 @@ class Stage(object):
if not os.path.exists(path):
os.unlink(path)
-
def _need_to_create_path(self):
"""Makes sure nothing weird has happened since the last time we
looked at path. Returns True if path already exists and is ok.
@@ -132,7 +129,7 @@ class Stage(object):
# Path looks ok, but need to check the target of the link.
if os.path.islink(self.path):
real_path = os.path.realpath(self.path)
- real_tmp = os.path.realpath(self.tmp_root)
+ real_tmp = os.path.realpath(self.tmp_root)
if spack.use_tmp_stage:
# If we're using a tmp dir, it's a link, and it points at the right spot,
@@ -151,7 +148,6 @@ class Stage(object):
return False
-
def _setup(self):
"""Creates the stage directory.
If spack.use_tmp_stage is False, the stage directory is created
@@ -200,7 +196,6 @@ class Stage(object):
# Make sure we can actually do something with the stage we made.
ensure_access(self.path)
-
@property
def archive_file(self):
"""Path to the source archive within this stage directory."""
@@ -217,7 +212,6 @@ class Stage(object):
else:
return None
-
@property
def source_path(self):
"""Returns the path to the expanded/checked out source code
@@ -232,7 +226,6 @@ class Stage(object):
return p
return None
-
def chdir(self):
"""Changes directory to the stage path. Or dies if it is not set up."""
if os.path.isdir(self.path):
@@ -240,7 +233,6 @@ class Stage(object):
else:
tty.die("Setup failed: no such directory: " + self.path)
-
def fetch(self, mirror_only=False):
"""Downloads an archive or checks out code from a repository."""
self.chdir()
@@ -293,7 +285,6 @@ class Stage(object):
self.fetcher = self.default_fetcher
raise fs.FetchError(errMessage, None)
-
def check(self):
"""Check the downloaded archive against a checksum digest.
No-op if this stage checks code out of a repository."""
@@ -307,7 +298,6 @@ class Stage(object):
else:
self.fetcher.check()
-
def expand_archive(self):
"""Changes to the stage directory and attempt to expand the downloaded
archive. Fail if the stage is not set up or if the archive is not yet
@@ -320,7 +310,6 @@ class Stage(object):
else:
tty.msg("Already staged %s in %s." % (self.name, self.path))
-
def chdir_to_source(self):
"""Changes directory to the expanded archive directory.
Dies with an error if there was no expanded archive.
@@ -333,14 +322,12 @@ class Stage(object):
if not os.listdir(path):
tty.die("Archive was empty for %s" % self.name)
-
def restage(self):
"""Removes the expanded archive path if it exists, then re-expands
the archive.
"""
self.fetcher.reset()
-
def destroy(self):
"""Remove this stage directory."""
remove_linked_tree(self.path)
@@ -367,11 +354,24 @@ class ResourceStage(Stage):
placement = {'': placement}
# Make the paths in the dictionary absolute and link
for key, value in placement.iteritems():
- link_path = join_path(root_stage.source_path, resource.destination, value)
+ 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)
- if not os.path.exists(link_path):
+
+ 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
- os.symlink(source_path, link_path)
+ tty.info('Moving resource stage\n\tsource : {stage}\n\tdestination : {destination}'.format(
+ stage=source_path, destination=destination_path
+ ))
+ shutil.move(source_path, destination_path)
@pattern.composite(method_list=['fetch', 'check', 'expand_archive', 'restage', 'destroy'])
@@ -380,6 +380,7 @@ class StageComposite:
Composite for Stage type objects. The first item in this composite is considered to be the root package, and
operations that return a value are forwarded to it.
"""
+
@property
def source_path(self):
return self[0].source_path
@@ -394,6 +395,7 @@ class StageComposite:
class DIYStage(object):
"""Simple class that allows any directory to be a spack stage."""
+
def __init__(self, path):
self.archive_file = None
self.path = path
@@ -431,7 +433,6 @@ def _get_mirrors():
return [val for name, val in config.iteritems()]
-
def ensure_access(file=spack.stage_path):
"""Ensure we can access a directory and die with an error if we can't."""
if not can_access(file):