prereq-build: do not replace binaries with symlinks
authorMichael Pratt <mcpratt@pm.me>
Sat, 27 May 2023 21:11:47 +0000 (17:11 -0400)
committerPetr Štetiar <ynezz@true.cz>
Mon, 5 Jun 2023 06:31:50 +0000 (08:31 +0200)
Some programs, like bash and patch, are checked by prereq stage
and have a symlink installed, but then is later built from source.

Now that the prereq-build checks are not successful
just by finding the file alone, it is possible for
a new symlink to overwrite the installed binary.

If a normal file is found in staging_dir/host/bin,
let the check look for the associated stampfile, and if found,
skip creation of a symlink and exit successfully.

Suggested-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
include/prereq.mk

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