diff options
author | Michael E Brown <mebrown@michaels-house.net> | 2007-10-21 06:14:00 -0500 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2007-10-21 06:14:00 -0500 |
commit | 117457586196119f9b4b9c80e2e761e81e21fecb (patch) | |
tree | 90391668335f0ac37d02148e3c77c186f4fc49a0 | |
parent | d115ea6765917221d8113459f381267598f4e076 (diff) | |
download | mock-117457586196119f9b4b9c80e2e761e81e21fecb.tar.gz mock-117457586196119f9b4b9c80e2e761e81e21fecb.tar.xz mock-117457586196119f9b4b9c80e2e761e81e21fecb.zip |
new plugin to optionally bind-mount host dirs into buildroot. not configured by default.
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | Makefile.in | 1 | ||||
-rwxr-xr-x | src/mock.py | 20 | ||||
-rw-r--r-- | src/py-libs/plugins/bind.py | 40 | ||||
-rw-r--r-- | src/py-libs/plugins/bind_mount.py | 40 |
5 files changed, 96 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am index 77bc5cd..b974fc1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,6 +43,7 @@ man_MANS = docs/mock.1 pluginsdir = $(pkgpythondir)/plugins plugins_PYTHON = \ + src/py-libs/plugins/bind_mount.py \ src/py-libs/plugins/ccache.py \ src/py-libs/plugins/root_cache.py \ src/py-libs/plugins/yum_cache.py diff --git a/Makefile.in b/Makefile.in index 83e9f5b..89d57a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -267,6 +267,7 @@ dist_libexec_SCRIPTS = src/mock.py man_MANS = docs/mock.1 pluginsdir = $(pkgpythondir)/plugins plugins_PYTHON = \ + src/py-libs/plugins/bind_mount.py \ src/py-libs/plugins/ccache.py \ src/py-libs/plugins/root_cache.py \ src/py-libs/plugins/yum_cache.py diff --git a/src/mock.py b/src/mock.py index 587ddf9..873bf56 100755 --- a/src/mock.py +++ b/src/mock.py @@ -1,5 +1,9 @@ #!/usr/bin/python -tt -# vim:tw=0:ts=4:sw=4:et: +# vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0: +# Originally written by Seth Vidal +# Sections taken from Mach by Thomas Vander Stichele +# Major reorganization and adaptation by Michael Brown +# Copyright (C) 2007 Michael E Brown <mebrown@michaels-house.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,8 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Written by Seth Vidal -# Sections taken from Mach by Thomas Vander Stichele # library imports import grp @@ -100,6 +102,7 @@ def command_parse(config_opts): def setup_default_config_opts(config_opts): # global config_opts['basedir'] = '/var/lib/mock/' # root name is automatically added to this + config_opts['cache_topdir'] = '/var/lib/mock/cache' config_opts['clean'] = True config_opts['chroothome'] = '/builddir' config_opts['log_config_file'] = 'logging.ini' @@ -118,9 +121,8 @@ def setup_default_config_opts(config_opts): config_opts['cleanup_on_success'] = 1 config_opts['cleanup_on_failure'] = 1 - # (global) caching-related config options - config_opts['cache_topdir'] = '/var/lib/mock/cache' - config_opts['plugins'] = ('ccache', 'yum_cache', 'root_cache') + # (global) plugins and plugin configs + config_opts['plugins'] = ('ccache', 'yum_cache', 'root_cache', 'bind_mount') config_opts['plugin_dir'] = os.path.join(PKGPYTHONDIR, "plugins") config_opts['plugin_conf'] = { 'enable_ccache': True, @@ -129,6 +131,12 @@ def setup_default_config_opts(config_opts): 'yum_cache_opts': {'max_age_days': 15}, 'enable_root_cache': True, 'root_cache_opts': {'max_age_days': 15}, + 'enable_bind_mount': True, + 'bind_mount_opts': {'dirs': ( + # specify like this: + # ( '/host/path', '/bind/mount/path/in/chroot/' ) + # ( '/another/host/path', '/another/bind/mount/path/in/chroot/' ) + )}, } # dependent on guest OS diff --git a/src/py-libs/plugins/bind.py b/src/py-libs/plugins/bind.py new file mode 100644 index 0000000..e2da4d7 --- /dev/null +++ b/src/py-libs/plugins/bind.py @@ -0,0 +1,40 @@ +# vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0: +# License: GPL2 or later see COPYING +# Written by Michael Brown +# Copyright (C) 2007 Michael E Brown <mebrown@michaels-house.net> + +# python library imports +import logging +import os + +# our imports +from mock.trace_decorator import traceLog +import mock.util + +# set up logging, module options +moduleLog = logging.getLogger("mock") +requires_api_version = "1.0" + +# plugin entry point +def init(rootObj, conf): + bind = BindMount(rootObj, conf) + +# classes +class BindMount(object): + """bind mount dirs from host into chroot""" + @traceLog(moduleLog) + def __init__(self, rootObj, conf): + self.rootObj = rootObj + self.bind_opts = conf + self.rootdir = rootObj.rootdir + rootObj.bindMountObj = self + rootObj.addHook("preinit", self._bindMountPreInitHook) + #rootObj.umountCmds.append('umount -n %s/tmp/ccache' % rootObj.rootdir) + #rootObj.mountCmds.append('mount -n --bind %s %s/tmp/ccache' % (self.ccachePath, rootObj.rootdir)) + + @traceLog(moduleLog) + def _bindMountPreInitHook(self): + #mock.util.mkdirIfAbsent(os.path.join(self.rootdir, 'tmp/ccache')) + pass + + diff --git a/src/py-libs/plugins/bind_mount.py b/src/py-libs/plugins/bind_mount.py new file mode 100644 index 0000000..e2da4d7 --- /dev/null +++ b/src/py-libs/plugins/bind_mount.py @@ -0,0 +1,40 @@ +# vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0: +# License: GPL2 or later see COPYING +# Written by Michael Brown +# Copyright (C) 2007 Michael E Brown <mebrown@michaels-house.net> + +# python library imports +import logging +import os + +# our imports +from mock.trace_decorator import traceLog +import mock.util + +# set up logging, module options +moduleLog = logging.getLogger("mock") +requires_api_version = "1.0" + +# plugin entry point +def init(rootObj, conf): + bind = BindMount(rootObj, conf) + +# classes +class BindMount(object): + """bind mount dirs from host into chroot""" + @traceLog(moduleLog) + def __init__(self, rootObj, conf): + self.rootObj = rootObj + self.bind_opts = conf + self.rootdir = rootObj.rootdir + rootObj.bindMountObj = self + rootObj.addHook("preinit", self._bindMountPreInitHook) + #rootObj.umountCmds.append('umount -n %s/tmp/ccache' % rootObj.rootdir) + #rootObj.mountCmds.append('mount -n --bind %s %s/tmp/ccache' % (self.ccachePath, rootObj.rootdir)) + + @traceLog(moduleLog) + def _bindMountPreInitHook(self): + #mock.util.mkdirIfAbsent(os.path.join(self.rootdir, 'tmp/ccache')) + pass + + |