copy_bin_with_libs.sh 1.02 KB
Newer Older
1 2 3 4 5 6 7
#!/bin/sh
# Nico Schottelius
# Fri May  1 17:31:50 CEST 2015


PATH=/bin:/sbin:/usr/bin:/usr/sbin

8 9 10 11 12 13 14 15
if [ "$#" -ne 1 ]; then
    echo "$0 dir-out"
    exit 1
fi


out_dir=$1

Nico Schottelius's avatar
Nico Schottelius committed
16 17
#bin_list="udevadm bash fdisk mount syslinux umount rm mv"
bin_list="udevadm fdisk"
18

Nico Schottelius's avatar
Nico Schottelius committed
19 20
libs=$(mktemp /tmp/cdist-preos-libs.XXXXXXXXXXXXX)

21
mkdir -p "$out_dir/bin" "$out_dir/lib"
22

23 24 25 26 27 28 29 30
(   
    for bin in $bin_list; do
        src=$(which "$bin")
        cp "$src" "$out_dir/bin"
    
        ldd "$src" | sed -e 's/=>//' -e 's/(.*//' | awk '{ if(NF == 2) { print $2 } else { print $1 } }'
    done
) | sort | uniq > "$libs"
31

32

33 34 35 36 37 38 39 40 41
while read lib; do
    if echo $lib | grep '^/'; then
        # echo "Copying fqdn lib $lib ..."
        cp "$lib" "$out_dir/lib"
    else
        echo "How to copy $lib ?"
    fi
done < "$libs"

Nico Schottelius's avatar
Nico Schottelius committed
42

43
rm -f "$libs"
44 45 46 47 48 49

exit 0


bin=$1

50 51 52
# Not used alternatives
# new_list=$(objdump -p /usr/bin/ls | awk '$1 ~ /NEEDED/ { print $2 }')
# ldconfig -p | grep 'libBrokenLocale.so.1$' | sed 's/.* => //'
53 54 55 56 57 58 59 60


for new_item in $new_list; do
    

done

ldconfig -p |