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