X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=scripts%2Fbundle-libraries.sh;h=621bf579e70234da6f148f68d5451d0e2eed74a1;hb=5fc28ef47959c1256f2553d507224bb481b08494;hp=d3c7206a4dddd2b44a5b7d506f88212de850e0b4;hpb=5ebcd32997b6d10abcd29c8795a598fdcaf4521d;p=openwrt%2Fopenwrt.git diff --git a/scripts/bundle-libraries.sh b/scripts/bundle-libraries.sh index d3c7206a4d..621bf579e7 100755 --- a/scripts/bundle-libraries.sh +++ b/scripts/bundle-libraries.sh @@ -125,6 +125,23 @@ _patch_glibc() { fi } +should_be_patched() { + local bin="$1" + + [ -x "$bin" ] || return 1 + + case "$bin" in + *.so|*.so.[0-9]*) + return 1 + ;; + *) + file "$bin" | grep -sqE "ELF.*(executable|interpreter)" && return 0 + ;; + esac + + return 1 +} + for LDD in ${PATH//://ldd }/ldd; do "$LDD" --version >/dev/null 2>/dev/null && break LDD="" @@ -150,7 +167,7 @@ for BIN in "$@"; do LDSO="" - [ -n "$LDD" ] && [ -x "$BIN" ] && file "$BIN" | grep -sqE "ELF.*(executable|interpreter)" && { + [ -n "$LDD" ] && should_be_patched "$BIN" && { for token in $("$LDD" "$BIN" 2>/dev/null); do case "$token" in */*.so*) dest="$DIR/lib/${token##*/}" @@ -186,7 +203,7 @@ for BIN in "$@"; do #!/usr/bin/env bash dir="\$(dirname "\$0")" export RUNAS_ARG0="\$0" - export LD_PRELOAD="\$dir/${REL:+$REL/}runas.so" + export LD_PRELOAD="\${LD_PRELOAD:+\$LD_PRELOAD:}\$dir/${REL:+$REL/}runas.so" exec "\$dir/${REL:+$REL/}$LDSO" --library-path "\$dir/${REL:+$REL/}" "\$dir/.${BIN##*/}.bin" "\$@" EOF