Created
March 4, 2012 23:08
-
-
Save cdollins/1975278 to your computer and use it in GitHub Desktop.
setup for chroot
This file contains 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
#!/usr/bin/env bash | |
chroot=$1 | |
command=`which $2` | |
ldd $command | while read line; do | |
if [[ `echo $line | awk '{print $3}'` =~ ^/ ]] ; then | |
sso=`echo $line | awk '{print $3}'` | |
lib_path=`dirname $sso` | |
name=`basename $sso` | |
mkdir -p $chroot$lib_path | |
cp $lib_path/$name $chroot$lib_path/ | |
if [ -h $lib_path/$name ] ; then | |
lib_name=`readlink $lib_path/$name` | |
cd $chroot$lib_path; ln -s $name $lib_name | |
fi | |
elif [[ `echo $line | awk '{print $1}'` =~ ^/ ]] ; then | |
sso=`echo $line | awk '{print $1}'` | |
mkdir -p $chroot/`dirname $sso` | |
cp $sso $chroot$sso | |
fi | |
done | |
mkdir -p $chroot`dirname $command` | |
cp $command $chroot$command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment