rmtree: import more code from slapos.core to support case of parent directory not writable
When running uninstall
from a cmmi recipe using go, we usually have the problem below:
2020-12-21 10:16:13 slapos[22779] INFO Uninstalling galene.
2020-12-21 10:16:13 slapos[22779] INFO While:
2020-12-21 10:16:13 slapos[22779] INFO Installing.
2020-12-21 10:16:13 slapos[22779] INFO Uninstalling galene.
2020-12-21 10:16:13 slapos[22779] INFO
2020-12-21 10:16:13 slapos[22779] INFO An internal error occurred due to a bug in either zc.buildout or in a
2020-12-21 10:16:13 slapos[22779] INFO recipe being used:
2020-12-21 10:16:13 slapos[22779] INFO Traceback (most recent call last):
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/buildout.py", line 2287, in main
2020-12-21 10:16:13 slapos[22779] INFO getattr(buildout, command)(args)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/buildout.py", line 651, in install
2020-12-21 10:16:13 slapos[22779] INFO self._install_parts(install_args)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/buildout.py", line 768, in _install_parts
2020-12-21 10:16:13 slapos[22779] INFO self._uninstall_part(part, installed_part_options)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/buildout.py", line 876, in _uninstall_part
2020-12-21 10:16:13 slapos[22779] INFO installed_part_options[part]['__buildout_installed__'])
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/buildout.py", line 975, in _uninstall
2020-12-21 10:16:13 slapos[22779] INFO rmtree(f)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/rmtree.py", line 107, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO shutil.rmtree (path, onerror = retry_writeable)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 270, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO rmtree(fullname, ignore_errors, onerror)
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/shared/python2.7/ddcfbd05e3ab3c34e918cdae0776ab6d/lib/python2.7/shutil.py", line 275, in rmtree
2020-12-21 10:16:13 slapos[22779] INFO onerror(os.remove, fullname, sys.exc_info())
2020-12-21 10:16:13 slapos[22779] INFO File "/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/eggs/zc.buildout-2.7.1+slapos009-py2.7.egg/zc/buildout/rmtree.py", line 105, in retry_writeable
2020-12-21 10:16:13 slapos[22779] INFO func(path)
2020-12-21 10:16:13 slapos[22779] INFO OSError: [Errno 13] Permission denied: '/srv/slapgrid/slappart60/srv/runner/software/bb883522c8448df6883afedca622d6f1/parts/galene/pkg/mod/github.com/gorilla/websocket@v1.4.2/.circleci/config.yml'