[pacman-dev] [PATCH] meson: make our symlinking script more portable

Allan McRae allan at archlinux.org
Mon Apr 19 11:37:30 UTC 2021


On 19/4/21 9:18 pm, Eli Schwartz wrote:
> On 4/19/21 3:42 AM, Allan McRae wrote:
>> On 18/4/21 12:42 pm, Eli Schwartz wrote:
>>> We do not need the --relative case as it is dead code (we only ever link
>>> a filename without directory components).
>>>
>>> For the rest, GNU-specific ln -T does two things:
>>>
>>> - if the link name is an existing directory, ln fails instead of
>>>   creating a surprising link inside the directory
>>> - if the link name is a symlink to a directory, ln treats it as a file,
>>>   and due to -f, unlinks it
>>>
>>> The second case can be portably solved by ln -n, and the first case is
>>> not actually currently functional, but we can portably replace the error
>>> message with rmdir, so, why not?
>>
>> Can we?  That assumes the directory is non-empty and rmdir fails.  I
>> don't think removing an empty directory and replacing it with a symlink
>> is expected behaviour.
>>
>> Can we just abort with an error if the target is a directory?
> 
> 
> I guess, but what's the difference between this and replacing a symlink
> to a directory?
> 

"ln -Tfs" overwrites one but not the other.  So it is staying consistent
with the old behaviour.

If we want to be consistent, don't replace a symlink to a directory either.

Allan


More information about the pacman-dev mailing list