diff mbox

[OpenWrt-Devel] prereq: fixes checks that prefix env vars (ex:git)

Message ID 1457211294-26740-1-git-send-email-luizluca@gmail.com
State Superseded
Headers show

Commit Message

Luiz Angelo Daros de Luca March 5, 2016, 8:54 p.m. UTC
If a prereq-build command check defines a command env var (ex: MANPAGER=cat git ...)
prereq SetupHostCommand breaks. This is because it looks for the binary using which on
the first space-separated item (which might be the env var definition)

This patch replaces bash substitution by a sed regex that removes both env parameters and
command args.
---
 include/prereq.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Luiz Angelo Daros de Luca March 5, 2016, 8:56 p.m. UTC | #1
BTW, buildbots are failing because of the change in git check prereq
http://buildbot.openwrt.org:8010/builders/ath25/builds/168/steps/compile_1/logs/stdio


Em sáb, 5 de mar de 2016 às 17:55, Luiz Angelo Daros de Luca <
luizluca@gmail.com> escreveu:

> If a prereq-build command check defines a command env var (ex:
> MANPAGER=cat git ...)
> prereq SetupHostCommand breaks. This is because it looks for the binary
> using which on
> the first space-separated item (which might be the env var definition)
>
> This patch replaces bash substitution by a sed regex that removes both env
> parameters and
> command args.
> ---
>  include/prereq.mk | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/prereq.mk b/include/prereq.mk
> index 6cb590e..839b663 100644
> --- a/include/prereq.mk
> +++ b/include/prereq.mk
> @@ -92,8 +92,11 @@ define SetupHostCommand
>                    $(call QuoteHostCommand,$(7)) $(call
> QuoteHostCommand,$(8)) \
>                            $(call QuoteHostCommand,$(9)); do \
>                 if [ -n "$$$$$$$$cmd" ]; then \
> +
>  regex_rm_vars='s/^(\w+=(\['\'\"]']|'\''[^'\'']*'\''|"[^"]*"|[^ ]*(\\ )?)*
> )*//'; \
> +                       regex_rm_args='s/[[:space:]].*//'; \
> +
>  regex_clean_cmd="$$$$$$$$regex_rm_vars;$$$$$$$$regex_rm_args"; \
>                         bin="$$$$$$$$(PATH="$(subst
> $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst
> :,$(space),$(PATH))))" \
> -                               which "$$$$$$$${cmd%% *}")"; \
> +                               which "$$$$$$$$(echo $$$$$$$$cmd | sed -re
> "$$$$$$$$regex_clean_cmd")")"; \
>                         if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd"
> >/dev/null 2>/dev/null; then \
>                                 mkdir -p "$(STAGING_DIR_HOST)/bin"; \
>                                 ln -sf "$$$$$$$$bin"
> "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
> --
> 2.5.0
>
> --

Luiz Angelo Daros de Luca
luizluca@gmail.com
Felix Fietkau March 5, 2016, 9:09 p.m. UTC | #2
On 2016-03-05 21:56, Luiz Angelo Daros de Luca wrote:
> BTW, buildbots are failing because of the change in git check prereq
> http://buildbot.openwrt.org:8010/builders/ath25/builds/168/steps/compile_1/logs/stdio
Fixed in r48934

- Felix
diff mbox

Patch

diff --git a/include/prereq.mk b/include/prereq.mk
index 6cb590e..839b663 100644
--- a/include/prereq.mk
+++ b/include/prereq.mk
@@ -92,8 +92,11 @@  define SetupHostCommand
 	           $(call QuoteHostCommand,$(7)) $(call QuoteHostCommand,$(8)) \
 			   $(call QuoteHostCommand,$(9)); do \
 		if [ -n "$$$$$$$$cmd" ]; then \
+			regex_rm_vars='s/^(\w+=(\['\'\"]']|'\''[^'\'']*'\''|"[^"]*"|[^ ]*(\\ )?)* )*//'; \
+			regex_rm_args='s/[[:space:]].*//'; \
+			regex_clean_cmd="$$$$$$$$regex_rm_vars;$$$$$$$$regex_rm_args"; \
 			bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
-				which "$$$$$$$${cmd%% *}")"; \
+				which "$$$$$$$$(echo $$$$$$$$cmd | sed -re "$$$$$$$$regex_clean_cmd")")"; \
 			if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
 				mkdir -p "$(STAGING_DIR_HOST)/bin"; \
 				ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \