From 85007c35d110512661ced66a218b327f65ebec22 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Thu, 22 Aug 2013 11:38:44 +1000 Subject: [PATCH] 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. --- source-builder/sb/path.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py index 643c08b..8354880 100644 --- a/source-builder/sb/path.py +++ b/source-builder/sb/path.py @@ -153,7 +153,19 @@ def copy_tree(src, dst): try: if os.path.islink(srcname): linkto = os.readlink(srcname) - os.symlink(linkto, dstname) + 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) else: