diff options
Diffstat (limited to 'copy_so.sh')
-rwxr-xr-x | copy_so.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/copy_so.sh b/copy_so.sh new file mode 100755 index 0000000..3cac82d --- /dev/null +++ b/copy_so.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +[ -z "$LDD" ] && LDD=/usr/bin/ldd +[ -z "$GREP" ] && GREP=/bin/grep + +LDD_EXP='/(.*).so(|.[[:digit:]]+)*' +if [ $# -ne 2 ]; then + echo "usage: $0 [binary] [destdir]" >&2 + exit 1 +else + BIN="${1}" + DEST="${2}" +fi + +SO_FILES=$(${LDD} ${BIN} | ${GREP} -oE ${LDD_EXP}) + +[ -d ${DEST} ] || mkdir -p ${DEST} +for file in ${SO_FILES}; do + if [ ! -r ${file} ]; then + echo "$0: $file not readable." + continue + fi + libdir=$(dirname ${DEST}/${file}) + mkdir -p ${libdir} + cp ${file} ${libdir}/ +done + |