Skip to content

Instantly share code, notes, and snippets.

@damienklinnert
Created June 20, 2012 14:33
Show Gist options
  • Save damienklinnert/2960179 to your computer and use it in GitHub Desktop.
Save damienklinnert/2960179 to your computer and use it in GitHub Desktop.
#!/bin/bash
# vars
SANDBOX_DIR=sandbox
if [[ `which ldd` ]]; then
DEPENDENCY_TOOL=ldd
else
DEPENDENCY_TOOL='otool -L'
fi
# build folder structure
mkdir $SANDBOX_DIR
# copy all binaries
cp -r /bin $SANDBOX_DIR
for eb_commands in `ls /bin`; do
# @todo: otool on maxosx, because ldd does not exist everywhere
eb_dependencies=`$DEPENDENCY_TOOL /bin/$eb_commands`
for eb_dependency in $eb_dependencies; do
# todo: this pattern is different on mac os x as well /not recursive, other form
if [[ `echo $eb_dependency | egrep -o '/[^:|\S]+$'` ]]; then
eb_dependency_dir=`dirname $eb_dependency`
mkdir -p $SANDBOX_DIR$eb_dependency_dir
cp $eb_dependency $SANDBOX_DIR$eb_dependency_dir
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment