[openwrt/openwrt] prereq-build: fix inconsistent value of $PATH

LEDE Commits lede-commits at lists.infradead.org
Tue Jun 13 07:49:49 PDT 2023


ynezz pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/c7bd7a9c5143f25dc6137439794fdf075c6cc424

commit c7bd7a9c5143f25dc6137439794fdf075c6cc424
Author: Michael Pratt <mcpratt at pm.me>
AuthorDate: Thu May 25 02:31:52 2023 -0400

    prereq-build: fix inconsistent value of $PATH
    
    In the recipe SetupHostCommand for checking
    and creating symlinks, $PATH was only overridden
    for one of several commands.
    
    This causes the symlinks to be included
    in the paths to pick a program from
    when the check was repeated, because
    staging_dir/host/bin was included in $PATH,
    but only *sometimes*.
    
    When the check ran again, the command succeded
    with a $PATH including the symlink,
    (eval "$$$$$$$$cmd")
    while the path to the program was evaluated
    with a $PATH NOT including the symlink,
    (bin=...)
    causing the symlink to be relinked incorrectly,
    instead of passing as exactly the same.
    
    Coincidentally, this was only a problem
    if the symlink targeted the alternative
    program with a different name.
    
    By overriding the value of $PATH at the invocation of Make,
    it will apply to the entire environment of the checks.
    
    Signed-off-by: Michael Pratt <mcpratt at pm.me>
    (cherry picked from commit 665fe2f818300f0b84c8c458fc49ae58ff8853aa)
---
 include/prereq.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/prereq.mk b/include/prereq.mk
index 74c3914d06..45c84e984c 100644
--- a/include/prereq.mk
+++ b/include/prereq.mk
@@ -28,9 +28,9 @@ define Require
 
     prereq-$(1): $(if $(PREREQ_PREV),prereq-$(PREREQ_PREV)) FORCE
 		printf "Checking '$(1)'... "
-		if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
+		if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) PATH="$(ORIG_PATH)" >/dev/null 2>/dev/null; then \
 			echo 'ok.'; \
-		elif $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) >/dev/null 2>/dev/null; then \
+		elif $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) PATH="$(ORIG_PATH)" >/dev/null 2>/dev/null; then \
 			echo 'updated.'; \
 		else \
 			echo 'failed.'; \
@@ -104,8 +104,7 @@ define SetupHostCommand
 	           $(call QuoteHostCommand,$(9)) $(call QuoteHostCommand,$(10)) \
 	           $(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
 		if [ -n "$$$$$$$$cmd" ]; then \
-			bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
-				command -v "$$$$$$$${cmd%% *}")"; \
+			bin="$$$$$$$$(command -v "$$$$$$$${cmd%% *}")"; \
 			if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
 				case "$$$$$$$$(ls -dl -- $(STAGING_DIR_HOST)/bin/$(strip $(1)))" in \
 					*" -> $$$$$$$$bin"*) \




More information about the lede-commits mailing list