package : minor syntax fixes
mirror : extracted add_single_spec from create
This commit is contained in:
parent
d649b715ed
commit
9001b9ed3c
2 changed files with 54 additions and 48 deletions
|
@ -110,7 +110,6 @@ def suggest_archive_basename(resource):
|
||||||
return basename
|
return basename
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create(path, specs, **kwargs):
|
def create(path, specs, **kwargs):
|
||||||
"""Create a directory to be used as a spack mirror, and fill it with
|
"""Create a directory to be used as a spack mirror, and fill it with
|
||||||
package archives.
|
package archives.
|
||||||
|
@ -158,58 +157,65 @@ def create(path, specs, **kwargs):
|
||||||
"Cannot create directory '%s':" % mirror_root, str(e))
|
"Cannot create directory '%s':" % mirror_root, str(e))
|
||||||
|
|
||||||
# Things to keep track of while parsing specs.
|
# Things to keep track of while parsing specs.
|
||||||
present = []
|
categories = {
|
||||||
mirrored = []
|
'present': [],
|
||||||
error = []
|
'mirrored': [],
|
||||||
|
'error': []
|
||||||
|
}
|
||||||
|
|
||||||
# Iterate through packages and download all the safe tarballs for each of them
|
# Iterate through packages and download all the safe tarballs for each of them
|
||||||
everything_already_exists = True
|
|
||||||
for spec in version_specs:
|
for spec in version_specs:
|
||||||
pkg = spec.package
|
add_single_spec(spec, mirror_root, categories, **kwargs)
|
||||||
tty.msg("Adding package {pkg} to mirror".format(pkg=spec.format("$_$@")))
|
|
||||||
try:
|
|
||||||
with pkg.stage:
|
|
||||||
for ii, stage in enumerate(pkg.stage):
|
|
||||||
fetcher = stage.fetcher
|
|
||||||
if ii == 0:
|
|
||||||
# create a subdirectory for the current package@version
|
|
||||||
archive_path = os.path.abspath(join_path(mirror_root, mirror_archive_path(spec, fetcher)))
|
|
||||||
name = spec.format("$_$@")
|
|
||||||
else:
|
|
||||||
resource = stage.resource
|
|
||||||
archive_path = join_path(subdir, suggest_archive_basename(resource))
|
|
||||||
name = "{resource} ({pkg}).".format(resource=resource.name, pkg=spec.format("$_$@"))
|
|
||||||
subdir = os.path.dirname(archive_path)
|
|
||||||
mkdirp(subdir)
|
|
||||||
|
|
||||||
if os.path.exists(archive_path):
|
return categories['present'], categories['mirrored'], categories['error']
|
||||||
tty.msg("{name} : already added".format(name=name))
|
|
||||||
else:
|
|
||||||
everything_already_exists = False
|
|
||||||
fetcher.fetch()
|
|
||||||
if not kwargs.get('no_checksum', False):
|
|
||||||
fetcher.check()
|
|
||||||
tty.msg("{name} : checksum passed".format(name=name))
|
|
||||||
|
|
||||||
# Fetchers have to know how to archive their files. Use
|
|
||||||
# that to move/copy/create an archive in the mirror.
|
|
||||||
fetcher.archive(archive_path)
|
|
||||||
tty.msg("{name} : added".format(name=name))
|
|
||||||
|
|
||||||
if everything_already_exists:
|
def add_single_spec(spec, mirror_root, categories, **kwargs):
|
||||||
present.append(spec)
|
tty.msg("Adding package {pkg} to mirror".format(pkg=spec.format("$_$@")))
|
||||||
else:
|
spec_exists_in_mirror = True
|
||||||
mirrored.append(spec)
|
try:
|
||||||
except Exception, e:
|
with spec.package.stage:
|
||||||
if spack.debug:
|
# fetcher = stage.fetcher
|
||||||
sys.excepthook(*sys.exc_info())
|
# fetcher.fetch()
|
||||||
else:
|
# ...
|
||||||
tty.warn("Error while fetching %s." % spec.format('$_$@'), e.message)
|
# fetcher.archive(archive_path)
|
||||||
error.append(spec)
|
for ii, stage in enumerate(spec.package.stage):
|
||||||
finally:
|
fetcher = stage.fetcher
|
||||||
pkg.stage.destroy()
|
if ii == 0:
|
||||||
|
# create a subdirectory for the current package@version
|
||||||
|
archive_path = os.path.abspath(join_path(mirror_root, mirror_archive_path(spec, fetcher)))
|
||||||
|
name = spec.format("$_$@")
|
||||||
|
else:
|
||||||
|
resource = stage.resource
|
||||||
|
archive_path = join_path(subdir, suggest_archive_basename(resource))
|
||||||
|
name = "{resource} ({pkg}).".format(resource=resource.name, pkg=spec.format("$_$@"))
|
||||||
|
subdir = os.path.dirname(archive_path)
|
||||||
|
mkdirp(subdir)
|
||||||
|
|
||||||
return (present, mirrored, error)
|
if os.path.exists(archive_path):
|
||||||
|
tty.msg("{name} : already added".format(name=name))
|
||||||
|
else:
|
||||||
|
spec_exists_in_mirror = False
|
||||||
|
fetcher.fetch()
|
||||||
|
if not kwargs.get('no_checksum', False):
|
||||||
|
fetcher.check()
|
||||||
|
tty.msg("{name} : checksum passed".format(name=name))
|
||||||
|
|
||||||
|
# Fetchers have to know how to archive their files. Use
|
||||||
|
# that to move/copy/create an archive in the mirror.
|
||||||
|
fetcher.archive(archive_path)
|
||||||
|
tty.msg("{name} : added".format(name=name))
|
||||||
|
|
||||||
|
if spec_exists_in_mirror:
|
||||||
|
categories['present'].append(spec)
|
||||||
|
else:
|
||||||
|
categories['mirrored'].append(spec)
|
||||||
|
except Exception as e:
|
||||||
|
if spack.debug:
|
||||||
|
sys.excepthook(*sys.exc_info())
|
||||||
|
else:
|
||||||
|
tty.warn("Error while fetching %s." % spec.format('$_$@'), e.message)
|
||||||
|
categories['error'].append(spec)
|
||||||
|
|
||||||
|
|
||||||
class MirrorError(spack.error.SpackError):
|
class MirrorError(spack.error.SpackError):
|
||||||
|
|
|
@ -732,7 +732,7 @@ def do_patch(self):
|
||||||
# If we encounter an archive that failed to patch, restage it
|
# If we encounter an archive that failed to patch, restage it
|
||||||
# so that we can apply all the patches again.
|
# so that we can apply all the patches again.
|
||||||
if os.path.isfile(bad_file):
|
if os.path.isfile(bad_file):
|
||||||
tty.msg("Patching failed last time. Restaging.")
|
tty.msg("Patching failed last time. Restaging.")
|
||||||
self.stage.restage()
|
self.stage.restage()
|
||||||
|
|
||||||
self.stage.chdir_to_source()
|
self.stage.chdir_to_source()
|
||||||
|
@ -912,7 +912,7 @@ def real_work():
|
||||||
% (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
|
% (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
|
||||||
print_pkg(self.prefix)
|
print_pkg(self.prefix)
|
||||||
|
|
||||||
except ProcessError, e:
|
except ProcessError as e:
|
||||||
# Annotate with location of build log.
|
# Annotate with location of build log.
|
||||||
e.build_log = log_path
|
e.build_log = log_path
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
Loading…
Reference in a new issue