Fix bug in mirror path construction.

This commit is contained in:
Todd Gamblin 2015-01-07 17:41:24 -05:00
parent 0ac6ffb3ef
commit ba593ccb26
3 changed files with 13 additions and 10 deletions

View File

@ -46,7 +46,7 @@
def mirror_archive_filename(spec):
"""Get the path that this spec will live at within a mirror."""
"""Get the name of the spec's archive in the mirror."""
if not spec.version.concrete:
raise ValueError("mirror.path requires spec with concrete version.")
@ -61,6 +61,11 @@ def mirror_archive_filename(spec):
return "%s-%s.%s" % (spec.package.name, spec.version, ext)
def mirror_archive_path(spec):
"""Get the relative path to the spec's archive within a mirror."""
return join_path(spec.name, mirror_archive_filename(spec))
def get_matching_versions(specs, **kwargs):
"""Get a spec for EACH known version matching any spec in the list."""
matching = []
@ -141,12 +146,10 @@ def create(path, specs, **kwargs):
stage = None
try:
# create a subdirectory for the current package@version
subdir = join_path(mirror_root, pkg.name)
archive_path = join_path(path, mirror_archive_path(spec))
subdir = os.path.dirname(archive_path)
mkdirp(subdir)
archive_file = mirror_archive_filename(spec)
archive_path = join_path(subdir, archive_file)
if os.path.exists(archive_path):
tty.msg("Already added %s" % spec.format("$_$@"))
present.append(spec)

View File

@ -459,7 +459,7 @@ def stage(self):
raise ValueError("Can only get a stage for a concrete package.")
if self._stage is None:
mp = spack.mirror.mirror_archive_filename(self.spec)
mp = spack.mirror.mirror_archive_path(self.spec)
self._stage = Stage(
self.fetcher, mirror_path=mp, name=self.spec.short_spec)
return self._stage

View File

@ -44,7 +44,7 @@ def setUp(self):
self.repos = {}
def set_up_package(self, name, mock_repo_class, url_attr):
def set_up_package(self, name, MockRepoClass, url_attr):
"""Use this to set up a mock package to be mirrored.
Each package needs us to:
1. Set up a mock repo/archive to fetch from.
@ -56,7 +56,7 @@ def set_up_package(self, name, mock_repo_class, url_attr):
# Get the package and fix its fetch args to point to a mock repo
pkg = spack.db.get(spec)
repo = mock_repo_class()
repo = MockRepoClass()
self.repos[name] = repo
# change the fetch args of the first (only) version.
@ -71,7 +71,7 @@ def tearDown(self):
for name, repo in self.repos.items():
if repo.stage:
repo.stage.destroy()
pass #repo.stage.destroy()
self.repos.clear()
@ -129,7 +129,7 @@ def check_mirror(self):
self.assertTrue(all(l in exclude for l in dcmp.left_only))
finally:
stage.destroy()
pass #stage.destroy()
def test_git_mirror(self):