From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending commit in: modules/
Date: Fri, 3 Jan 2014 05:03:22 +0000 (UTC) [thread overview]
Message-ID: <1388723968.7a4705adf2578f8131ae5fa4192d383c82a0516d.dol-sen@gentoo> (raw)
Message-ID: <20140103050322.OL60mV3qRHwUb5nqS5Cb-DVxGyNH_t6IPx4AygQbOYQ@z> (raw)
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})
next reply other threads:[~2014-01-03 5:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 2:00 Brian Dolbec [this message]
2014-01-03 5:03 ` [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-06 2:00 Brian Dolbec
2014-01-06 2:00 Brian Dolbec
2014-01-03 6:12 [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-15 21:33 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-12-15 4:19 Matt Turner
2013-08-08 5:38 Matt Turner
2013-08-02 5:59 Brian Dolbec
2013-05-27 20:26 Richard Farina
2013-05-27 20:26 Richard Farina
2013-05-27 20:15 Richard Farina
2013-02-23 2:02 Matt Turner
2013-02-23 2:02 Matt Turner
2013-02-23 2:02 Matt Turner
2013-02-23 2:02 Matt Turner
2013-02-23 2:02 Matt Turner
2013-02-05 8:34 Matt Turner
2012-11-22 2:51 Jorge Manuel B. S. Vicetto
2012-11-22 2:51 Jorge Manuel B. S. Vicetto
2012-11-01 20:04 Richard Farina
2012-10-29 20:36 Anthony G. Basile
2012-10-29 20:35 Anthony G. Basile
2012-10-14 5:50 Matt Turner
2012-08-31 0:34 Jorge Manuel B. S. Vicetto
2012-08-29 4:17 Jorge Manuel B. S. Vicetto
2012-08-26 19:30 Jorge Manuel B. S. Vicetto
2012-08-23 5:55 Jorge Manuel B. S. Vicetto
2012-08-23 5:55 Jorge Manuel B. S. Vicetto
2012-08-23 5:55 Jorge Manuel B. S. Vicetto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388723968.7a4705adf2578f8131ae5fa4192d383c82a0516d.dol-sen@gentoo \
--to=brian.dolbec@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox