commit:     40e80db729938c776b98b65812bc6a50b27f8c4f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 01:53:01 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Apr 18 16:50:36 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=40e80db7

Use cmd instead of os.system(), simplify code duplication.

---
 catalyst/base/stagebase.py | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index aa9be38..90dd37d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -927,6 +927,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
        def bind(self):
                for x in self.mounts:
+                       _cmd = ''
                        #print "bind(); x =", x
                        target = normpath(self.settings["chroot_path"] + 
self.target_mounts[x])
                        ensure_dirs(target, mode=0755)
@@ -941,28 +942,22 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                self.snapshot_lock_object.read_lock()
                        if os.uname()[0] == "FreeBSD":
                                if src == "/dev":
-                                       cmd = "mount -t devfs none " + target
-                                       retval=os.system(cmd)
+                                       _cmd = "mount -t devfs none " + target
                                else:
-                                       cmd = "mount_nullfs " + src + " " + 
target
-                                       retval=os.system(cmd)
+                                       _cmd = "mount_nullfs " + src + " " + 
target
                        else:
                                if src == "tmpfs":
                                        if "var_tmpfs_portage" in self.settings:
-                                               cmd = "mount -t tmpfs -o size=" 
+ \
+                                               _cmd = "mount -t tmpfs -o 
size=" + \
                                                        
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)
+                                       _cmd = "mount -t tmpfs -o 
noexec,nosuid,nodev shm " + target
                                else:
-                                       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 + "\n" + cmd)
+                                       _cmd = "mount --bind " + src + " " + 
target
+                       #print "bind(); _cmd =", _cmd
+                       cmd(_cmd, "Bind mounting Failed", env=self.env, 
fail_func=self.unbind)
+               #print "bind(); finished :D"
 
        def unbind(self):
                ouch=0

Reply via email to