[Buildroot] [PATCH 1/2] core: make symlinks relative when preparing the SDK

Joel Carlson JoelsonCarl at gmail.com
Fri Dec 7 19:35:30 UTC 2018

On Fri, Dec 7, 2018 at 11:10 AM Yann E. MORIN <yann.morin.1998 at free.fr> wrote:
> The SDK is supposed to be relocatable, so symlinks must not be
> absolute.
> Add a new helper script, that replaces all absolute symlinks with
> relative ones.
> The ideal solution would use the shortest relative path for the
> destination, but it is non-trivial to come up with. We just ensure
> the relative path does not cross a common base directory, and compute
> all the paths relative to that anchor.
> This can give non-optimum relative symlinks, like:
>     /base-dir/bin/foo -> ../bin/bar
> when the optimum would have been:
>     /base-dir/bin/foo -> bar
> Finally, as a sanity check, ensure there is not relative symlinl
> pointing out of the base directory, because their targets would be
> missing from the SDK.
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
> Cc: Joel Carlson <JoelsonCarl at gmail.com>

Reviewed-by: Joel Carlson <JoelsonCarl at gmail.com>
Tested-by: Joel Carlson <JoelsonCarl at gmail.com>

Applied this patch and patch 2/2 to my branch and made sure the SDK
generated and the symlinks I had seen fail before looked to be
I also added a few of my own symlinks into host/ with absolute paths
pointing both inside and outside of host/ to test that the cases
caught them.
And I added some relative symlinks that crossed the boundary to make
sure that case was caught as well.

More information about the buildroot mailing list