From e6ad5d9a10bb3e15231d8ae0582cd10bda1b13be Mon Sep 17 00:00:00 2001 From: Etienne Champetier Date: Fri, 8 Nov 2019 06:58:01 -0800 Subject: [PATCH] build: cleanup possibly dangling Python 3 host symlink MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Etienne Champetier --- include/prereq-build.mk | 2 ++ include/prereq.mk | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 15ba1eb93a..03f6d31d9c 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 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', \ diff --git a/include/prereq.mk b/include/prereq.mk index 0f0f253744..60f1e47c3d 100644 --- a/include/prereq.mk +++ b/include/prereq.mk @@ -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 -- 2.25.1