python,python3: move shebang handle in install script
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Mon, 4 Feb 2019 14:36:25 +0000 (16:36 +0200)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Tue, 12 Feb 2019 10:31:55 +0000 (12:31 +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/files/python-package-pip.mk
lang/python/python/files/python-package-setuptools.mk
lang/python/python3/files/python3-package-pip.mk
lang/python/python3/files/python3-package-setuptools.mk

index 30373751cec3d9b9c23d1bd18c829d76cf65c0ea..a1b21e49f47c24efaf3443e373e9ed0f011bdf95 100644 (file)
@@ -65,6 +65,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" -exec rm -f {} \;
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 8e209e139b37cb7208f28f7e90540a73748c041b..fd1cd59d54767c851eab382edd3d15c36a881ad1 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 472f5a620cfd60b0e4d0d703b8d8f737ae0b2993..5cb5f58de0e4ffc30526d5ac23ed04a4cf62a2fc 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) \