Fix bug in mirror path construction.
This commit is contained in:
parent
0ac6ffb3ef
commit
ba593ccb26
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
|
|
||||||
def mirror_archive_filename(spec):
|
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:
|
if not spec.version.concrete:
|
||||||
raise ValueError("mirror.path requires spec with concrete version.")
|
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)
|
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):
|
def get_matching_versions(specs, **kwargs):
|
||||||
"""Get a spec for EACH known version matching any spec in the list."""
|
"""Get a spec for EACH known version matching any spec in the list."""
|
||||||
matching = []
|
matching = []
|
||||||
@ -141,12 +146,10 @@ def create(path, specs, **kwargs):
|
|||||||
stage = None
|
stage = None
|
||||||
try:
|
try:
|
||||||
# create a subdirectory for the current package@version
|
# 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)
|
mkdirp(subdir)
|
||||||
|
|
||||||
archive_file = mirror_archive_filename(spec)
|
|
||||||
archive_path = join_path(subdir, archive_file)
|
|
||||||
|
|
||||||
if os.path.exists(archive_path):
|
if os.path.exists(archive_path):
|
||||||
tty.msg("Already added %s" % spec.format("$_$@"))
|
tty.msg("Already added %s" % spec.format("$_$@"))
|
||||||
present.append(spec)
|
present.append(spec)
|
||||||
|
@ -459,7 +459,7 @@ def stage(self):
|
|||||||
raise ValueError("Can only get a stage for a concrete package.")
|
raise ValueError("Can only get a stage for a concrete package.")
|
||||||
|
|
||||||
if self._stage is None:
|
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._stage = Stage(
|
||||||
self.fetcher, mirror_path=mp, name=self.spec.short_spec)
|
self.fetcher, mirror_path=mp, name=self.spec.short_spec)
|
||||||
return self._stage
|
return self._stage
|
||||||
|
@ -44,7 +44,7 @@ def setUp(self):
|
|||||||
self.repos = {}
|
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.
|
"""Use this to set up a mock package to be mirrored.
|
||||||
Each package needs us to:
|
Each package needs us to:
|
||||||
1. Set up a mock repo/archive to fetch from.
|
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
|
# Get the package and fix its fetch args to point to a mock repo
|
||||||
pkg = spack.db.get(spec)
|
pkg = spack.db.get(spec)
|
||||||
repo = mock_repo_class()
|
repo = MockRepoClass()
|
||||||
self.repos[name] = repo
|
self.repos[name] = repo
|
||||||
|
|
||||||
# change the fetch args of the first (only) version.
|
# change the fetch args of the first (only) version.
|
||||||
@ -71,7 +71,7 @@ def tearDown(self):
|
|||||||
|
|
||||||
for name, repo in self.repos.items():
|
for name, repo in self.repos.items():
|
||||||
if repo.stage:
|
if repo.stage:
|
||||||
repo.stage.destroy()
|
pass #repo.stage.destroy()
|
||||||
|
|
||||||
self.repos.clear()
|
self.repos.clear()
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ def check_mirror(self):
|
|||||||
self.assertTrue(all(l in exclude for l in dcmp.left_only))
|
self.assertTrue(all(l in exclude for l in dcmp.left_only))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
stage.destroy()
|
pass #stage.destroy()
|
||||||
|
|
||||||
|
|
||||||
def test_git_mirror(self):
|
def test_git_mirror(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user