[PATCH] Create missing directories for config_opts['files'] elements

Paul Howarth paul at city-fan.org
Wed Apr 28 14:53:12 UTC 2010


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Create-missing-directories-for-config_opts-files.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/buildsys/attachments/20100428/80ddde62/attachment.bin 


More information about the buildsys mailing list