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

William Blevins wblevins001 at gmail.com
Mon Mar 23 20:52:45 EDT 2015


Nathan,

I was able to reproduce.  I will submit the pull request soon for review.

V/R,
William

On Mon, Mar 23, 2015 at 8:24 PM, William Blevins <wblevins001 at gmail.com>
wrote:

> Nathan,
>
> Can you give me a snippet of code for the test case?  Under what condition
> does this happen?  Are you manipulating the SCons CWD?
>
> V/R,
> William
>
> On Mon, Mar 23, 2015 at 7:59 PM, William Blevins <wblevins001 at gmail.com>
> wrote:
>
>> Nathan,
>>
>> Nvm.  I reread the code, and that makes perfect sense.  It's not a link
>> anymore :)
>>
>> V/R,
>> William
>>
>> On Mon, Mar 23, 2015 at 7:52 PM, William Blevins <wblevins001 at gmail.com>
>> wrote:
>>
>>> Nathan,
>>>
>>> I think I understand what you are talking about.  Though this patch
>>> cannot solve that problem since you are recursively calling copy_func with
>>> symlink=True in the second pass thus copying the symlink itself.
>>>
>>> I will make a patch for this and a test case.
>>>
>>> V/R,
>>> William
>>>
>>>
>>>
>>> On Mon, Mar 23, 2015 at 12:17 PM, Nathan Kennedy <
>>> nkennedy at grammatech.com> wrote:
>>>
>>>> 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)
>>>>
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150323/219e0442/attachment.html>


More information about the Scons-users mailing list