modules/generic_stage_target.py, Create SOURCE_MOUNTS_DEFAULTS
authorBrian Dolbec <dolsen@gentoo.org>
Mon, 30 Dec 2013 23:56:02 +0000 (15:56 -0800)
committerBrian Dolbec <dolsen@gentoo.org>
Fri, 3 Jan 2014 05:29:37 +0000 (21:29 -0800)
Similarly to TARGET_MOUNTS_DEFAULTS this is a temporary location.
This will simplify the migration to being fully configurable.
It also simplifies initialization somewhat.

modules/generic_stage_target.py

index 7919f072f69d1bfcc43c43d747e984253fcaddfe..790e4da2498466806dbecb26d9422fd064de64c3 100644 (file)
@@ -22,6 +22,15 @@ TARGET_MOUNTS_DEFAULTS = {
        "proc": "/proc",
        }
 
+SOURCE_MOUNTS_DEFAULTS = {
+       "dev": "/dev",
+       "devpts": "/dev/pts",
+       "distdir": "/usr/portage/distfiles",
+       "portdir": "/usr/portage",
+       "port_tmpdir": "tmpfs",
+       "proc": "/proc",
+       }
+
 
 class generic_stage_target(generic_target):
        """
@@ -194,23 +203,19 @@ class generic_stage_target(generic_target):
                """ Setup our mount points """
                # initialize our target mounts.
                self.target_mounts = TARGET_MOUNTS_DEFAULTS.copy()
-               if "SNAPCACHE" in self.settings:
-                       self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
-                       self.mountmap = {
-                               "dev": "/dev",
-                               "devpts": "/dev/pts",
-                               "distdir": self.settings["distdir"],
-                               "portdir": normpath("/".join([
-                                       self.settings["snapshot_cache_path"],
-                                       self.settings["repo_name"],
-                                       ])),
-                               "port_tmpdir": "tmpfs",
-                               "proc": "/proc",
-                               }
-               else:
-                       self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
-                       self.mountmap = {"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
-                               "distdir":self.settings["distdir"], "port_tmpdir":"tmpfs"}
+
+               self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
+               # initialize our source mounts
+               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.mounts.remove("portdir")
+                       #self.mountmap["portdir"] = None
                if os.uname()[0] == "Linux":
                        self.mounts.append("devpts")