Last active
March 30, 2018 08:39
-
-
Save abn/1191cd971ef5a55b6d9e2c209a1c390a to your computer and use it in GitHub Desktop.
Helper script to find and copy shared library files given a binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DEST=${DEST-rootfs} | |
function loadfiles() { | |
for FILE in $1 | |
do | |
echo "Loading ${FILE}" | |
mkdir -p ${DEST}$(dirname ${FILE}) | |
cp ${FILE} ${DEST}${FILE} | |
done | |
} | |
function loadbins() { | |
for BINFILE in $@; do | |
loadfiles ${BINFILE} | |
loadfiles "$(ldd ${BINFILE} | awk '{print $1}' | grep -e ^/)" | |
loadfiles "$(ldd ${BINFILE} | awk '{print $3}' | grep -e ^/lib)" | |
done | |
} | |
loadbins $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment