summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-10-16 06:56:00 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-10-16 06:56:00 -0700
commitfb3003f664d13f95c1d8c6e2c430924165bd576f (patch)
tree07abbada36be08159dcc8da39390c6882d26055c /lib
parent6fdfd83e6b0f776bf79d9de0af82bcfc311072f9 (diff)
downloadspack-fb3003f664d13f95c1d8c6e2c430924165bd576f.tar.gz
spack-fb3003f664d13f95c1d8c6e2c430924165bd576f.tar.bz2
spack-fb3003f664d13f95c1d8c6e2c430924165bd576f.tar.xz
spack-fb3003f664d13f95c1d8c6e2c430924165bd576f.zip
Bug fixes for URLs and mirror fetching.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/mirror.py9
-rw-r--r--lib/spack/spack/concretize.py1
-rw-r--r--lib/spack/spack/fetch_strategy.py24
-rw-r--r--lib/spack/spack/mirror.py2
-rw-r--r--lib/spack/spack/stage.py23
5 files changed, 37 insertions, 22 deletions
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 6e2e4dfb24..22838e1344 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -71,8 +71,12 @@ def setup_parser(subparser):
def mirror_add(args):
"""Add a mirror to Spack."""
+ url = args.url
+ if url.startswith('/'):
+ url = 'file://' + url
+
config = spack.config.get_config('user')
- config.set_value('mirror', args.name, 'url', args.url)
+ config.set_value('mirror', args.name, 'url', url)
config.write()
@@ -158,6 +162,9 @@ def mirror_create(args):
" %-4d already present" % p,
" %-4d added" % m,
" %-4d failed to fetch." % e)
+ if error:
+ tty.error("Failed downloads:")
+ colify(s.format("$_$@") for s in error)
def mirror(parser, args):
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index e603806af9..eee8cb7fde 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -70,6 +70,7 @@ class DefaultConcretizer(object):
pkg = spec.package
valid_versions = [v for v in pkg.available_versions
if any(v.satisfies(sv) for sv in spec.versions)]
+
if valid_versions:
spec.versions = ver([valid_versions[-1]])
else:
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 2b574eaba7..5a508b130c 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -559,7 +559,7 @@ def for_package_version(pkg, version):
url = pkg.url_for_verison(version)
if not url:
raise InvalidArgsError(pkg, version)
- return URLFetchStrategy()
+ return URLFetchStrategy(url)
# Grab a dict of args out of the package version dict
args = pkg.versions[version]
@@ -574,6 +574,8 @@ def for_package_version(pkg, version):
for fetcher in all_strategies:
attrs = dict((attr, getattr(pkg, attr, None))
for attr in fetcher.required_attributes)
+ if 'url' in attrs:
+ attrs['url'] = pkg.url_for_version(version)
attrs.update(args)
if fetcher.matches(attrs):
return fetcher(**attrs)
@@ -581,12 +583,12 @@ def for_package_version(pkg, version):
raise InvalidArgsError(pkg, version)
-class FetchStrategyError(spack.error.SpackError):
+class FetchError(spack.error.SpackError):
def __init__(self, msg, long_msg):
- super(FetchStrategyError, self).__init__(msg, long_msg)
+ super(FetchError, self).__init__(msg, long_msg)
-class FailedDownloadError(FetchStrategyError):
+class FailedDownloadError(FetchError):
"""Raised wen a download fails."""
def __init__(self, url, msg=""):
super(FailedDownloadError, self).__init__(
@@ -594,18 +596,26 @@ class FailedDownloadError(FetchStrategyError):
self.url = url
-class NoArchiveFileError(FetchStrategyError):
+class NoArchiveFileError(FetchError):
def __init__(self, msg, long_msg):
super(NoArchiveFileError, self).__init__(msg, long_msg)
-class NoDigestError(FetchStrategyError):
+class NoDigestError(FetchError):
def __init__(self, msg, long_msg):
super(NoDigestError, self).__init__(msg, long_msg)
-class InvalidArgsError(FetchStrategyError):
+class InvalidArgsError(FetchError):
def __init__(self, pkg, version):
msg = "Could not construct a fetch strategy for package %s at version %s"
msg %= (pkg.name, version)
super(InvalidArgsError, self).__init__(msg)
+
+
+class ChecksumError(FetchError):
+ """Raised when archive fails to checksum."""
+ def __init__(self, message, long_msg=None):
+ super(ChecksumError, self).__init__(message, long_msg)
+
+
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index f7bbb3f840..2f822b13ab 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -146,7 +146,7 @@ def create(path, specs, **kwargs):
archive_file = mirror_archive_filename(spec)
archive_path = join_path(subdir, archive_file)
- if os.path.exists(archive_file):
+ if os.path.exists(archive_path):
tty.msg("%s is already present. Skipping." % spec.format("$_$@"))
present.append(spec)
continue
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 0d684df92d..b371761785 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -32,7 +32,7 @@ from llnl.util.filesystem import *
import spack
import spack.config
-import spack.fetch_strategy as fetch_strategy
+import spack.fetch_strategy as fs
import spack.error
@@ -83,8 +83,8 @@ class Stage(object):
stage will be given a unique name automatically.
"""
if isinstance(url_or_fetch_strategy, basestring):
- self.fetcher = fetch_strategy.from_url(url_or_fetch_strategy)
- elif isinstance(url_or_fetch_strategy, fetch_strategy.FetchStrategy):
+ self.fetcher = fs.from_url(url_or_fetch_strategy)
+ elif isinstance(url_or_fetch_strategy, fs.FetchStrategy):
self.fetcher = url_or_fetch_strategy
else:
raise ValueError("Can't construct Stage without url or fetch strategy")
@@ -198,7 +198,10 @@ class Stage(object):
@property
def archive_file(self):
"""Path to the source archive within this stage directory."""
- paths = [os.path.join(self.path, os.path.basename(self.url))]
+ if not isinstance(self.fetcher, fs.URLFetchStrategy):
+ return None
+
+ paths = [os.path.join(self.path, os.path.basename(self.fetcher.url))]
if self.mirror_path:
paths.append(os.path.join(self.path, os.path.basename(self.mirror_path)))
@@ -242,9 +245,9 @@ class Stage(object):
urls = ["%s/%s" % (m, self.mirror_path) for m in _get_mirrors()]
digest = None
- if isinstance(self.fetcher, fetch_strategy.URLFetchStrategy):
+ if isinstance(self.fetcher, fs.URLFetchStrategy):
digest = self.fetcher.digest
- fetchers = [fetch_strategy.URLFetchStrategy(url, digest)
+ fetchers = [fs.URLFetchStrategy(url, digest)
for url in urls] + fetchers
for f in fetchers:
f.set_stage(self)
@@ -365,12 +368,6 @@ class StageError(spack.error.SpackError):
super(self, StageError).__init__(message, long_message)
-class ChecksumError(StageError):
- """Raised when archive fails to checksum."""
- def __init__(self, message, long_msg=None):
- super(ChecksumError, self).__init__(message, long_msg)
-
-
class RestageError(StageError):
def __init__(self, message, long_msg=None):
super(RestageError, self).__init__(message, long_msg)
@@ -382,4 +379,4 @@ class ChdirError(StageError):
# Keep this in namespace for convenience
-FailedDownloadError = spack.fetch_strategy.FailedDownloadError
+FailedDownloadError = fs.FailedDownloadError