X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=scripts%2Fbundle-libraries.sh;h=508fe787f2e2c9e95a15d4e14b840222a6ffdd5b;hb=646e9d8d5ef5ebee6911414db6b28d7833b14e89;hp=34cd08e78790f70b70ad84a8e64f962fd147d8ac;hpb=f175e728fb8f4868cddbcbd2363690fd8d11e232;p=openwrt.git diff --git a/scripts/bundle-libraries.sh b/scripts/bundle-libraries.sh index 34cd08e787..508fe787f2 100755 --- a/scripts/bundle-libraries.sh +++ b/scripts/bundle-libraries.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash # # Script to install host system binaries along with required libraries. -# Refer to the --help output for more information. # -# Copyright (C) 2012 Jo-Philipp Wich +# Copyright (C) 2012-2013 Jo-Philipp Wich # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,10 +46,7 @@ for LDD in ${PATH//://ldd }/ldd; do LDD="" done -[ -n "$LDD" -a -x "$LDD" ] || { - echo "Unable to find working ldd" >&2 - exit 4 -} +[ -n "$LDD" -a -x "$LDD" ] || LDD= for BIN in "$@"; do [ -n "$BIN" -a -x "$BIN" -a -n "$DIR" ] || { @@ -67,26 +63,24 @@ for BIN in "$@"; do LDSO="" echo "Bundling ${BIN##*/}" - for token in $("$LDD" "$BIN" 2>/dev/null); do - case "$token" in */*.so*) - case "$token" in - *ld-*.so*) LDSO="${token##*/}" ;; - *) echo " * lib: ${token##*/}" ;; - esac - - dest="$DIR/bundled/lib/${token#*/lib*/}" - ddir="${dest%/*}" - - [ -f "$token" -a ! -f "$dest" ] && { - _md "$ddir" - _cp "$token" "$dest" - - case "$token" in */tls/*.so*) - _cp "${token%/tls/*}/${token##*/}" "$DIR/bundled/lib/${token##*/}" - ;; esac - } - ;; esac - done + [ -n "$LDD" ] && { + for token in $("$LDD" "$BIN" 2>/dev/null); do + case "$token" in */*.so*) + case "$token" in + *ld-*.so*) LDSO="${token##*/}" ;; + *) echo " * lib: ${token##*/}" ;; + esac + + dest="$DIR/bundled/lib/${token##*/}" + ddir="${dest%/*}" + + [ -f "$token" -a ! -f "$dest" ] && { + _md "$ddir" + _cp "$token" "$dest" + } + ;; esac + done + } _md "$DIR" @@ -94,21 +88,23 @@ for BIN in "$@"; do if [ -n "$LDSO" ]; then _cp "$BIN" "$DIR/bundled/${BIN##*/}" - [ -x "$DIR/bundled/run.sh" ] || { - cat <<-EOF > "$DIR/bundled/run.sh" + RUN="${LDSO#ld-}"; RUN="run-${RUN%%.so*}.sh" + + [ -x "$DIR/bundled/$RUN" ] || { + cat <<-EOF > "$DIR/bundled/$RUN" #!/usr/bin/env bash dir="\$(dirname "\$0")" bin="\$(basename "\$0")" exec -a "\$0" "\$dir/bundled/lib/$LDSO" --library-path "\$dir/bundled/lib" "\$dir/bundled/\$bin" "\$@" EOF - chmod ${VERBOSE:+-v} 0755 "$DIR/bundled/run.sh" + chmod ${VERBOSE:+-v} 0755 "$DIR/bundled/$RUN" } - _ln "./bundled/run.sh" "$DIR/${BIN##*/}" + _ln "./bundled/$RUN" "$DIR/${BIN##*/}" # is a static executable or non-elf binary else - echo " * not dynamically linked" + [ -n "$LDD" ] && echo " * not dynamically linked" _cp "$BIN" "$DIR/${BIN##*/}" fi done