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): mock-0.6-4.fc5 How reproducible: deterministic 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: /var/lib/mock/distro/ /var/lib/mock/distro/result /var/lib/mock/distro/result/root.log /var/lib/mock/distro/result/mockconfig.log /var/lib/mock/distro/result/build.log /var/lib/mock/distro/state /var/lib/mock/distro/state/status /var/lib/mock/distro/root 4. login as user2 5. mock -r <distro> init Actual results: Step 5. fails. # mock -r distro init Traceback (most recent call last): File "/usr/bin/mock", line 985, in ? main() File "/usr/bin/mock", line 956, in main do_clean(config_opts, init=1) File "/usr/bin/mock", line 826, in do_clean my = Root(config_opts) File "/usr/bin/mock", line 129, in __init__ self.state("init") File "/usr/bin/mock", line 202, in state sfo = open(sf, 'w') IOError: [Errno 13] Permission denied: '/var/lib/mock/distro/state/status' Expected results: Step 5. to succeed. Additional info: 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" operation. 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 > internal > cleanup function is called as part of an "init" operation as well as a "clean" > operation. 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>