Hello,
While trying to get livecd-creator working in a mock-built chroot, I
discovered that only directories could be bind-mounted using the
bind_mount plugin. I made a few code changes and attached a patch for
your consideration that enables the bind-mounting of files. Like
directories, the bind-mounting of files will require
'internal_dev_setup' be set to False, otherwise the mount command will fail.
In the chroot configuration file the following syntax would be allowed
(which looks just like that which was used for bind-mounting directories):
config_opts['plugin_conf']['bind_mount_opts']['files'].append(('/dev/loop0',
'/dev/loop0'))
Please let me know what you think, and thanks in advance for your time!
- Jay
>From 7d223b627f83345cbbe4f5313ed664ba41ed6c94 Mon Sep 17 00:00:00 2001
From: Jay Greguske <[email protected]>
Date: Wed, 18 Mar 2009 14:32:28 -0400
Subject: [PATCH] support to bind_mount files
---
py/mock.py | 3 +++
py/mock/plugins/bind_mount.py | 9 ++++++---
py/mock/util.py | 1 +
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/py/mock.py b/py/mock.py
index 408b421..c0b9366 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -253,6 +253,9 @@ def setup_default_config_opts(config_opts, unprivUid):
# specify like this:
# ('/host/path', '/bind/mount/path/in/chroot/' ),
# ('/another/host/path', '/another/bind/mount/path/in/chroot/'),
+ ], 'files': [
+ # same syntax for files as above, but for files:
+ # ('/dev/loop0', '/dev/loop0')
]},
'tmpfs_enable': False,
'tmpfs_opts': {'required_ram_mb': 900},
diff --git a/py/mock/plugins/bind_mount.py b/py/mock/plugins/bind_mount.py
index ff531f0..a8efffc 100644
--- a/py/mock/plugins/bind_mount.py
+++ b/py/mock/plugins/bind_mount.py
@@ -27,11 +27,14 @@ class BindMount(object):
self.bind_opts = conf
rootObj.bindMountObj = self
rootObj.addHook("preinit", self._bindMountPreInitHook)
- for srcdir, destdir in self.bind_opts['dirs']:
- rootObj.umountCmds.append('umount -n %s' % rootObj.makeChrootPath(destdir))
- rootObj.mountCmds.append('mount -n --bind %s %s' % (srcdir, rootObj.makeChrootPath(destdir)))
+
+ for src, dest in self.bind_opts['dirs'] + self.bind_opts['files']:
+ rootObj.umountCmds.append('umount -n %s' % rootObj.makeChrootPath(dest))
+ rootObj.mountCmds.append('mount -n --bind %s %s' % (src, rootObj.makeChrootPath(dest)))
decorate(traceLog())
def _bindMountPreInitHook(self):
for srcdir, destdir in self.bind_opts['dirs']:
mock.util.mkdirIfAbsent(self.rootObj.makeChrootPath(destdir))
+ for srcfile, destfile in self.bind_opts['files']:
+ mock.util.touch(self.rootObj.makeChrootPath(destfile))
diff --git a/py/mock/util.py b/py/mock/util.py
index f52003e..d4f6236 100644
--- a/py/mock/util.py
+++ b/py/mock/util.py
@@ -65,6 +65,7 @@ def mkdirIfAbsent(*args):
decorate(traceLog())
def touch(fileName):
+ mkdirIfAbsent(os.path.dirname(fileName))
getLog().debug("touching file: %s" % fileName)
fo = open(fileName, 'w')
fo.close()
--
1.5.5.6
--
Fedora-buildsys-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list