summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Howarth <paul@city-fan.org>2010-05-05 13:05:04 -0500
committerClark Williams <williams@redhat.com>2010-05-05 13:06:18 -0500
commit256f250dce17e6240bda8ddbb6aac2bd2d12e30c (patch)
tree8360af522d84d3e94066bcfe14b2e87beebe5737
parent78cce7c8b9d299367c7f8d8e23a63ca777a90c26 (diff)
downloadmock-256f250dce17e6240bda8ddbb6aac2bd2d12e30c.tar.gz
mock-256f250dce17e6240bda8ddbb6aac2bd2d12e30c.tar.xz
mock-256f250dce17e6240bda8ddbb6aac2bd2d12e30c.zip
Create missing directories for config_opts['files'] elements
Without this fix, only files within directories pre-created as part of the chroot "skeleton" can be created using config_opts['files'], as the attempt to create the file fails with "No such file or directory". This patch allows for creation of files in arbitrary directories. Signed-off-by: Clark Williams <williams@redhat.com> (cherry picked from commit 0c4254573261bd1c9144b9fd03693572eb3ba036)
-rw-r--r--py/mock/backend.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 7ca6a1d..ca06f59 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -262,10 +262,12 @@ class Root(object):
f.write('\n')
f.close()
- # files in /etc that need doing
+ # files that need doing
for key in self.chroot_file_contents:
p = self.makeChrootPath(key)
if not os.path.exists(p):
+ # create directory if necessary
+ mock.util.mkdirIfAbsent(os.path.dirname(p))
# write file
fo = open(p, 'w+')
fo.write(self.chroot_file_contents[key])