Red Hat Bugzilla – Bug 198515
mock -r distro clean does not clean /var/lib/mock/distro
Last modified: 2013-01-09 22:59:35 EST
Description of problem:
mock -r distro clean
doesn't clean up /var/lib/mock/distro
It leaves directories behind below /var/lib/mock/distro.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. login as user1
2. mock -r <distro> init
=> Creates /var/lib/mock/<distro> directory hierarchy
3. mock -r <distro> clean
=> Largely empties /var/lib/mock/<distro> directory hierarchy
but leave directories and files behind:
4. login as user2
5. mock -r <distro> init
Step 5. fails.
# mock -r distro init
Traceback (most recent call last):
File "/usr/bin/mock", line 985, in ?
File "/usr/bin/mock", line 956, in main
File "/usr/bin/mock", line 826, in do_clean
my = Root(config_opts)
File "/usr/bin/mock", line 129, in __init__
File "/usr/bin/mock", line 202, in state
sfo = open(sf, 'w')
IOError: [Errno 13] Permission denied: '/var/lib/mock/distro/state/status'
Step 5. to succeed.
A simple "rm -rf /var/lib/mock/<distro>" after "mock -r <distro> clean" resolves
this issue, i.e. an analogous operation at the end of "mock clean" would likely
resolve this issue, too.
The directories and files that you're seeing are created *after* a clean
operation to ensure that the hierarchy is correct. This is because the internal
cleanup function is called as part of an "init" operation as well as a "clean"
Changing this behavior will require some re-architecting in how the Root object
handles init versus clean ops. Either that or changing permission/ownership of
those files so your "user2" can nuke them.
(In reply to comment #1)
> The directories and files that you're seeing are created *after* a clean
> operation to ensure that the hierarchy is correct. This is because the
> cleanup function is called as part of an "init" operation as well as a "clean"
Well - what shall I say - your problem ;)
'mock clean' is documented (man mock) as:
clean - purge the chroot tree
Apparently mock doesn't do this.
Also, I think I need to emphasize the severity of this bug: It classifies mock
as "not multiuser-capabile", i.e. as unusable in a multiuser environment.
This behavior got cleaned up in the Great Re-Write that happened over the last year.
mock -r distro clean
now deletes /var/lib/mock/<distro>