[Scons-users] Bug: Copy(..., symlinks=False) of symlinks with relative target pathnames

Nathan Kennedy nkennedy at grammatech.com
Mon Mar 23 12:17:55 EDT 2015


Issue 2395 added a "symlinks" parameter to SCons.Defaults.Copy to copy 
symlinks rather than their target, defaulting to true. When using 
symlinks=False to copy the symlink's target, if the target has a 
relative path (e.g. "../../libfoo.so"), the path is resolved relative to 
the current working directory rather than the symlink's directory. If 
these differ, the copy will either fail or copy the wrong file.

We fixed this with the patch below.

Best,
Nathan

--- src/engine/SCons/Defaults.py.orig    2015-03-23 12:10:51.983117000 -0400
+++ src/engine/SCons/Defaults.py 2015-03-23 12:11:54.057539000 -0400
@@ -35,10 +35,11 @@

  __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"


  import os
+import os.path
  import errno
  import shutil
  import stat
  import time
  import sys
@@ -200,11 +201,11 @@
      elif os.path.islink(src):
          linkto = os.readlink(src)
          if symlinks:
              return os.symlink(linkto, dest)
          else:
-            return copy_func(dest, linkto, symlinks)
+            return copy_func(dest, os.path.realpath(src))
      elif os.path.isfile(src):
          return shutil.copy2(src, dest)
      else:
          return shutil.copytree(src, dest, symlinks)



More information about the Scons-users mailing list