aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-04-15 10:33:17 +0200
committerEike Ziller <eike.ziller@qt.io>2019-05-02 08:54:28 +0000
commit5064d94f7145a8e971e6f2222baf89da5c2ad83a (patch)
tree03b9ca5763a6eba2d10b7a6311f6a1d30d8baaec
parentc2f68cbc540aed5f8b46ce2ec39a29a60872285f (diff)
Fix move_tree over file system bounds in case of directory symlinks
Looks like shutil.move fails with "OSError: Cannot call rmtree on a symbolic link" in that case. When removing the source, it probably checks if the src is a dir (os.isdir is True for symlinks to directories), and then fails when using shutil.rmtree. Change-Id: I24ea4b2832449f43d5aa1d34728bda1da1ad26f8 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--packaging-tools/bldinstallercommon.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py
index 682e8bfe3..5bcb62cf6 100644
--- a/packaging-tools/bldinstallercommon.py
+++ b/packaging-tools/bldinstallercommon.py
@@ -305,7 +305,12 @@ def move_tree(srcdir, dstdir, pattern=None):
os.mkdir(dstfname)
move_tree(srcfname, dstfname)
elif pattern is None or fnmatch.fnmatch(name, pattern):
- shutil.move(srcfname, dstfname)
+ if os.path.islink(srcfname): # shutil.move fails moving directory symlinks over file system bounds...
+ linkto = os.readlink(srcfname)
+ os.symlink(linkto, dstfname)
+ os.remove(srcfname)
+ else:
+ shutil.move(srcfname, dstfname)
###############################