commit: 992b4ffdcbf469db543c9cab90a5f7a3a4125c97
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 10 08:34:23 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec 10 08:54:21 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=992b4ffd
bin/doins.py: remove file before creating symlink (bug 640376)
Fixes: d9522ba661b5 ("Rewrite doins in python (bug 624526)")
Bug: https://bugs.gentoo.org/640376
bin/doins.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bin/doins.py b/bin/doins.py
index ad8f90eee..92e450979 100644
--- a/bin/doins.py
+++ b/bin/doins.py
@@ -405,7 +405,11 @@ def _doins(opts, install_runner, relpath, source_root):
not os.readlink(source).startswith(
opts.distdir)):
linkto = os.readlink(source)
- shutil.rmtree(dest, ignore_errors=True)
+ try:
+ os.unlink(dest)
+ except OSError as e:
+ if e.errno == errno.EISDIR:
+ shutil.rmtree(dest,
ignore_errors=True)
os.symlink(linkto, dest)
return True
except Exception: