summaryrefslogtreecommitdiffstats
path: root/include/prereq.mk
diff options
context:
space:
mode:
authorMichael Pratt <mcpratt@pm.me>2022-05-22 06:10:56 -0400
committerPetr Štetiar <ynezz@true.cz>2023-05-21 19:39:22 +0200
commitf75204036ccc56700df18258602cc65726dd653b (patch)
tree65de26493cb2ab729c2284c08263169c9b544e49 /include/prereq.mk
parent38c150612cc9be488527e342db92d5c74093213f (diff)
downloadopenwrt-f75204036ccc56700df18258602cc65726dd653b.tar.gz
openwrt-f75204036ccc56700df18258602cc65726dd653b.tar.bz2
openwrt-f75204036ccc56700df18258602cc65726dd653b.zip
prereq-build: allow host command symlinks to update
This makes the prereq stage update the symlinks installed into staging_dir/host/bin by rearrainging the way they are verified. Before, seeing or installing a symlink would result in a successful exit code, and not installing a symlink would result is a failed exit code. However, that is not able to account for the difference between existing good and bad links, or whether the link would be the same if it was reinstalled, because the check can match the program to a different path. Instead, let a success exit code represent identifying an existing symlink as exactly the same as what would be installed if it did not exist, and let a fail exit code represent needing to install the symlink or not having a match to the check criteria. The failing exit code is caught by a new second attempt for all of the check-* targets which will then indicate to the user that there was an update by having a success exit code when the check is run again and the link is the same. When there is nothing to update, the checks will run only once. This relies on the ls command to be POSIX-conformant with long format: "path/to/link -> target/of/link" Also, make sure the symlink is executable, not just a file, and the directory only needs to be created once. Fixes: #12610 Signed-off-by: Michael Pratt <mcpratt@pm.me>
Diffstat (limited to 'include/prereq.mk')
-rw-r--r--include/prereq.mk12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/prereq.mk b/include/prereq.mk
index d34539ec30..89660d323d 100644
--- a/include/prereq.mk
+++ b/include/prereq.mk
@@ -30,6 +30,8 @@ define Require
printf "Checking '$(1)'... "
if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
echo 'ok.'; \
+ elif $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
+ echo 'updated.'; \
else \
echo 'failed.'; \
echo "$(PKG_NAME): $(strip $(2))" >> $(TMP_DIR)/.prereq-error; \
@@ -107,7 +109,7 @@ endef
# 3+: candidates
define SetupHostCommand
define Require/$(1)
- [ -f "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0; \
+ mkdir -p "$(STAGING_DIR_HOST)/bin"; \
for cmd in $(call QuoteHostCommand,$(3)) $(call QuoteHostCommand,$(4)) \
$(call QuoteHostCommand,$(5)) $(call QuoteHostCommand,$(6)) \
$(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
@@ -117,9 +119,13 @@ define SetupHostCommand
bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
command -v "$$$$$$$${cmd%% *}")"; \
if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
- mkdir -p "$(STAGING_DIR_HOST)/bin"; \
+ case "$$$$$$$$(ls -dl -- $(STAGING_DIR_HOST)/bin/$(strip $(1)))" in \
+ *" -> $$$$$$$$bin"*) \
+ [ -x "$(STAGING_DIR_HOST)/bin/$(strip $(1))" ] && exit 0 \
+ ;; \
+ esac; \
ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
- exit 0; \
+ exit 1; \
fi; \
fi; \
done; \