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

Petr Štetiar ynezz at true.cz
Mon Jun 17 16:08:56 EDT 2019


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 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
+  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


More information about the openwrt-devel mailing list