Skip to content

Instantly share code, notes, and snippets.

@cdollins
Created March 4, 2012 23:08
Show Gist options
  • Save cdollins/1975278 to your computer and use it in GitHub Desktop.
Save cdollins/1975278 to your computer and use it in GitHub Desktop.
setup for chroot
#!/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