sb: Fix copy_tree coping links on Linux

Overwriting symlinks did not work on Linux. This change manages the
coping of links with special code. The copy worked on FreeBSD.
This commit is contained in:
Chris Johns 2013-08-22 11:38:44 +10:00
parent 75aa2db1c6
commit 85007c35d1

View File

@ -153,6 +153,18 @@ def copy_tree(src, dst):
try:
if os.path.islink(srcname):
linkto = os.readlink(srcname)
if os.path.exists(dstname):
if os.path.islink(dstname):
dstlinkto = os.readlink(dstname)
if linkto != dstlinkto:
log.warning('copying tree: update of link does not match: %s -> %s: %s' % \
(dstname, dstlinkto))
os.remove(dstname)
else:
log.warning('copying tree: destination is not a link: %s -> %s: %s' % \
(dstname, dstlinkto))
os.remove(dstname)
else:
os.symlink(linkto, dstname)
elif os.path.isdir(srcname):
copy_tree(srcname, dstname)