[PATCH] mock _init _umountall

Paul B Schroeder paulbsch at vbridges.com
Fri Jun 25 20:11:17 UTC 2010


Hello all...

Recently, I was doing some work which needed a more extensive /dev than the mock internal dev setup.  So I tried doing this in site-defaults.cfg:
config_opts['internal_dev_setup'] = False
config_opts['plugin_conf']['bind_mount_enable'] = True
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/dev', '/dev' ))

And discovered that mock chroot init was failing due _umountall getting called (in _init) before _makeBuildUser.  In _makeBuildUser there is a perl command which, for whatever reason, would fail due to /dev/null not being available at that point.

At any rate, the following patch seems to take care of the issue.  And it would seem to be a better way to handle this in general as I would expect _umountall to be the last method called.

It would be awesome if this or something similar could be applied..

Thanks...Paul... 


diff --git a/py/mock/backend.py b/py/mock/backend.py
index ca06f59..9df438b 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -282,24 +282,24 @@ class Root(object):
             self._mountall()
             if self.chrootWasCleaned:
                 self._yum(self.chroot_setup_cmd, returnOutput=1)
-        finally:
-            self._umountall()
 
-        # create user
-        self._makeBuildUser()
+            # create user
+            self._makeBuildUser()
 
-        # create rpmbuild dir
-        self._buildDirSetup()
+            # create rpmbuild dir
+            self._buildDirSetup()
 
-        # set up timezone to match host
-        localtimedir = self.makeChrootPath('etc')
-        localtimepath = self.makeChrootPath('etc', 'localtime')
-        if os.path.exists(localtimepath):
-            os.remove(localtimepath)
-        shutil.copy2('/etc/localtime', localtimedir)
+            # set up timezone to match host
+            localtimedir = self.makeChrootPath('etc')
+            localtimepath = self.makeChrootPath('etc', 'localtime')
+            if os.path.exists(localtimepath):
+                os.remove(localtimepath)
+            shutil.copy2('/etc/localtime', localtimedir)
 
-        # done with init
-        self._callHooks('postinit')
+            # done with init
+            self._callHooks('postinit')
+        finally:
+            self._umountall()
 
     decorate(traceLog())
     def _setupDev(self):




-- 
---
Paul B Schroeder
<paulbsch "at" vbridges "dot" com>


More information about the buildsys mailing list