Skip to content

Instantly share code, notes, and snippets.

@abn
Last active March 30, 2018 08:39
Show Gist options
  • Save abn/1191cd971ef5a55b6d9e2c209a1c390a to your computer and use it in GitHub Desktop.
Save abn/1191cd971ef5a55b6d9e2c209a1c390a to your computer and use it in GitHub Desktop.
Helper script to find and copy shared library files given a binary.
#!/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