From 721642908c2bc2f16ff371bdd33e4df02813318c Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 12 Sep 2019 15:03:50 +0300 Subject: python,python3: add Py[3]Shebang functions & move outside of script Some packages just install some Python binaries, that may need their shebang fixed. This change adds some utilities to help with that and try to centralize the sed rules a bit. It also removes the logic from the `python-package-install.sh` into the `python-package[3].mk` files. This does 2 things: 1. It minimizes the need for the shell script to know the Python version 2/3 2. Makes the logic re-usable in packages; especially if the install rules differ a bit Signed-off-by: Alexandru Ardelean --- lang/python/python3-package.mk | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lang/python/python3-package.mk') diff --git a/lang/python/python3-package.mk b/lang/python/python3-package.mk index e14290081..d20d19801 100644 --- a/lang/python/python3-package.mk +++ b/lang/python/python3-package.mk @@ -34,6 +34,10 @@ ifdef CONFIG_USE_MIPS16 TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16 endif +define Py3Shebang +$(SED) "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python3," -i --follow-symlinks $(1) +endef + define Py3Package define Package/$(1)-src @@ -73,12 +77,14 @@ define Py3Package define Package/$(1)/install $$(call Py3Package/$(1)/install,$$(1)) - SED="$(SED)" \ $(SHELL) $(python3_mk_path)python-package-install.sh "3" \ "$(PKG_INSTALL_DIR)" "$$(1)" \ "$(HOST_PYTHON3_BIN)" "$$(2)" \ - "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" - endef + "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" && \ + if [ -d "$$(1)/usr/bin" ]; then \ + $(call Py3Shebang,$$(1)/usr/bin/*) ; \ + fi + endef define Package/$(1)-src/install $$(call Package/$(1)/install,$$(1),sources) -- cgit