| 1 |
#!/bin/bash |
| 2 |
# Copyright (C) 2000-2020 Kern Sibbald |
| 3 |
# License: BSD 2-Clause; see file LICENSE-FOSS |
| 4 |
# |
| 5 |
# copy the libraries needed for a binary into the |
| 6 |
# local directory |
| 7 |
|
| 8 |
mkdir -p $PWD/libs/usr/lib64 |
| 9 |
|
| 10 |
function copylib |
| 11 |
{ |
| 12 |
file=$1 |
| 13 |
PWD=`pwd` |
| 14 |
F=`dirname $file` |
| 15 |
mkdir -p $PWD/libs/$F |
| 16 |
cp -v $file $PWD/libs/$F |
| 17 |
} |
| 18 |
|
| 19 |
ldd $1 | awk '/=>/ { print $3 }' | while read file |
| 20 |
do |
| 21 |
copylib $file |
| 22 |
done |
| 23 |
|
| 24 |
# We need to copy some common libraries used by libc |
| 25 |
file=`ldd $1 | awk '/ld-linux/ { print $1 }'` |
| 26 |
copylib $file |
| 27 |
|
| 28 |
file=`ldconfig -p | grep -v lib32 | awk '/libresolv\.so\./ { gsub(/.+=> /, ""); print $1 }'` |
| 29 |
copylib $file |
| 30 |
|
| 31 |
file=`ldconfig -p | grep -v lib32 | awk '/libnss_dns\.so\./ { gsub(/.+=> /, ""); print $1 }'` |
| 32 |
copylib $file |
| 33 |
|