Bug fixes for URLs and mirror fetching.

This commit is contained in:
Todd Gamblin 2014-10-16 06:56:00 -07:00
parent 6fdfd83e6b
commit fb3003f664
8 changed files with 41 additions and 27 deletions

View File

@ -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):

View File

@ -70,6 +70,7 @@ def concretize_version(self, spec):
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:

View File

@ -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 @@ def __init__(self, url, msg=""):
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)

View File

@ -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

View File

@ -32,7 +32,7 @@
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 @@ def __init__(self, url_or_fetch_strategy, **kwargs):
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 @@ def _setup(self):
@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 @@ def fetch(self):
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 @@ def __init__(self, message, long_message=None):
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 @@ def __init__(self, message, long_msg=None):
# Keep this in namespace for convenience
FailedDownloadError = spack.fetch_strategy.FailedDownloadError
FailedDownloadError = fs.FailedDownloadError

View File

@ -27,9 +27,8 @@
class Libmonitor(Package):
"""Libmonitor is a library for process and thread control."""
homepage = "http://hpctoolkit.org"
url = "file:///g/g0/legendre/tools/oss/openspeedshop-release-2.1/SOURCES/libmonitor-20130218.tar.gz"
version('20130218', 'aa85c2c580e2dafb823cc47b09374279')
version('20130218', svn='https://outreach.scidac.gov/svn/libmonitor/trunk', revision=146)
def install(self, spec, prefix):
configure("--prefix=" + prefix)

View File

@ -7,9 +7,9 @@ class Paraver(Package):
is expressed on its input trace format. Traces for parallel MPI,
OpenMP and other programs can be genereated with Extrae."""
homepage = "http://www.bsc.es/computer-sciences/performance-tools/paraver"
url = "http://www.bsc.es/ssl/apps/performanceTools/files/paraver-sources-4.5.2.tar.gz"
url = "http://www.bsc.es/ssl/apps/performanceTools/files/paraver-sources-4.5.3.tar.gz"
version('4.5.2', 'ea463dd494519395c99ebae294edee17')
version('4.5.3', '625de9ec0d639acd18d1aaa644b38f72')
depends_on("boost")
#depends_on("extrae")

View File

@ -5,8 +5,8 @@ class Stat(Package):
homepage = "http://paradyn.org/STAT/STAT.html"
url = "https://github.com/lee218llnl/stat/archive/v2.0.0.tar.gz"
version('2.0.0', 'c7494210b0ba26b577171b92838e1a9b')
version('2.1.0', 'ece26beaf057aa9134d62adcdda1ba91')
version('2.0.0', 'c7494210b0ba26b577171b92838e1a9b')
depends_on('libdwarf')
depends_on('dyninst')