This intends to serve as a guard against future use of the following
that may lead to multiple copies of the same binary be packaged and
installed to the target system

        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libyy.so.* $(1)

Signed-off-by: Yousong Zhou <yszhou4t...@gmail.com>
---
If this got accepted, pull requests like openwrt/packages#9233 will no
longer be necessary

 include/shell.sh | 29 +++++++++++++++++++++++++++++
 rules.mk         |  8 ++++----
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/include/shell.sh b/include/shell.sh
index 6ee0cf6030..fe72056099 100644
--- a/include/shell.sh
+++ b/include/shell.sh
@@ -13,3 +13,32 @@ isset() {
        eval "var=\"\${$1}\""
        [ -n "$var" ]
 }
+
+install() {
+       local arg
+       local dest
+       local args=()
+       local symlinks=()
+       local n=0
+
+       for arg in "$@"; do
+               if [ "${arg#-}" = "$arg" ]; then
+                       dest="$arg"
+                       if [ -h "$arg" ]; then
+                               symlinks+=("$arg")
+                       else
+                               args+=("$arg")
+                               n=$((n+1))
+                       fi
+               else
+                       args+=("$arg")
+               fi
+       done
+
+       if [ "$n" -ge 2 ]; then
+               command install "${args[@]}" || return 1
+       fi
+       if [ "${#symlinks[@]}" -ge 1 ]; then
+               cp --force --preserve --no-dereference "${symlinks[@]}" "$dest" 
|| return 1
+       fi
+}
diff --git a/rules.mk b/rules.mk
index 80cb3d63f4..2b7f9ec873 100644
--- a/rules.mk
+++ b/rules.mk
@@ -278,11 +278,11 @@ FIND:=find
 PATCH:=patch
 PYTHON:=python
 
-INSTALL_BIN:=install -m0755
-INSTALL_SUID:=install -m4755
 INSTALL_DIR:=install -d -m0755
-INSTALL_DATA:=install -m0644
-INSTALL_CONF:=install -m0600
+INSTALL_BIN:=$(SH_FUNC) install -m0755
+INSTALL_SUID:=$(SH_FUNC) install -m4755
+INSTALL_DATA:=$(SH_FUNC) install -m0644
+INSTALL_CONF:=$(SH_FUNC) install -m0600
 
 TARGET_CC_NOCACHE:=$(TARGET_CC)
 TARGET_CXX_NOCACHE:=$(TARGET_CXX)

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to