build: cleanup possibly dangling Python 2 host symlink
authorPetr Štetiar <ynezz@true.cz>
Wed, 20 Mar 2019 08:52:58 +0000 (09:52 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 26 Jul 2019 06:09:16 +0000 (08:09 +0200)
When bumping buildroot to Python 3, we need to assure, that Python
symlink in staging bin directory points to Python >= 3.5 as well.

We can't rely completly just on SetupHostCommand as its executed only in
cases when the $(STAGING_DIR_HOST)/bin/python doesn't already exist, so
we need to remove it before running SetupHostCommand.

Acked-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
include/prereq-build.mk
include/prereq.mk

index c52ca719087caed3a7281b4d98cc325997ad28db..40df89575d9e75128dfe05d95c464250f8d681b5 100644 (file)
@@ -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]\.?', \
index 0f0f2537448f2f314a4b923d0f3fb3f4924f4397..83ac21242c6535b9bdd03e70b2b91f10161231e5 100644 (file)
@@ -66,6 +66,18 @@ define RequireHeader
   $$(eval $$(call Require,$(1),$(2)))
 endef
 
+define CleanupPython2
+  define Require/python2-cleanup
+       if [ -f "$(STAGING_DIR_HOST)/bin/python" ] && \
+               $(STAGING_DIR_HOST)/bin/python -V 2>&1 | \
+               grep -q 'Python 2'; then \
+                       rm $(STAGING_DIR_HOST)/bin/python; \
+       fi
+  endef
+
+  $$(eval $$(call Require,python2-cleanup))
+endef
+
 define QuoteHostCommand
 '$(subst ','"'"',$(strip $(1)))'
 endef