python,python3: Fix overridden usr/bin symlinks 9513/head
authorJeffery To <jeffery.to@gmail.com>
Sun, 31 Mar 2019 11:11:15 +0000 (19:11 +0800)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Thu, 8 Aug 2019 11:38:37 +0000 (13:38 +0200)
Currently, all files in usr/bin (presumably all Python scripts) are run
through sed to replace the shebang; sed will overwrite the file whether
or not a match is found. This causes symlinks to be overridden and made
into copies of their targets. python[3]-base and python[3]-dev are
affected by this.

This adds the --follow-symlinks flag to sed, in addition to using
$(SED), so that symlinks are not overridden.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python-package-install.sh
lang/python/python-package.mk
lang/python/python3-package.mk

index f21c00c811612360b74e1119588846ccffafd882..34ba0721bba8c6f613d0ff35116a2d53f5a06891 100644 (file)
@@ -47,6 +47,8 @@ python="$4"
 mode="$5"
 filespec="$6"
 
+SED="${SED:-sed -e}"
+
 process_filespec "$src_dir" "$dst_dir" "$filespec" || {
        echo "process filespec error-ed"
        exit 1
@@ -55,7 +57,7 @@ process_filespec "$src_dir" "$dst_dir" "$filespec" || {
 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/*
+       $SED "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python${ver}," -i --follow-symlinks $usr_bin_dir/*
 fi
 
 if [ "$mode" == "sources" ] ; then
index 66a49298370efe3b4825528dbb34b41b08c9df6e..855dd4449caf4ccc098d271fddc530179ddc3290 100644 (file)
@@ -70,6 +70,7 @@ define PyPackage
   define Package/$(1)/install
        $(call PyPackage/$(1)/install,$$(1))
        find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+       SED="$(SED)" \
        $(SHELL) $(python_mk_path)python-package-install.sh "2" \
                "$(PKG_INSTALL_DIR)" "$$(1)" \
                "$(HOST_PYTHON_BIN)" "$$(2)" \
index 9e473b5c5d2e8fcfcbd24dd219f1c1178bada2bc..5a779c21754c57a3b5276b73c399e45a7762979f 100644 (file)
@@ -69,6 +69,7 @@ define Py3Package
   define Package/$(1)/install
        $(call Py3Package/$(1)/install,$$(1))
        find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+       SED="$(SED)" \
        $(SHELL) $(python3_mk_path)python-package-install.sh "3" \
                "$(PKG_INSTALL_DIR)" "$$(1)" \
                "$(HOST_PYTHON3_BIN)" "$$(2)" \