build: cleanup possibly dangling Python 3 host symlink
authorEtienne Champetier <champetier.etienne@gmail.com>
Fri, 8 Nov 2019 14:58:01 +0000 (06:58 -0800)
committerPetr Štetiar <ynezz@true.cz>
Sat, 9 Nov 2019 07:21:45 +0000 (08:21 +0100)
When switching from master branch to 19.07 or older, we need to ensure
that Python symlink in staging bin directory points to Python 2.

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.

This is a cherry-pick of 3b68fb57c938af3948ae4c2da61501183fbef649
with python3 instead of python2

Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
include/prereq-build.mk
include/prereq.mk

index 8d9140a2d2ca2c58d34636a830907bbb7a25a052..d626ab024fe52fc8b91942c6cc6a71b6caacb811 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 CleanupPython3))
+
 $(eval $(call SetupHostCommand,python,Please install Python 2.x, \
        python2.7 -V 2>&1 | grep 'Python 2.7', \
        python2 -V 2>&1 | grep 'Python 2', \
index 0f0f2537448f2f314a4b923d0f3fb3f4924f4397..60f1e47c3db61d9d271ddaa3e5766e1ec757320d 100644 (file)
@@ -66,6 +66,18 @@ define RequireHeader
   $$(eval $$(call Require,$(1),$(2)))
 endef
 
+define CleanupPython3
+  define Require/python3-cleanup
+       if [ -f "$(STAGING_DIR_HOST)/bin/python" ] && \
+               $(STAGING_DIR_HOST)/bin/python -V 2>&1 | \
+               grep -q 'Python 3'; then \
+                       rm $(STAGING_DIR_HOST)/bin/python; \
+       fi
+  endef
+
+  $$(eval $$(call Require,python3-cleanup))
+endef
+
 define QuoteHostCommand
 '$(subst ','"'"',$(strip $(1)))'
 endef