From 17da9886456369878560953ffb773292f6a2a00a Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 7 Mar 2017 14:50:19 +0200 Subject: python,python3: fix goof with multiline command break Signed-off-by: Alexandru Ardelean --- lang/python3/files/python3-package.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lang/python3/files/python3-package.mk') diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index f13e737ae..31a5d0684 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -44,8 +44,8 @@ define Py3Package ifndef Py3Package/$(1)/install define Py3Package/$(1)/install if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \ - $(INSTALL_DIR) $$(1)/usr/bin \ - $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ + $(INSTALL_DIR) $$(1)/usr/bin ; \ + $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \ fi endef endif -- cgit From 5d502e85303462ad9c8e437d910172884685e6b7 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 2 Mar 2017 15:10:23 +0200 Subject: python3: move filespec shell code into file Same as for python. Signed-off-by: Alexandru Ardelean --- lang/python3/Makefile | 1 + lang/python3/files/python3-package-install.sh | 38 ++++++++++++++++++++++++ lang/python3/files/python3-package.mk | 42 ++++++++------------------- 3 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 lang/python3/files/python3-package-install.sh (limited to 'lang/python3/files/python3-package.mk') diff --git a/lang/python3/Makefile b/lang/python3/Makefile index 67a594de6..1276ae546 100644 --- a/lang/python3/Makefile +++ b/lang/python3/Makefile @@ -187,6 +187,7 @@ define Build/InstallDev ./files/python3-package.mk \ ./files/python3-host.mk \ ./files/python3-version.mk \ + ./files/python3-package-install.sh \ $(STAGING_DIR)/mk/ $(CP) \ $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ diff --git a/lang/python3/files/python3-package-install.sh b/lang/python3/files/python3-package-install.sh new file mode 100644 index 000000000..c3de0cc95 --- /dev/null +++ b/lang/python3/files/python3-package-install.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +process_filespec() { + local src_dir="$1" + local dst_dir="$2" + local filespec="$3" + echo "$filespec" | ( + IFS='|' + while read fop fspec fperm; do + local fop=`echo "$fop" | tr -d ' \t\n'` + if [ "$fop" = "+" ]; then + if [ ! -e "${src_dir}${fspec}" ]; then + echo "File not found '${src_dir}${fspec}'" + exit 1 + fi + dpath=`dirname "$fspec"` + if [ -z "$fperm" ]; then + dperm=`stat -c "%a" ${src_dir}${dpath}` + fi + mkdir -p -m$dperm ${dst_dir}${dpath} + echo "copying: '$fspec'" + cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/ + if [ -n "$fperm" ]; then + chmod -R $fperm ${dst_dir}${fspec} + fi + elif [ "$fop" = "-" ]; then + echo "removing: '$fspec'" + rm -fR ${dst_dir}${fspec} + elif [ "$fop" = "=" ]; then + echo "setting permissions: '$fperm' on '$fspec'" + chmod -R $fperm ${dst_dir}${fspec} + fi + done + ) +} + +process_filespec "$1" "$2" "$3" + diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index 31a5d0684..7881c1f04 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -54,36 +54,18 @@ define Py3Package define Package/$(1)/install find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f - @echo "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" | ( \ - IFS='|'; \ - while read fop fspec fperm; do \ - fop=`echo "$$$$$$$$fop" | tr -d ' \t\n'`; \ - if [ "$$$$$$$$fop" = "+" ]; then \ - if [ ! -e "$(PKG_INSTALL_DIR)$$$$$$$$fspec" ]; then \ - echo "File not found '$(PKG_INSTALL_DIR)$$$$$$$$fspec'"; \ - exit 1; \ - fi; \ - dpath=`dirname "$$$$$$$$fspec"`; \ - if [ -n "$$$$$$$$fperm" ]; then \ - dperm="-m$$$$$$$$fperm"; \ - else \ - dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \ - fi; \ - mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \ - echo "copying: '$$$$$$$$fspec'"; \ - cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \ - if [ -n "$$$$$$$$fperm" ]; then \ - chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \ - fi; \ - elif [ "$$$$$$$$fop" = "-" ]; then \ - echo "removing: '$$$$$$$$fspec'"; \ - rm -fR $$(1)$$$$$$$$fspec; \ - elif [ "$$$$$$$$fop" = "=" ]; then \ - echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \ - chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \ - fi; \ - done; \ - ) + if [ -e files/python3-package-install.sh ] ; then \ + $(SHELL) files/python3-package-install.sh \ + "$(PKG_INSTALL_DIR)" "$$(1)" \ + "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \ + elif [ -e $(STAGING_DIR)/mk/python3-package-install.sh ] ; then \ + $(SHELL) $(STAGING_DIR)/mk/python3-package-install.sh \ + "$(PKG_INSTALL_DIR)" "$$(1)" \ + "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \ + else \ + echo "No 'python3-package-install.sh' script found" ; \ + exit 1 ; \ + fi $(call Py3Package/$(1)/install,$$(1)) endef endef -- cgit From df0d0bcc0016866fce67dd04d01e1fc350ddf152 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 2 Mar 2017 18:04:43 +0200 Subject: python,python3: move PyPackage install rules in the beggining of the Package install rules So that we can process Python sources installed by those rules, if we need to. Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 1 + lang/python/files/python-package.mk | 2 +- lang/python3/files/python3-package.mk | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lang/python3/files/python3-package.mk') diff --git a/lang/python/Makefile b/lang/python/Makefile index b6846f52d..4300eef71 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -259,6 +259,7 @@ $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_f endef define PyPackage/python-base/install + $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/ diff --git a/lang/python/files/python-package.mk b/lang/python/files/python-package.mk index 732dbf05d..dfc07a612 100644 --- a/lang/python/files/python-package.mk +++ b/lang/python/files/python-package.mk @@ -53,6 +53,7 @@ define PyPackage $(call shexport,PyPackage/$(1)/filespec) define Package/$(1)/install + $(call PyPackage/$(1)/install,$$(1)) find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f if [ -e files/python-package-install.sh ] ; then \ $(SHELL) files/python-package-install.sh \ @@ -66,7 +67,6 @@ define PyPackage echo "No 'python-package-install.sh' script found" ; \ exit 1 ; \ fi - $(call PyPackage/$(1)/install,$$(1)) endef endef diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index 7881c1f04..f1f3ff546 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -53,6 +53,7 @@ define Py3Package $(call shexport,Py3Package/$(1)/filespec) define Package/$(1)/install + $(call Py3Package/$(1)/install,$$(1)) find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f if [ -e files/python3-package-install.sh ] ; then \ $(SHELL) files/python3-package-install.sh \ @@ -66,7 +67,6 @@ define Py3Package echo "No 'python3-package-install.sh' script found" ; \ exit 1 ; \ fi - $(call Py3Package/$(1)/install,$$(1)) endef endef -- cgit From 05f8d6edf06c93dadab34f14a5fad48449dd7eda Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 2 Mar 2017 15:24:14 +0200 Subject: python,python3: drop remove .pyc & .pyo files We'll control in the install phase what we ship [byte-codes or source files] Signed-off-by: Alexandru Ardelean --- lang/python/files/python-package.mk | 4 ++-- lang/python3/files/python3-package.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lang/python3/files/python3-package.mk') diff --git a/lang/python/files/python-package.mk b/lang/python/files/python-package.mk index dfc07a612..4f05dfebb 100644 --- a/lang/python/files/python-package.mk +++ b/lang/python/files/python-package.mk @@ -54,7 +54,7 @@ define PyPackage define Package/$(1)/install $(call PyPackage/$(1)/install,$$(1)) - find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f + find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f if [ -e files/python-package-install.sh ] ; then \ $(SHELL) files/python-package-install.sh \ "$(PKG_INSTALL_DIR)" "$$(1)" \ @@ -103,7 +103,7 @@ define Build/Compile/PyMod cd $(PKG_BUILD_DIR)/$(strip $(1)), \ ./setup.py $(2), \ $(3)) - find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f + find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f endef define PyBuild/Compile/Default diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index f1f3ff546..1ed8b2c18 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -54,7 +54,7 @@ define Py3Package define Package/$(1)/install $(call Py3Package/$(1)/install,$$(1)) - find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f + find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f if [ -e files/python3-package-install.sh ] ; then \ $(SHELL) files/python3-package-install.sh \ "$(PKG_INSTALL_DIR)" "$$(1)" \ @@ -103,7 +103,7 @@ define Build/Compile/Py3Mod cd $(PKG_BUILD_DIR)/$(strip $(1)), \ ./setup.py $(2), \ $(3)) - find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f + find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f endef define Py3Build/Compile/Default -- cgit From ae350d938785bb72161dc21f94ea947ee3d9bf1b Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 2 Mar 2017 18:02:14 +0200 Subject: python3: split source packages away from compiled packages Same as for python. Signed-off-by: Alexandru Ardelean --- lang/python3/Makefile | 5 ++++ lang/python3/files/python3-package-install.sh | 33 ++++++++++++++++++++++++++- lang/python3/files/python3-package.mk | 17 ++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) (limited to 'lang/python3/files/python3-package.mk') diff --git a/lang/python3/Makefile b/lang/python3/Makefile index a0711a3f6..abf0a557f 100644 --- a/lang/python3/Makefile +++ b/lang/python3/Makefile @@ -289,6 +289,7 @@ $(eval $(call HostBuild)) $(foreach package, $(PYTHON3_PACKAGES), \ $(eval $(call Py3Package,$(package))) \ $(eval $(call BuildPackage,$(package))) \ + $(eval $(call BuildPackage,$(package)-src)) \ ) $(eval $(call Py3Package,python3-base)) @@ -298,3 +299,7 @@ $(eval $(call Py3Package,python3)) $(eval $(call BuildPackage,python3-base)) $(eval $(call BuildPackage,python3-light)) $(eval $(call BuildPackage,python3)) + +$(eval $(call BuildPackage,python3-base-src)) +$(eval $(call BuildPackage,python3-light-src)) +$(eval $(call BuildPackage,python3-src)) diff --git a/lang/python3/files/python3-package-install.sh b/lang/python3/files/python3-package-install.sh index c3de0cc95..cc1005189 100644 --- a/lang/python3/files/python3-package-install.sh +++ b/lang/python3/files/python3-package-install.sh @@ -34,5 +34,36 @@ process_filespec() { ) } -process_filespec "$1" "$2" "$3" +src_dir="$1" +dst_dir="$2" +python="$3" +mode="$4" +filespec="$5" +process_filespec "$src_dir" "$dst_dir" "$filespec" || { + echo "process filespec error-ed" + exit 1 +} + +if [ "$mode" == "sources" ] ; then + # Copy only python source files + find $dst_dir -not -name "*\.py" | xargs rm -f + # Delete empty folders (if the case) + find $dst_dir/usr -type d | xargs rmdir &> /dev/null + rmdir $dst_dir/usr &> /dev/null + exit 0 +fi + +# XXX [So that you won't goof as I did] +# Note: Yes, I tried to use the -O & -OO flags here. +# However the generated byte-codes were not portable. +# So, we just stuck to un-optimized byte-codes, +# which is still way better/faster than running +# Python sources all the time. +$python -m compileall -b -d '/' $dst_dir || { + echo "python -m compileall err-ed" + exit 1 +} +# Delete source files and pyc [ un-optimized bytecode files ] +# We may want to make this optimization thing configurable later, but not sure atm +find $dst_dir -name "*\.py" | xargs rm -f diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index 1ed8b2c18..a28689aba 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -34,6 +34,17 @@ endif define Py3Package + define Package/$(1)-src + $(call Package/$(1)) + TITLE+= (sources) + DEPENDS:=$$$$(foreach dep,$$$$(filter +python3-%,$$$$(DEPENDS)),$$$$(dep)-src) + endef + + define Package/$(1)-src/description + $(call Package/$(1)/description). + (Contains the Python3 sources for this package). + endef + # Add default PyPackage filespec none defined ifndef Py3Package/$(1)/filespec define Py3Package/$(1)/filespec @@ -58,16 +69,22 @@ define Py3Package if [ -e files/python3-package-install.sh ] ; then \ $(SHELL) files/python3-package-install.sh \ "$(PKG_INSTALL_DIR)" "$$(1)" \ + "$(HOST_PYTHON3_BIN)" "$$(2)" \ "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \ elif [ -e $(STAGING_DIR)/mk/python3-package-install.sh ] ; then \ $(SHELL) $(STAGING_DIR)/mk/python3-package-install.sh \ "$(PKG_INSTALL_DIR)" "$$(1)" \ + "$(HOST_PYTHON3_BIN)" "$$(2)" \ "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \ else \ echo "No 'python3-package-install.sh' script found" ; \ exit 1 ; \ fi endef + + define Package/$(1)-src/install + $$(call Package/$(1)/install,$$(1),sources) + endef endef $(call include_mk, python3-host.mk) -- cgit