On 8/11/10 3:26 PM, Alan Franzoni wrote:
[cut]

I now realized that Paul's concern was slightly different than my own,
but it can be addressed in the very same way using reversed(). An
updated patch has been loaded on the bugtracker and is attached here.



-- 
Alan Franzoni
contact me at pub...@[mysurname].eu
diff --git a/py/mock/backend.py b/py/mock/backend.py
index eb97219..a7b0c4b 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -632,12 +632,26 @@ class Root(object):
     decorate(traceLog())
     def _umountall(self):
         """umount all mounted chroot fs."""
-        # Unwind mounts by umounting in the opposite order of the mounts
-        umountCmds = self.umountCmds
-        umountCmds.reverse()
-        for cmd in umountCmds:
+        # first try removing all expected mountpoints. 
+        for cmd in reversed(self.umountCmds):
             self.root_log.debug(cmd)
-            mock.util.do(cmd, raiseExc=0, shell=True)
+            try:
+                mock.util.do(cmd, raiseExc=1, shell=True)
+            except mock.exception.Error, e:
+                # the exception already contains info about the error.
+                self.root_log.warning(e) 
+        # then remove anything that might be left around.
+        mountpoints = open("/proc/mounts").read().strip().split("\n")
+        # umount in reverse mount order to prevent nested mount issues that
+        # may prevent clean unmount.
+        for mountline in reversed(mountpoints):
+            mountpoint = mountline.split()[1]
+            if os.path.realpath(mountpoint).startswith(os.path.realpath(
+                self.makeChrootPath() + "/")):
+               cmd = "umount -n %s" % mountpoint
+               self.root_log.warning("Forcibly unmounting '%s' from chroot." %
+                       mountpoint)
+               mock.util.do(cmd, raiseExc=0, shell=True)
 
     decorate(traceLog())
     def _yum(self, cmd, returnOutput=0):
--
buildsys mailing list
buildsys@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/buildsys

Reply via email to