If I attempt to use:
config_opts['files']['some/file'] = ...
to create a file in a directory that's not already created as part of
the chroot "skeleton" in mock, it crashes out with a "No such file or
directory" error like this:
$ mock -r city-fan-fedora-11-x86_64 libssh2-1.2.5-2.0.cf.fc12.src.rpm
INFO: mock.py version 1.0.7 starting...
State Changed: init plugins
State Changed: start
INFO: Start(libssh2-1.2.5-2.0.cf.fc12.src.rpm)
Config(city-fan-fedora-11-x86_64)
State Changed: lock buildroot
State Changed: clean
State Changed: init
State Changed: lock buildroot
Mock Version: 1.0.7
INFO: Mock Version: 1.0.7
INFO: mounting tmpfs.
INFO: enabled root cache
INFO: enabled yum cache
State Changed: cleaning yum metadata
INFO: enabled ccache
INFO: unmounting tmpfs.
ERROR: Exception(libssh2-1.2.5-2.0.cf.fc12.src.rpm)
Config(city-fan-fedora-11-x86_64) 0 minutes 0 seconds
INFO: Results and/or logs in: /var/lib/mock/city-fan-fedora-11-x86_64/result
ERROR: [Errno 2] No such file or directory:
'/var/lib/mock/city-fan-fedora-11-x86_64/root/selinux/enforce'
Traceback (most recent call last):
File "/usr/sbin/mock", line 693, in <module>
main(retParams)
File "/usr/sbin/mock", line 635, in main
do_rebuild(config_opts, chroot, args)
File "<peak.util.decorators.rewrap wrapping __main__.do_rebuild at
0x01655230>", line 3, in do_rebuild
def do_rebuild(config_opts, chroot, srpms): return
__decorated(config_opts, chroot, srpms)
File "/usr/lib/python2.6/site-packages/mock/trace_decorator.py", line
70, in trace
result = func(*args, **kw)
File "/usr/sbin/mock", line 371, in do_rebuild
chroot.init()
File "<peak.util.decorators.rewrap wrapping mock.backend.init at
0x0164D9B0>", line 3, in init
def init(self): return __decorated(self)
File "/usr/lib/python2.6/site-packages/mock/trace_decorator.py", line
70, in trace
result = func(*args, **kw)
File "/usr/lib/python2.6/site-packages/mock/backend.py", line 163, in
init
self._init()
File "<peak.util.decorators.rewrap wrapping mock.backend._init at
0x0164DDE8>", line 3, in _init
def _init(self): return __decorated(self)
File "/usr/lib/python2.6/site-packages/mock/trace_decorator.py", line
70, in trace
result = func(*args, **kw)
File "/usr/lib/python2.6/site-packages/mock/backend.py", line 270, in
_init
fo = open(p, 'w+')
IOError: [Errno 2] No such file or directory:
'/var/lib/mock/city-fan-fedora-11-x86_64/root/selinux/enforce'
This is because mock doesn't create any missing parent directories for
the file. The attached patch addresses this.
Incidentally, what I was doing was:
config_opts['files']['selinux/enforce'] = "0"
This is sufficient to fool libselinux-using applications in the chroot
into believing they're running in permissive mode, allowing for instance
an OpenSSH server to run on localhost on a high port and accept
connections as part of a package's test suite (libssh2 in this case).
This might be a useful thing to have by default, but that's a different
discussion.
Paul.
>From 36a4d735a72c3913710ae83c398faed469e6b048 Mon Sep 17 00:00:00 2001
From: Paul Howarth <[email protected]>
Date: Wed, 28 Apr 2010 15:21:35 +0100
Subject: [PATCH] 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.
---
py/mock/backend.py | 4 +++-
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])
--
1.6.6.1
--
buildsys mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/buildsys