Re: bind-mounting files in mock
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 18 Mar 2009 14:52:35 -0400 Jay Greguske jgreg...@redhat.com wrote: 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 Jay, Finally got some time to pull in mock patches and work on bugs. Sorry it's taken this long... I'm not seeing how your stuff would work. A bind-mount only works on directories, not files. If I try to bind-mount /dev/loop0 somewhere by hand I get the following: $ mkdir -p /tmp/foo cd /tmp/foo $ sudo mount -n --bind /dev/loop0 . mount: Not a directory $ mkdir dev $ sudo mount -n --bind /dev/loop0 dev mount: Not a directory What am I missing here? Clark -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAknM5GYACgkQHyuj/+TTEp1CWQCgsPClxT4qV2XCQx3oyHihhBlE t9UAoIekmO6wJCgp9T+OwukEguLJ21Qz =63u9 -END PGP SIGNATURE- -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
Re: bind-mounting files in mock
Hi Clark, If you're bind mounting a file, you have to bind it to an existing file, not a directory. Try touching /dev/myloop first, and then mounting the real loop device to it. Thanks, -jay Clark Williams wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 18 Mar 2009 14:52:35 -0400 Jay Greguske jgreg...@redhat.com wrote: 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 Jay, Finally got some time to pull in mock patches and work on bugs. Sorry it's taken this long... I'm not seeing how your stuff would work. A bind-mount only works on directories, not files. If I try to bind-mount /dev/loop0 somewhere by hand I get the following: $ mkdir -p /tmp/foo cd /tmp/foo $ sudo mount -n --bind /dev/loop0 . mount: Not a directory $ mkdir dev $ sudo mount -n --bind /dev/loop0 dev mount: Not a directory What am I missing here? Clark -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAknM5GYACgkQHyuj/+TTEp1CWQCgsPClxT4qV2XCQx3oyHihhBlE t9UAoIekmO6wJCgp9T+OwukEguLJ21Qz =63u9 -END PGP SIGNATURE- -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
Re: bind-mounting files in mock
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wow, that's bizarre (but works). :) It's not described in the man page, so I'm a bit leery about depending on that behavior. That being said, it's not a normal use-case for mock builds, so it'll probably only bite the livecd creation stuff it the bind-mount behavior changes. Ok, I'll pull it in for the next release. Clark On Fri, 27 Mar 2009 10:39:54 -0400 Jay Greguske jgreg...@redhat.com wrote: Hi Clark, If you're bind mounting a file, you have to bind it to an existing file, not a directory. Try touching /dev/myloop first, and then mounting the real loop device to it. Thanks, -jay Clark Williams wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 18 Mar 2009 14:52:35 -0400 Jay Greguske jgreg...@redhat.com wrote: 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 Jay, Finally got some time to pull in mock patches and work on bugs. Sorry it's taken this long... I'm not seeing how your stuff would work. A bind-mount only works on directories, not files. If I try to bind-mount /dev/loop0 somewhere by hand I get the following: $ mkdir -p /tmp/foo cd /tmp/foo $ sudo mount -n --bind /dev/loop0 . mount: Not a directory $ mkdir dev $ sudo mount -n --bind /dev/loop0 dev mount: Not a directory What am I missing here? Clark -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAknM5GYACgkQHyuj/+TTEp1CWQCgsPClxT4qV2XCQx3oyHihhBlE t9UAoIekmO6wJCgp9T+OwukEguLJ21Qz =63u9 -END PGP SIGNATURE- -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAknM8swACgkQHyuj/+TTEp2i/QCfZa1y4KBC2z4A3ZP9+rO8muZF Q3gAoItg2iK5NMf9vnfVLgaT4BSTWhLC =j3Sw -END PGP SIGNATURE- -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
Re: bind-mounting files in mock
On Fri, 2009-03-27 at 10:37 -0500, Clark Williams wrote: It's not described in the man page, so I'm a bit leery about depending on that behavior. That being said, it's not a normal use-case for mock builds, so it'll probably only bite the livecd creation stuff it the bind-mount behavior changes. Ok, I'll pull it in for the next release. I need that functionality too when building install images. Rather than see more and different code paths when chroot generating, I think there would be some value in using the same code path regardless of how the chroot is used. I think the bind mounting of dev/ is only there for the loop entries, I don't know of any other mock consumers that require a real /dev/ tree. We might consider just always file bind mounting a few loop entries in and only having one code path. -- Jesse Keating Fedora -- FreedomĀ² is a feature! identi.ca: http://identi.ca/jkeating signature.asc Description: This is a digitally signed message part -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
Re: bind-mounting files in mock
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, 27 Mar 2009 08:57:17 -0700 Jesse Keating jkeat...@redhat.com wrote: On Fri, 2009-03-27 at 10:37 -0500, Clark Williams wrote: It's not described in the man page, so I'm a bit leery about depending on that behavior. That being said, it's not a normal use-case for mock builds, so it'll probably only bite the livecd creation stuff it the bind-mount behavior changes. Ok, I'll pull it in for the next release. I need that functionality too when building install images. Rather than see more and different code paths when chroot generating, I think there would be some value in using the same code path regardless of how the chroot is used. I think the bind mounting of dev/ is only there for the loop entries, I don't know of any other mock consumers that require a real /dev/ tree. We might consider just always file bind mounting a few loop entries in and only having one code path. That works for me. I'm currently trying to figure out the regression with 3rd party repos, so if you have the time and can gin up a patch, that'd be great; if not I'll work on it after I figure the BZ out. Clark -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAknNF3QACgkQHyuj/+TTEp2kZgCfdrRSiGQLWukV3OT03EXFosZv 8VEAoLmdboXfdgVafNi7SYgfz4qnc+KZ =qdbd -END PGP SIGNATURE- -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
Re: bind-mounting files in mock
On Friday, March 27 2009, Jesse Keating said: On Fri, 2009-03-27 at 10:37 -0500, Clark Williams wrote: It's not described in the man page, so I'm a bit leery about depending on that behavior. That being said, it's not a normal use-case for mock builds, so it'll probably only bite the livecd creation stuff it the bind-mount behavior changes. Ok, I'll pull it in for the next release. I need that functionality too when building install images. Rather than see more and different code paths when chroot generating, I think there would be some value in using the same code path regardless of how the chroot is used. I think the bind mounting of dev/ is only there for the loop entries, I don't know of any other mock consumers that require a real /dev/ tree. We might consider just always file bind mounting a few loop entries in and only having one code path. You can't really just do a few as you may need however many there are on the real system. If the idea is to make them by default it's probably better to just make n of them based on the host. But then the chroot does have a way of affecting outside of it :/ Jeremy -- Fedora-buildsys-list mailing list Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list
bind-mounting files in mock
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 jgreg...@redhat.com 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 Fedora-buildsys-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-buildsys-list