diff mbox series

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

Message ID 1560802136-4157-7-git-send-email-ynezz@true.cz
State Changes Requested
Delegated to: Petr Štetiar
Headers show
Series build: switch to Python 3 | expand

Commit Message

Petr Štetiar June 17, 2019, 8:08 p.m. UTC
When bumping buildroot to Python 3, we need to assure, that Python
symlink in staging bin directory points to Python >= 3.5 as well.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 include/prereq-build.mk |  2 ++
 include/prereq.mk       | 11 +++++++++++
 2 files changed, 13 insertions(+)

Comments

Yousong Zhou June 19, 2019, 11:46 a.m. UTC | #1
On Tue, 18 Jun 2019 at 04:10, Petr Štetiar <ynezz@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@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@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

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
+  endef
+
+  $$(eval $$(call Require,python2-cleanup))
+endef
+
 define QuoteHostCommand
 '$(subst ','"'"',$(strip $(1)))'
 endef