diff options
author | Michael E Brown <mebrown@michaels-house.net> | 2007-11-28 23:32:43 -0600 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2007-11-28 23:32:43 -0600 |
commit | 9f0c947517846ffb617bd294856d068660535e1b (patch) | |
tree | 49e5f7f5342c18b22added8e00533161eeb0fca7 | |
parent | d4309a181b403b37fdb857016699ce09d06fd868 (diff) | |
download | mock-9f0c947517846ffb617bd294856d068660535e1b.tar.gz mock-9f0c947517846ffb617bd294856d068660535e1b.tar.xz mock-9f0c947517846ffb617bd294856d068660535e1b.zip |
add option to disable internal /dev setup.
-rw-r--r-- | etc/defaults.cfg | 5 | ||||
-rwxr-xr-x | src/mock.py | 1 | ||||
-rw-r--r-- | src/py-libs/backend.py | 49 |
3 files changed, 34 insertions, 21 deletions
diff --git a/etc/defaults.cfg b/etc/defaults.cfg index 88f6ec2..2a68e0b 100644 --- a/etc/defaults.cfg +++ b/etc/defaults.cfg @@ -25,6 +25,11 @@ # config_opts['root_log_fmt_name'] = "detailed" # config_opts['state_log_fmt_name'] = "state" # +# mock will normally set up a minimal chroot /dev. +# If you want to use a pre-configured /dev, disable this and use the bind-mount +# plugin to mount your special /dev +# config_opts['internal_dev_setup'] = True +# # internal_setarch defaults to 'True' if the python 'ctypes' package is # available. It is in the python std lib on >= python 2.5. On older versions, # it is available as an addon. On systems w/o ctypes, it will default to diff --git a/src/mock.py b/src/mock.py index 234cd5c..794d7f2 100755 --- a/src/mock.py +++ b/src/mock.py @@ -135,6 +135,7 @@ def setup_default_config_opts(config_opts): config_opts['state_log_fmt_name'] = "state" config_opts['online'] = True + config_opts['internal_dev_setup'] = True try: import ctypes config_opts['internal_setarch'] = True diff --git a/src/py-libs/backend.py b/src/py-libs/backend.py index 997614a..f3046ee 100644 --- a/src/py-libs/backend.py +++ b/src/py-libs/backend.py @@ -75,6 +75,7 @@ class Root(object): self.cachedir = os.path.join(self.cache_topdir, self.sharedRootName) self.useradd = config['useradd'] self.online = config['online'] + self.internal_dev_setup = config['internal_dev_setup'] self.plugins = config['plugins'] self.pluginConf = config['plugin_conf'] @@ -88,11 +89,9 @@ class Root(object): # mount/umount self.umountCmds = ['umount -n %s/proc' % self.rootdir, - 'umount -n %s/dev/pts' % self.rootdir, 'umount -n %s/sys' % self.rootdir, ] self.mountCmds = ['mount -n -t proc mock_chroot_proc %s/proc' % self.rootdir, - 'mount -n -t devpts mock_chroot_devpts %s/dev/pts' % self.rootdir, 'mount -n -t sysfs mock_chroot_sysfs %s/sys' % self.rootdir, ] @@ -193,7 +192,6 @@ class Root(object): 'etc/yum.repos.d', 'etc/yum', 'proc', - 'dev/pts', 'sys', ]: mock.util.mkdirIfAbsent(os.path.join(self.rootdir, item)) @@ -237,6 +235,30 @@ class Root(object): fo.write(self.chroot_file_contents[key]) fo.close() + if self.internal_dev_setup: + self._setupDev() + + # yum stuff + self.state("running yum") + self._mountall() + try: + if not self.chrootWasCleaned: + self.chroot_setup_cmd = 'update' + self._yum(self.chroot_setup_cmd, returnOutput=1) + finally: + self._umountall() + + # create user + self._makeBuildUser() + + # create rpmbuild dir + self._buildDirSetup() + + # done with init + self._callHooks('postinit') + + @traceLog(moduleLog) + def _setupDev(self): # files in /dev mock.util.rmtree(os.path.join(self.rootdir, "dev")) mock.util.mkdirIfAbsent(os.path.join(self.rootdir, "dev", "pts")) @@ -263,24 +285,9 @@ class Root(object): os.symlink("/proc/self/fd/2", os.path.join(self.rootdir, "dev/stderr")) os.umask(prevMask) - # yum stuff - self.state("running yum") - self._mountall() - try: - if not self.chrootWasCleaned: - self.chroot_setup_cmd = 'update' - self._yum(self.chroot_setup_cmd, returnOutput=1) - finally: - self._umountall() - - # create user - self._makeBuildUser() - - # create rpmbuild dir - self._buildDirSetup() - - # done with init - self._callHooks('postinit') + # mount/umount + self.umountCmds.append('umount -n %s/dev/pts' % self.rootdir) + self.mountCmds.append('mount -n -t devpts mock_chroot_devpts %s/dev/pts' % self.rootdir) @traceLog(moduleLog) def doChroot(self, command, env="", *args, **kargs): |