* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-20 0:29 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-20 0:29 UTC (permalink / raw
To: gentoo-commits
commit: 31865200ec6a892768cd2a51e7e80dbc8dfe9d2d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 20 00:14:40 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=31865200
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 43df545..49fc615 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -453,7 +453,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -464,14 +464,14 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
self.settings["autoresume_path"]=normpath(self.settings["storedir"]+\
"/tmp/"+self.settings["rel_type"]+"/"+".autoresume-"+\
self.settings["target"]+"-"+self.settings["subarch"]+"-"+\
- self.settings["version_stamp"]+"/")
+ self.settings["version_stamp"])
if "AUTORESUME" in self.settings:
print "The autoresume path is " + self.settings["autoresume_path"]
if not os.path.exists(self.settings["autoresume_path"]):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-20 0:29 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-20 0:29 UTC (permalink / raw
To: gentoo-commits
commit: 217a97d354fedd8b3534bd5aa83adfc93182fc02
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 20 00:11:10 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=217a97d3
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Cleans up all self.mounts, self.mountmap usage.
Replace multiple path additions with one instance at the beginning of the function, reuse the result multiple times.
Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 94 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 63 insertions(+), 36 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index ce28ab8..c8d31e1 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -4,6 +4,23 @@ from generic_target import *
from stat import *
import catalyst_lock
+# temporary location. It will be moved to a
+# new defaults file in a later comit
+TARGET_MOUNTS_DEFAULTS = {
+ "proc": "/proc",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "portdir": "/usr/portage",
+ "distdir": "/usr/portage/distfiles",
+ "packagedir": "/usr/portage/packages",
+ "port_tmpdir": "/var/tmp/portage",
+ "kerncache": "/tmp/kerncache",
+ "ccache": "/var/tmp/ccache",
+ "icecream": "/usr/lib/icecc/bin",
+ "port_logdir": "/var/log/portage",
+ }
+
+
class generic_stage_target(generic_target):
"""
This class does all of the chroot setup, copying of files, etc. It is
@@ -173,6 +190,10 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" Setup our mount points """
+ # initialize our target mounts.
+ # later I plan to make these configurable so the
+ # defaults can be easily overridden if desired.
+ self.target_mounts = TARGET_MOUNTS_DEFAULTS.copy()
if "SNAPCACHE" in self.settings:
self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
self.mountmap={"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
@@ -219,17 +240,18 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"]=self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"]=self.target_mounts["port_logdir"]
self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
def override_cbuild(self):
@@ -603,33 +625,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -897,12 +920,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -910,20 +935,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -935,26 +962,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..1e0d874 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"]="/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-20 0:48 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-20 0:48 UTC (permalink / raw
To: gentoo-commits
commit: 94175889593607953e32ec2324127eaf6b1a4e01
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 20 00:47:09 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=94175889
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 43df545..49fc615 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -453,7 +453,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -464,14 +464,14 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
self.settings["autoresume_path"]=normpath(self.settings["storedir"]+\
"/tmp/"+self.settings["rel_type"]+"/"+".autoresume-"+\
self.settings["target"]+"-"+self.settings["subarch"]+"-"+\
- self.settings["version_stamp"]+"/")
+ self.settings["version_stamp"])
if "AUTORESUME" in self.settings:
print "The autoresume path is " + self.settings["autoresume_path"]
if not os.path.exists(self.settings["autoresume_path"]):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-30 1:44 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-30 1:44 UTC (permalink / raw
To: gentoo-commits
commit: 52c8009fcce0747cb37742c73271903f861c1209
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 15 22:53:32 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 29 09:09:27 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=52c8009f
modules/generic_stage_target.py: Use portdir, distdir,... instead of paths for keys
If snapcache is enabled, self.mounts and self.mountmap had not been modified
like they were if it was not enabled.
Fix a missed self.mounts key change from a path as key.
original patch: 27b751ffd9594e0128a3d70f83c7af18dab03838
Added a print statement for debugging to be converted to logging in the future.
---
modules/generic_stage_target.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3e60f72..6c8cdbc 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,10 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["/proc","/dev","/usr/portage","/usr/portage/distfiles","/var/tmp/portage"]
- self.mountmap={"/proc":"/proc","/dev":"/dev","devpts":"/dev/pts",
- "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\
- "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
+ self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
+ self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
+ "portdir": self.settings["snapshot_cache_path"] + "/portage",
+ "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
else:
self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
self.mountmap = {"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
@@ -904,7 +904,8 @@ class generic_stage_target(generic_target):
os.makedirs(self.mountmap[x],0755)
src=self.mountmap[x]
- if "SNAPCACHE" in self.settings and x == "/usr/portage":
+ #print "bind(); src =", src
+ if "SNAPCACHE" in self.settings and x == "portdir":
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-30 1:44 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-30 1:44 UTC (permalink / raw
To: gentoo-commits
commit: ec491ccae1a8150e330b372992e0f497b559faac
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 29 18:54:06 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=ec491cca
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Temporary location to define TARGET_MOUNTS, IT will be moved to a new defaults.py file in a later commit.
I also plan to make them configurable.
Cleans up all self.mounts, self.mountmap usage.
Replace multiple path additions with one instance at the beginning of the function, reuse the result multiple times.
Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 83 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 55 insertions(+), 33 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 8f7654e..8d98e58 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -8,6 +8,20 @@ import catalyst_lock
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+TARGET_MOUNTS_DEFAULTS = {
+ "ccache": "/var/tmp/ccache",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "distdir": "/usr/portage/distfiles",
+ "icecream": "/usr/lib/icecc/bin",
+ "kerncache": "/tmp/kerncache",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "port_logdir": "/var/log/portage",
+ "proc": "/proc",
+ }
+
class generic_stage_target(generic_target):
"""
@@ -178,6 +192,8 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" 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 = {
@@ -230,12 +246,13 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
self.mounts.append("port_logdir")
@@ -614,33 +631,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -908,12 +926,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -921,20 +941,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -946,26 +968,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..5f4ffa0 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"] = "/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-30 1:44 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-30 1:44 UTC (permalink / raw
To: gentoo-commits
commit: 0b87d521fdaf3dbf5f10e601ed79e830b362b0ca
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 09:03:14 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 29 18:54:05 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0b87d521
Fix mounts and mountmap port_logdir code block.
---
modules/generic_stage_target.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 51375c0..8f7654e 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -4,6 +4,11 @@ from generic_target import *
from stat import *
import catalyst_lock
+
+PORT_LOGDIR_CLEAN = \
+ 'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+
+
class generic_stage_target(generic_target):
"""
This class does all of the chroot setup, copying of files, etc. It is
@@ -233,10 +238,10 @@ class generic_stage_target(generic_target):
self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
if "port_logdir" in self.settings:
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
- self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
def override_cbuild(self):
if "CBUILD" in self.makeconf:
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-30 1:44 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-30 1:44 UTC (permalink / raw
To: gentoo-commits
commit: 557a8b10ac6791f190d0411b3621412b25762b39
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 19 04:27:04 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 29 18:53:36 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=557a8b10
Fix a missed self.settings["repo_name"] migration
Use normpath() on it as well.
Fix the coding style in the lines touched.
---
modules/generic_stage_target.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 6c8cdbc..51375c0 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,17 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
- self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
- "portdir": self.settings["snapshot_cache_path"] + "/portage",
- "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
+ self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
+ self.mountmap = {
+ "proc": "/proc",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "portdir": normpath("/".join([
+ self.settings["snapshot_cache_path"],
+ self.settings["repo_name"],
+ ])),
+ "distdir": self.settings["distdir"],
+ "port_tmpdir": "tmpfs"}
else:
self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
self.mountmap = {"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-30 1:44 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-30 1:44 UTC (permalink / raw
To: gentoo-commits
commit: 7895f714e63b060baef970424c2a843d17b841be
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 29 18:54:06 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=7895f714
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index bbea57a..f69f192 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,7 +459,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -470,14 +470,14 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
self.settings["autoresume_path"]=normpath(self.settings["storedir"]+\
"/tmp/"+self.settings["rel_type"]+"/"+".autoresume-"+\
self.settings["target"]+"-"+self.settings["subarch"]+"-"+\
- self.settings["version_stamp"]+"/")
+ self.settings["version_stamp"])
if "AUTORESUME" in self.settings:
print "The autoresume path is " + self.settings["autoresume_path"]
if not os.path.exists(self.settings["autoresume_path"]):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:22 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:22 UTC (permalink / raw
To: gentoo-commits
commit: 09ea211964c280092b397f6b70de731ad23f2259
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 19 04:27:04 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 00:39:34 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=09ea2119
Fix a missed self.settings["repo_name"] migration
Use normpath() on it as well.
Fix the coding style in the lines touched.
---
modules/generic_stage_target.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 6c8cdbc..51375c0 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,17 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
- self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
- "portdir": self.settings["snapshot_cache_path"] + "/portage",
- "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
+ self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
+ self.mountmap = {
+ "proc": "/proc",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "portdir": normpath("/".join([
+ self.settings["snapshot_cache_path"],
+ self.settings["repo_name"],
+ ])),
+ "distdir": self.settings["distdir"],
+ "port_tmpdir": "tmpfs"}
else:
self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
self.mountmap = {"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2013-12-31 4:22 ` Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:22 UTC (permalink / raw
To: gentoo-commits
commit: 5f0fce9876dea3f8fdc7127f7658239792cb526b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 15 22:53:32 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 00:38:53 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5f0fce98
modules/generic_stage_target.py: Use portdir, distdir, ... instead of paths for keys
If snapcache is enabled, self.mounts and self.mountmap had not been
modified like they were if it was not enabled.
Added a print statement for debugging to be converted to logging in
the future.
---
modules/generic_stage_target.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3e60f72..6c8cdbc 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,10 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["/proc","/dev","/usr/portage","/usr/portage/distfiles","/var/tmp/portage"]
- self.mountmap={"/proc":"/proc","/dev":"/dev","devpts":"/dev/pts",
- "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\
- "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
+ self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
+ self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
+ "portdir": self.settings["snapshot_cache_path"] + "/portage",
+ "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
else:
self.mounts = ["proc", "dev", "distdir", "port_tmpdir"]
self.mountmap = {"proc":"/proc", "dev":"/dev", "devpts":"/dev/pts",
@@ -904,7 +904,8 @@ class generic_stage_target(generic_target):
os.makedirs(self.mountmap[x],0755)
src=self.mountmap[x]
- if "SNAPCACHE" in self.settings and x == "/usr/portage":
+ #print "bind(); src =", src
+ if "SNAPCACHE" in self.settings and x == "portdir":
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:22 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:22 UTC (permalink / raw
To: gentoo-commits
commit: 31454e73a8dd9871a15e10a2b06d472f692bc3e9
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 03:56:09 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=31454e73
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Temporary location to define TARGET_MOUNTS_DEFAULTS.
IT will be moved to a new defaults.py file in a later commit.
I also plan to make them configurable.
Also:
* Clean up all self.mounts, self.mountmap usage.
* Replace multiple path additions with one instance at the
beginning of the function, reuse the result multiple times.
* Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 83 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 55 insertions(+), 33 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 8f7654e..8d98e58 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -8,6 +8,20 @@ import catalyst_lock
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+TARGET_MOUNTS_DEFAULTS = {
+ "ccache": "/var/tmp/ccache",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "distdir": "/usr/portage/distfiles",
+ "icecream": "/usr/lib/icecc/bin",
+ "kerncache": "/tmp/kerncache",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "port_logdir": "/var/log/portage",
+ "proc": "/proc",
+ }
+
class generic_stage_target(generic_target):
"""
@@ -178,6 +192,8 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" 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 = {
@@ -230,12 +246,13 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
self.mounts.append("port_logdir")
@@ -614,33 +631,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -908,12 +926,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -921,20 +941,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -946,26 +968,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..5f4ffa0 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"] = "/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:22 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:22 UTC (permalink / raw
To: gentoo-commits
commit: 0a8a5f53e4f3ce1613bd667e98c9d30fd334d3be
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 09:03:14 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 00:39:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=0a8a5f53
Fix mounts and mountmap port_logdir code block.
---
modules/generic_stage_target.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 51375c0..8f7654e 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -4,6 +4,11 @@ from generic_target import *
from stat import *
import catalyst_lock
+
+PORT_LOGDIR_CLEAN = \
+ 'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+
+
class generic_stage_target(generic_target):
"""
This class does all of the chroot setup, copying of files, etc. It is
@@ -233,10 +238,10 @@ class generic_stage_target(generic_target):
self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
if "port_logdir" in self.settings:
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
- self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
def override_cbuild(self):
if "CBUILD" in self.makeconf:
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:22 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:22 UTC (permalink / raw
To: gentoo-commits
commit: 1e54e4a50621dfc339bfdb950a630ad393b79f00
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 03:58:32 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=1e54e4a5
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index bbea57a..daba5eb 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,7 +459,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -470,7 +470,7 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:39 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:39 UTC (permalink / raw
To: gentoo-commits
commit: 5382d11da1af6deefc1cac602cbd77936638ddfa
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:33:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5382d11d
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index c6a06b6..fcffa23 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,7 +459,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -470,7 +470,7 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:39 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:39 UTC (permalink / raw
To: gentoo-commits
commit: c0e1397e4b9e1a530e215870f57c5b5491f33320
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:33:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c0e1397e
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Temporary location to define TARGET_MOUNTS_DEFAULTS.
IT will be moved to a new defaults.py file in a later commit.
I also plan to make them configurable.
Also:
* Clean up all self.mounts, self.mountmap usage.
* Replace multiple path additions with one instance at the
beginning of the function, reuse the result multiple times.
* Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 83 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 55 insertions(+), 33 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 55b336f..c57c504 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -8,6 +8,20 @@ import catalyst_lock
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+TARGET_MOUNTS_DEFAULTS = {
+ "ccache": "/var/tmp/ccache",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "distdir": "/usr/portage/distfiles",
+ "icecream": "/usr/lib/icecc/bin",
+ "kerncache": "/tmp/kerncache",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "port_logdir": "/var/log/portage",
+ "proc": "/proc",
+ }
+
class generic_stage_target(generic_target):
"""
@@ -178,6 +192,8 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" 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 = {
@@ -230,12 +246,13 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
self.mounts.append("port_logdir")
@@ -614,33 +631,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -908,12 +926,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -921,20 +941,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -946,26 +968,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..5f4ffa0 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"] = "/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:39 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:39 UTC (permalink / raw
To: gentoo-commits
commit: a83d4df507612cbb30d12eabe1087aa19c995eb9
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 19 04:27:04 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:33:28 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a83d4df5
Fix a missed self.settings["repo_name"] migration
Use normpath() on it as well.
Fix the coding style in the lines touched.
---
modules/generic_stage_target.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 6c8cdbc..3d6a45e 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,17 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
- self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
- "portdir": self.settings["snapshot_cache_path"] + "/portage",
- "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
+ 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",
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:39 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:39 UTC (permalink / raw
To: gentoo-commits
commit: 9468c69a818352d97d3afe7c03d2447ebcda33b2
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 09:03:14 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:33:35 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=9468c69a
Fix mounts and mountmap port_logdir code block.
---
modules/generic_stage_target.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3d6a45e..55b336f 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -4,6 +4,11 @@ from generic_target import *
from stat import *
import catalyst_lock
+
+PORT_LOGDIR_CLEAN = \
+ 'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+
+
class generic_stage_target(generic_target):
"""
This class does all of the chroot setup, copying of files, etc. It is
@@ -233,10 +238,10 @@ class generic_stage_target(generic_target):
self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
if "port_logdir" in self.settings:
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
- self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
def override_cbuild(self):
if "CBUILD" in self.makeconf:
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:48 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:48 UTC (permalink / raw
To: gentoo-commits
commit: 5a85da68c274da46cfb4cbf8d6111c48a9740760
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:40:00 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5a85da68
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Temporary location to define TARGET_MOUNTS_DEFAULTS.
It will be moved to a new defaults.py file in a later commit.
I also plan to make them configurable.
Also:
* Clean up all self.mounts, self.mountmap usage.
* Replace multiple path additions with one instance at the
beginning of the function, reuse the result multiple times.
* Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 83 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 55 insertions(+), 33 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 55b336f..c57c504 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -8,6 +8,20 @@ import catalyst_lock
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+TARGET_MOUNTS_DEFAULTS = {
+ "ccache": "/var/tmp/ccache",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "distdir": "/usr/portage/distfiles",
+ "icecream": "/usr/lib/icecc/bin",
+ "kerncache": "/tmp/kerncache",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "port_logdir": "/var/log/portage",
+ "proc": "/proc",
+ }
+
class generic_stage_target(generic_target):
"""
@@ -178,6 +192,8 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" 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 = {
@@ -230,12 +246,13 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
self.mounts.append("port_logdir")
@@ -614,33 +631,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -908,12 +926,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -921,20 +941,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -946,26 +968,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..5f4ffa0 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"] = "/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 4:48 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 4:48 UTC (permalink / raw
To: gentoo-commits
commit: ba5d3f23e16077e80f0c967ce9d6401d705d4593
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 04:40:14 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=ba5d3f23
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index c6a06b6..fcffa23 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,7 +459,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -470,7 +470,7 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2013-12-31 18:14 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2013-12-31 18:14 UTC (permalink / raw
To: gentoo-commits
commit: c2df48099ddd83a684cdb5b4e486763718fa0436
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 31 17:59:02 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c2df4809
Remove some troublesome trailing slashes from paths
---
modules/generic_stage_target.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index c6a06b6..fcffa23 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,7 +459,7 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
@@ -470,7 +470,7 @@ class generic_stage_target(generic_target):
Things *will* break without it!
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-02 0:04 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-02 0:04 UTC (permalink / raw
To: gentoo-commits
commit: ac21cae9dfa75a8e79c6d67ce61d7aadd5111bb2
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Jan 1 23:55:32 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=ac21cae9
Remove some troublesome trailing slashes from paths
Change the docstring to warn to use a proper path join function.
---
modules/generic_stage_target.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index c6a06b6..aafcc32 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -459,18 +459,18 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
def set_chroot_path(self):
"""
- NOTE: the trailing slash is very important!
- Things *will* break without it!
+ NOTE: the trailing slash has been removed
+ Things *could* break if you don't use a proper join()
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-01-03 5:03 ` Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 5:03 UTC (permalink / raw
To: gentoo-commits
commit: 20c1975bd68784bdcf37d0d95de96333881fc272
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 19 04:27:04 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 04:39:22 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=20c1975b
Fix a missed self.settings["repo_name"] migration
Use normpath() on it as well.
Fix the coding style in the lines touched.
---
modules/generic_stage_target.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 6c8cdbc..ce43c79 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,10 +174,18 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if "SNAPCACHE" in self.settings:
- self.mounts=["proc", "dev", "portdir", "distdir", "port_tmpdir"]
- self.mountmap={"proc": "/proc", "dev": "/dev", "devpts": "/dev/pts",
- "portdir": self.settings["snapshot_cache_path"] + "/portage",
- "distdir": self.settings["distdir"], "port_tmpdir": "tmpfs"}
+ 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",
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 5:03 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 5:03 UTC (permalink / raw
To: gentoo-commits
commit: c0c0a87d2a22a73e9b8a2e754bed5b185ed54aec
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 04:39:28 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=c0c0a87d
Remove some troublesome trailing slashes from paths
Change the docstring to warn to use a proper path join function.
---
modules/generic_stage_target.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 7919f07..587b903 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -460,18 +460,18 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
def set_chroot_path(self):
"""
- NOTE: the trailing slash is very important!
- Things *will* break without it!
+ NOTE: the trailing slash has been removed
+ Things *could* break if you don't use a proper join()
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 5:03 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 5:03 UTC (permalink / raw
To: gentoo-commits
commit: 4da24c6ed4ae87c4653b051924269915925178f9
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 09:03:14 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 04:39:28 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=4da24c6e
Fix mounts and mountmap port_logdir code block.
---
modules/generic_stage_target.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index ce43c79..8cc6dc1 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -4,6 +4,11 @@ from generic_target import *
from stat import *
import catalyst_lock
+
+PORT_LOGDIR_CLEAN = \
+ 'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+
+
class generic_stage_target(generic_target):
"""
This class does all of the chroot setup, copying of files, etc. It is
@@ -234,10 +239,10 @@ class generic_stage_target(generic_target):
self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
if "port_logdir" in self.settings:
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
- self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
+ self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
def override_cbuild(self):
if "CBUILD" in self.makeconf:
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-01-03 5:03 ` Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 5:03 UTC (permalink / raw
To: gentoo-commits
commit: 7a4705adf2578f8131ae5fa4192d383c82a0516d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:05 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 04:39:28 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=7a4705ad
modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Temporary location to define TARGET_MOUNTS_DEFAULTS.
It will be moved to a new defaults.py file in a later commit.
I also plan to make them configurable.
Also:
* Clean up all self.mounts, self.mountmap usage.
* Replace multiple path additions with one instance at the
beginning of the function, reuse the result multiple times.
* Add some extra debug prints (to be converted to logging later)
---
modules/generic_stage_target.py | 83 ++++++++++++++++++++++++++---------------
modules/stage1_target.py | 5 ++-
2 files changed, 55 insertions(+), 33 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 8cc6dc1..63a8ff5 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -8,6 +8,20 @@ import catalyst_lock
PORT_LOGDIR_CLEAN = \
'find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
+TARGET_MOUNTS_DEFAULTS = {
+ "ccache": "/var/tmp/ccache",
+ "dev": "/dev",
+ "devpts": "/dev/pts",
+ "distdir": "/usr/portage/distfiles",
+ "icecream": "/usr/lib/icecc/bin",
+ "kerncache": "/tmp/kerncache",
+ "packagedir": "/usr/portage/packages",
+ "portdir": "/usr/portage",
+ "port_tmpdir": "/var/tmp/portage",
+ "port_logdir": "/var/log/portage",
+ "proc": "/proc",
+ }
+
class generic_stage_target(generic_target):
"""
@@ -178,6 +192,8 @@ class generic_stage_target(generic_target):
file_locate(self.settings,["portage_confdir"],expand=0)
""" 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 = {
@@ -231,12 +247,13 @@ class generic_stage_target(generic_target):
self.mounts.append("ccache")
self.mountmap["ccache"] = ccdir
""" for the chroot: """
- self.env["CCACHE_DIR"]="/var/tmp/ccache"
+ self.env["CCACHE_DIR"] = self.target_mounts["ccache"]
if "ICECREAM" in self.settings:
self.mounts.append("/var/cache/icecream")
self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
- self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
+ self.env["PATH"] = self.target_mounts["icecream"] + ":" + \
+ self.env["PATH"]
if "port_logdir" in self.settings:
self.mounts.append("port_logdir")
@@ -615,33 +632,34 @@ class generic_stage_target(generic_target):
"kill-chroot-pids script failed.",env=self.env)
def mount_safety_check(self):
- mypath=self.settings["chroot_path"]
-
"""
Check and verify that none of our paths in mypath are mounted. We don't
want to clean up with things still mounted, and this allows us to check.
Returns 1 on ok, 0 on "something is still mounted" case.
"""
- if not os.path.exists(mypath):
+ if not os.path.exists(self.settings["chroot_path"]):
return
+ print "self.mounts =", self.mounts
for x in self.mounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ print "mount_safety_check() x =", x, target
+ if not os.path.exists(target):
continue
- if ismount(mypath + self.mountmap[x]):
+ if ismount(target):
""" Something is still mounted "" """
try:
- print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
+ print target + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath + self.mountmap[x]):
- raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
+ if ismount(target):
+ raise CatalystError, "Auto-unbind failed for " + target
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
+ raise CatalystError, "Unable to auto-unbind " + target
def unpack(self):
unpack=True
@@ -909,12 +927,14 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
- os.makedirs(self.settings["chroot_path"]+x,0755)
+ #print "bind(); x =", x
+ target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
+ if not os.path.exists(target):
+ os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
if not self.mountmap[x] == "tmpfs":
- os.makedirs(self.mountmap[x],0755)
+ os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
#print "bind(); src =", src
@@ -922,20 +942,22 @@ class generic_stage_target(generic_target):
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval = os.system("mount -t devfs none " +
- self.settings["chroot_path"] + src)
+ cmd = "mount -t devfs none " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount_nullfs " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount_nullfs " + src + " " + target
+ retval=os.system(cmd)
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ cmd = "mount -t tmpfs -o size=" + \
+ self.settings["var_tmpfs_portage"] + "G " + \
+ src + " " + target
+ retval=os.system(cmd)
else:
- retval = os.system("mount --bind " + src + " " +
- self.settings["chroot_path"] + src)
+ cmd = "mount --bind " + src + " " + target
+ #print "bind(); cmd =", cmd
+ retval=os.system(cmd)
if retval!=0:
self.unbind()
raise CatalystError,"Couldn't bind mount " + src
@@ -947,26 +969,25 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath + self.mountmap[x]):
+ target = normpath(mypath + self.target_mounts[x])
+ if not os.path.exists(target):
continue
- if not ismount(mypath + self.mountmap[x]):
+ if not ismount(target):
continue
- retval=os.system("umount "+\
- os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
+ retval=os.system("umount " + target)
if retval!=0:
- warn("First attempt to unmount: " + mypath +
- self.mountmap[x] +" failed.")
+ warn("First attempt to unmount: " + target + " failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2 = os.system("umount " + mypath + self.mountmap[x])
+ retval2 = os.system("umount " + target)
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
+ warn("Couldn't umount bind mount: " + target)
if "SNAPCACHE" in self.settings and x == "/usr/portage":
try:
diff --git a/modules/stage1_target.py b/modules/stage1_target.py
index aa43926..5f4ffa0 100644
--- a/modules/stage1_target.py
+++ b/modules/stage1_target.py
@@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
os.makedirs(self.settings["stage_path"]+"/proc")
# alter the mount mappings to bind mount proc onto it
- self.mounts.append("/tmp/stage1root/proc")
- self.mountmap["/tmp/stage1root/proc"]="/proc"
+ self.mounts.append("stage1root/proc")
+ self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
+ self.mountmap["stage1root/proc"] = "/proc"
def register(foo):
foo.update({"stage1":stage1_target})
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 6:12 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 6:12 UTC (permalink / raw
To: gentoo-commits
commit: 9f15e29d85f9752d7d4ffb18a4b83fb1f9973ae3
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 05:41:25 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=9f15e29d
Remove some troublesome trailing slashes from paths
Change the docstring to warn to use a proper path join function.
---
modules/generic_stage_target.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3d66231..0026bd7 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -468,18 +468,18 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
def set_chroot_path(self):
"""
- NOTE: the trailing slash is very important!
- Things *will* break without it!
+ NOTE: the trailing slash has been removed
+ Things *could* break if you don't use a proper join()
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 6:12 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 6:12 UTC (permalink / raw
To: gentoo-commits
commit: f48028dc0e9ed1da8413f5fc486b43f2d3d5342a
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 23:56:02 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 05:29:37 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=f48028dc
modules/generic_stage_target.py, Create SOURCE_MOUNTS_DEFAULTS
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 | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 7919f07..790e4da 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -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")
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 6:12 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 6:12 UTC (permalink / raw
To: gentoo-commits
commit: 134ce250adc19ef5ecbe37f2d8e7a55fcffcfb9b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 23:57:28 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 05:39:31 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=134ce250
catalyst/targets/generic_stage_target.py: mount /dev/shm on linux
Add shm targets defaults. Anthony G. Basile <blueness <AT> gentoo.org>
Some build systems require /dev/shm to be mounted, like python's
build system. We make sure that on Linux systems, /dev/shm is
mounted in the stage chroots. See bug #496328.
Douglas Freed <dwfreed <AT> mtu.edu> :
Mount /dev/shm in the chroot with the right options
Bind mounting /dev/shm into the chroot isn't a good idea, as there may
be collisions and result in weird side effects. Instead, we can just
mount a new tmpfs there, with the right options to ensure security.
(Forward ported to pending branch from 2.X Brian Dolbec)
Conflicts:
catalyst/targets/generic_stage_target.py
---
modules/generic_stage_target.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 790e4da..3d66231 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -20,6 +20,7 @@ TARGET_MOUNTS_DEFAULTS = {
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
+ "shm": "/dev/shm",
}
SOURCE_MOUNTS_DEFAULTS = {
@@ -29,6 +30,7 @@ SOURCE_MOUNTS_DEFAULTS = {
"portdir": "/usr/portage",
"port_tmpdir": "tmpfs",
"proc": "/proc",
+ "shm": "shmfs",
}
@@ -218,6 +220,7 @@ class generic_stage_target(generic_target):
#self.mountmap["portdir"] = None
if os.uname()[0] == "Linux":
self.mounts.append("devpts")
+ self.mounts.append("shm")
self.set_mounts()
@@ -938,7 +941,7 @@ class generic_stage_target(generic_target):
os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
- if not self.mountmap[x] == "tmpfs":
+ if self.mountmap[x] not in ["tmpfs", "shmfs"]:
os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
@@ -959,6 +962,9 @@ class generic_stage_target(generic_target):
self.settings["var_tmpfs_portage"] + "G " + \
src + " " + target
retval=os.system(cmd)
+ elif src == "shmfs":
+ cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target
+ retval=os.system(cmd)
else:
cmd = "mount --bind " + src + " " + target
#print "bind(); cmd =", cmd
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
@ 2014-01-03 6:41 Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 6:41 UTC (permalink / raw
To: gentoo-commits
commit: febdb20089a71b7003118d6ce9722d718b6d7676
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 17 06:22:41 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 06:40:03 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=febdb200
Remove some troublesome trailing slashes from paths
Change the docstring to warn to use a proper path join function.
---
modules/generic_stage_target.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3d66231..0026bd7 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -468,18 +468,18 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ self.settings["snapshot"])
self.snapcache_lock=\
catalyst_lock.LockDir(self.settings["snapshot_cache_path"])
print "Caching snapshot to "+self.settings["snapshot_cache_path"]
def set_chroot_path(self):
"""
- NOTE: the trailing slash is very important!
- Things *will* break without it!
+ NOTE: the trailing slash has been removed
+ Things *could* break if you don't use a proper join()
"""
self.settings["chroot_path"]=normpath(self.settings["storedir"]+\
- "/tmp/"+self.settings["target_subpath"]+"/")
+ "/tmp/"+self.settings["target_subpath"])
self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"])
def set_autoresume_path(self):
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [gentoo-commits] proj/catalyst:pending commit in: modules/
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
@ 2014-01-03 6:41 ` Brian Dolbec
0 siblings, 0 replies; 30+ messages in thread
From: Brian Dolbec @ 2014-01-03 6:41 UTC (permalink / raw
To: gentoo-commits
commit: e5a9e20376397f2714aa7a835b7f42f71fcc38d9
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 30 23:57:28 2013 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan 3 06:39:31 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=e5a9e203
catalyst/targets/generic_stage_target.py: mount /dev/shm on linux
Add shm targets defaults. Anthony G. Basile <blueness <AT> gentoo.org>
Some build systems require /dev/shm to be mounted, like python's
build system. We make sure that on Linux systems, /dev/shm is
mounted in the stage chroots. See bug #496328.
Douglas Freed <dwfreed <AT> mtu.edu> :
Mount /dev/shm in the chroot with the right options
Bind mounting /dev/shm into the chroot isn't a good idea, as there may
be collisions and result in weird side effects. Instead, we can just
mount a new tmpfs there, with the right options to ensure security.
(Forward ported to pending branch from 2.X Brian Dolbec)
Conflicts:
catalyst/targets/generic_stage_target.py
---
modules/generic_stage_target.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 790e4da..3d66231 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -20,6 +20,7 @@ TARGET_MOUNTS_DEFAULTS = {
"port_tmpdir": "/var/tmp/portage",
"port_logdir": "/var/log/portage",
"proc": "/proc",
+ "shm": "/dev/shm",
}
SOURCE_MOUNTS_DEFAULTS = {
@@ -29,6 +30,7 @@ SOURCE_MOUNTS_DEFAULTS = {
"portdir": "/usr/portage",
"port_tmpdir": "tmpfs",
"proc": "/proc",
+ "shm": "shmfs",
}
@@ -218,6 +220,7 @@ class generic_stage_target(generic_target):
#self.mountmap["portdir"] = None
if os.uname()[0] == "Linux":
self.mounts.append("devpts")
+ self.mounts.append("shm")
self.set_mounts()
@@ -938,7 +941,7 @@ class generic_stage_target(generic_target):
os.makedirs(target, 0755)
if not os.path.exists(self.mountmap[x]):
- if not self.mountmap[x] == "tmpfs":
+ if self.mountmap[x] not in ["tmpfs", "shmfs"]:
os.makedirs(self.mountmap[x], 0755)
src=self.mountmap[x]
@@ -959,6 +962,9 @@ class generic_stage_target(generic_target):
self.settings["var_tmpfs_portage"] + "G " + \
src + " " + target
retval=os.system(cmd)
+ elif src == "shmfs":
+ cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target
+ retval=os.system(cmd)
else:
cmd = "mount --bind " + src + " " + target
#print "bind(); cmd =", cmd
^ permalink raw reply related [flat|nested] 30+ messages in thread
end of thread, other threads:[~2014-01-03 6:41 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-31 4:39 [gentoo-commits] proj/catalyst:pending commit in: modules/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-01-03 6:41 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-01-03 5:03 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-01-03 5:03 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-01-06 2:00 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2013-12-31 4:22 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-01-03 6:41 Brian Dolbec
2014-01-03 6:12 Brian Dolbec
2014-01-03 6:12 Brian Dolbec
2014-01-03 6:12 Brian Dolbec
2014-01-03 5:03 Brian Dolbec
2014-01-03 5:03 Brian Dolbec
2014-01-02 0:04 Brian Dolbec
2013-12-31 18:14 Brian Dolbec
2013-12-31 4:48 Brian Dolbec
2013-12-31 4:48 Brian Dolbec
2013-12-31 4:39 Brian Dolbec
2013-12-31 4:39 Brian Dolbec
2013-12-31 4:39 Brian Dolbec
2013-12-31 4:22 Brian Dolbec
2013-12-31 4:22 Brian Dolbec
2013-12-31 4:22 Brian Dolbec
2013-12-31 4:22 Brian Dolbec
2013-12-30 1:44 Brian Dolbec
2013-12-30 1:44 Brian Dolbec
2013-12-30 1:44 Brian Dolbec
2013-12-30 1:44 Brian Dolbec
2013-12-30 1:44 Brian Dolbec
2013-12-20 0:48 Brian Dolbec
2013-12-20 0:29 Brian Dolbec
2013-12-20 0:29 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox