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, 5 Jun 2023 06:31:52 +0000 (08:31 +0200)
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>
include/prereq.mk

index c888268d852074859bd9844171b7d75adc5d521a..546f36b8e3e8a54628870bf2c90602580b9718c0 100644 (file)
@@ -114,6 +114,11 @@ define SetupHostCommand
                                                find "$(STAGING_DIR_HOST)/stamp" | grep $(strip $(1)) && \
                                                [ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
                                                ;; \
+                                       *" -> /"*) \
+                                               ;; \
+                                       *" -> "*) \
+                                               [ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
+                                               ;; \
                                esac; \
                                ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
                                exit 1; \