Fixes issues introduced after merge with conflicts

This commit is contained in:
alalazo 2016-01-26 12:08:28 +01:00
parent 6f11a64af5
commit 093b831799
2 changed files with 25 additions and 21 deletions

View file

@ -804,6 +804,9 @@ def _get_resources(self):
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):

View file

@ -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.fetch_strategy as fs
import spack.error
STAGE_PREFIX = 'spack-stage-'
@ -104,7 +103,6 @@ def __init__(self, url_or_fetch_strategy, **kwargs):
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 @@ def _cleanup_dead_links(self):
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.
@ -151,7 +148,6 @@ def _need_to_create_path(self):
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 @@ def _setup(self):
# 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 @@ def archive_file(self):
else:
return None
@property
def source_path(self):
"""Returns the path to the expanded/checked out source code
@ -232,7 +226,6 @@ def source_path(self):
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 @@ def chdir(self):
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 @@ def fetch(self, mirror_only=False):
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 @@ def check(self):
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 @@ def expand_archive(self):
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 @@ def chdir_to_source(self):
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 @@ def expand_archive(self):
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 @@ def chdir_to_source(self):
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):