The default portdir path uses the snapshot_cache_path setting, but we
only set a default for that (in
generic_stage_target.set_snapcache_path) if SNAPCACHE is enabled. By
shifting the portdir calculation into the SNAPCACHE-only block here,
we avoid running into key-errors when the user has SNAPCACHE disabled
and (unsurprisingly) doesn't specify an explicit snapshot_cache_path.
---
On Tue, Mar 04, 2014 at 09:25:08PM -0800, Brian Dolbec wrote:
> On Tue, 4 Mar 2014 20:47:47 -0800, W. Trevor King wrote:
> > There are not particularly many snapshot_cache_path references in
> > catalyst. Grepping through them, the following looks suspicious:
> >
> > catalyst/targets/generic_stage_target.py-215- self.mountmap["portdir"] =
> > normpath("/".join([
> > catalyst/targets/generic_stage_target.py:216:
> > self.settings["snapshot_cache_path"],
> > catalyst/targets/generic_stage_target.py-217- self.settings["repo_name"],
> > catalyst/targets/generic_stage_target.py-218- ]))
> > catalyst/targets/generic_stage_target.py-219- if "SNAPCACHE" not in
> > self.settings:
> >
> > Everything else looks fine. So what should portdir be if
> > SNAPCACHE isn't set?
>
> Yeah, that's where it was failing. …
>
> I'm open to a better alternative. I think the potential is there
> for more of these types of errors which depend on options selected.
This patch should fix it. Analysis in the commit message itself.
Cheers,
Trevor
catalyst/targets/generic_stage_target.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/catalyst/targets/generic_stage_target.py
b/catalyst/targets/generic_stage_target.py
index 2b3d7ce..1412ed5 100644
--- a/catalyst/targets/generic_stage_target.py
+++ b/catalyst/targets/generic_stage_target.py
@@ -212,11 +212,11 @@ class generic_stage_target(generic_target):
self.mountmap = SOURCE_MOUNTS_DEFAULTS.copy()
# update them from settings
self.mountmap["distdir"] = self.settings["distdir"]
- self.mountmap["portdir"] = normpath("/".join([
- self.settings["snapshot_cache_path"],
- self.settings["repo_name"],
- ]))
if "SNAPCACHE" not in self.settings:
+ self.mountmap["portdir"] = normpath("/".join([
+ self.settings["snapshot_cache_path"],
+ self.settings["repo_name"],
+ ]))
self.mounts.remove("portdir")
#self.mountmap["portdir"] = None
if os.uname()[0] == "Linux":
--
1.8.5.2.8.g0f6c0d1