[OpenWrt-Devel] [PATCH 6/6] build: cleanup possibly dangling Python 2 host symlink

Yousong Zhou yszhou4tech at gmail.com
Wed Jun 19 07:46:35 EDT 2019


On Tue, 18 Jun 2019 at 04:10, Petr Štetiar <ynezz at true.cz> wrote:
>
> When bumping buildroot to Python 3, we need to assure, that Python
> symlink in staging bin directory points to Python >= 3.5 as well.

I thought `ln -sf` in previous patch will update that symlink to
python3.  Isn't that the case?

>
> Signed-off-by: Petr Štetiar <ynezz at true.cz>
> ---
>  include/prereq-build.mk |  2 ++
>  include/prereq.mk       | 11 +++++++++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/include/prereq-build.mk b/include/prereq-build.mk
> index c52ca719087c..40df89575d9e 100644
> --- a/include/prereq-build.mk
> +++ b/include/prereq-build.mk
> @@ -141,6 +141,8 @@ $(eval $(call SetupHostCommand,wget,Please install GNU 'wget', \
>  $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
>         perl --version | grep "perl.*v5"))
>
> +$(eval $(call CleanupPython2))
> +
>  $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
>         python3.7 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
>         python3.6 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?', \
> diff --git a/include/prereq.mk b/include/prereq.mk
> index 0f0f2537448f..51a0a879e3dc 100644
> --- a/include/prereq.mk
> +++ b/include/prereq.mk
> @@ -66,6 +66,17 @@ define RequireHeader
>    $$(eval $$(call Require,$(1),$(2)))
>  endef
>
> +define CleanupPython2
> +  define Require/python2-cleanup
> +       [ -f "$(STAGING_DIR_HOST)/bin/python" ] && \
> +               $(STAGING_DIR_HOST)/bin/python -V 2>&1 | \
> +               grep -E 'Python 3\.[5-9]\.?' > /dev/null 2>&1 || \
> +               rm $(STAGING_DIR_HOST)/bin/python

Fresh clone and build when doing the rm command will report "no such
file or directory"?

Maybe this will do

if [ -f $(STAGING_DIR_HOST)/bin/python ] &&
$(STAGING_DIR_HOST)/bin/python -V 2>&1 | grep -q 'Python 3\.[5-9]';
then \
        rm $(STAGING_DIR_HOST)/bin/python; \
fi

Regards,
                yousong

> +  endef
> +
> +  $$(eval $$(call Require,python2-cleanup))
> +endef
> +
>  define QuoteHostCommand
>  '$(subst ','"'"',$(strip $(1)))'
>  endef
> --
> 1.9.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list