From b373dac9e493e97d029be0c2ab2942b6213eeba5 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 31 May 2023 11:04:57 +0200 Subject: [PATCH] bind_mount: pre-create dest directory before mounting file Previously, the bind_mount plugin relied on pre-existing directory tree, typically created by the chroot directory tree by the _PackageManager installation. So it was quite easy to mount stuff like `/var/run/socket` because `/var/run` always existed. Problem happened with files like `/var/run/subdirectory/socket`. Relates: #1091 --- mock/py/mockbuild/plugins/bind_mount.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mock/py/mockbuild/plugins/bind_mount.py b/mock/py/mockbuild/plugins/bind_mount.py index 67225d248..5e3f12701 100644 --- a/mock/py/mockbuild/plugins/bind_mount.py +++ b/mock/py/mockbuild/plugins/bind_mount.py @@ -50,4 +50,6 @@ def _bindMountCreateDirs(self): file_util.mkdirIfAbsent(srcdir) file_util.mkdirIfAbsent(self.buildroot.make_chroot_path(destdir)) else: - file_util.touch(self.buildroot.make_chroot_path(destdir)) + dest_file = self.buildroot.make_chroot_path(destdir) + file_util.mkdirIfAbsent(os.path.dirname(dest_file)) + file_util.touch(dest_file)