prereq-build: replace relative symlinks only if broken
authorMichael Pratt <mcpratt@pm.me>
Mon, 29 May 2023 09:38:33 +0000 (05:38 -0400)
committerPetr Štetiar <ynezz@true.cz>
Mon, 12 Jun 2023 20:10:23 +0000 (22:10 +0200)
commite972e4f2a9ecbb65b826f53b890e4705c6034f43
treef5c0bb74f9a74e323880d03295b4c6f52ee6a511
parent43b92ff6ce203dee5049c3ad4f28c95a69dd0694
prereq-build: replace relative symlinks only if broken

Some programs installed to staging_dir/host/bin
also install some symlinks to itself
for an alternative name.

Some of those new symlinks are overwriting
symlinks that were installed by prereq stage.

If prereq stage were to somehow be run again,
it should not be overwriting symlinks
that point to programs that are already built.

To filter that out, catch all symlinks
after first catching all symlinks
that have an absolute target
after all other cases in the case statement,
make sure it is not broken, and if so exit successfully.

Suggested-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
(cherry picked from commit b890e2fbf9211648ad4a74f3e8b47bbf04a3cc7a)
include/prereq.mk