python,python3: move shebang handle in install script
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Mon, 4 Feb 2019 14:36:25 +0000 (16:36 +0200)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Thu, 8 Aug 2019 11:38:36 +0000 (13:38 +0200)
This extends the Python[3] shebang fixup to all packages.
Only Python scripts in `/usr/bin` will be handled at the moment. Later it
may make sense to also cover executables in `/bin`, though typically Python
executables shouldn't be placed there.

Previously the shebang handling was only done for python[3]-pip &
python[3]-setuptools.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
lang/python/python-package-install.sh
lang/python/python/Makefile
lang/python/python/files/python-package-pip.mk
lang/python/python/files/python-package-setuptools.mk
lang/python/python3/Makefile
lang/python/python3/files/python3-package-pip.mk
lang/python/python3/files/python3-package-setuptools.mk

index e5f6ec89389f23cb38993e4cec3182b98ac5380e..f21c00c811612360b74e1119588846ccffafd882 100644 (file)
@@ -52,6 +52,12 @@ process_filespec "$src_dir" "$dst_dir" "$filespec" || {
        exit 1
 }
 
+usr_bin_dir="$dst_dir/usr/bin"
+
+if [ -d "$usr_bin_dir" ] ; then
+       sed "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python${ver}," -i $usr_bin_dir/*
+fi
+
 if [ "$mode" == "sources" ] ; then
        # Copy only python source files
        find $dst_dir -not -type d -not -name "*\.py" | xargs rm -f
index b590e2f12adb1cb339c31ec90e005f89e97ef992..6e44f51449abeab5c765cfa94088d3c0b2dc8876 100644 (file)
@@ -12,7 +12,7 @@ include ../python-version.mk
 
 PKG_NAME:=python
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
index b082564646b45c8cd8ef241ced1cdcc830ccdc94..e0c6de97875417480bda7e353566ed88b66ebe80 100644 (file)
@@ -14,8 +14,6 @@ endef
 
 define PyPackage/python-pip/install
        $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
-       # Adjust shebang to proper python location on target
-       sed "1s@.*@#\!/usr/bin/python$(PYTHON_VERSION)@" -i $(PKG_BUILD_DIR)/install-pip/bin/*
        $(CP) $(PKG_BUILD_DIR)/install-pip/bin/* $(1)/usr/bin
        $(CP) \
                $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON_VERSION)/site-packages/pip \
index 413ec7979a0c59a847a519301327c9b226b297e8..f90b018648be35a13fb02dabb7ec9d9ca1628c1a 100644 (file)
@@ -14,8 +14,6 @@ endef
 
 define PyPackage/python-setuptools/install
        $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
-       # Adjust shebang to proper python location on target
-       sed "1s@.*@#\!/usr/bin/python$(PYTHON_VERSION)@" -i $(PKG_BUILD_DIR)/install-setuptools/bin/*
        $(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/* $(1)/usr/bin
        $(CP) \
                $(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \
index 9fbb6923e53a9d4f70c218066ef0e7b19d77745d..25ea949f8c6fa1a4f746874f0ddd7b43554c732e 100644 (file)
@@ -14,7 +14,7 @@ PYTHON_VERSION:=$(PYTHON3_VERSION)
 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
 
 PKG_NAME:=python3
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
index 1aaeaf2ee0c75fd532a2f095e2e82cefda0ca18e..0f8476c18c923a02bef276f13ddaa05e01f5497e 100644 (file)
@@ -14,8 +14,6 @@ endef
 
 define Package/python3-pip/install
        $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
-       # Adjust shebang to proper python location on target
-       sed "1s@.*@#\!/usr/bin/python$(PYTHON3_VERSION)@" -i $(PKG_BUILD_DIR)/install-pip/bin/*
        $(CP) $(PKG_BUILD_DIR)/install-pip/bin/pip3* $(1)/usr/bin
        $(CP) \
                $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON3_VERSION)/site-packages/pip \
index c8415cbd9306c91691b4bc48c349867f4d3e268f..fa3c2a22b5e2da128944428abaae74e0ea310c74 100644 (file)
@@ -14,8 +14,6 @@ endef
 
 define Py3Package/python3-setuptools/install
        $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
-       # Adjust shebang to proper python location on target
-       sed "1s@.*@#\!/usr/bin/python$(PYTHON3_VERSION)@" -i $(PKG_BUILD_DIR)/install-setuptools/bin/*
        $(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/easy_install-* $(1)/usr/bin
        $(LN) easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/easy_install-3
        $(CP) \