Skip to content

Instantly share code, notes, and snippets.

@float-tw
Created August 13, 2012 11:05
Show Gist options
  • Save float-tw/3339552 to your computer and use it in GitHub Desktop.
Save float-tw/3339552 to your computer and use it in GitHub Desktop.
chroot setup
#! /bin/sh
chroot_bin="/tmp/chroot/bin/"
chroot_lib="/tmp/chroot/lib/"
cmd_list="/bin/bash \
/bin/ls \
/bin/cp \
/bin/mkdir \
/bin/mv \
/bin/rm \
/bin/rmdir"
for i in $cmd_list
do
if test -e $chroot_bin/`basename $i`
then
echo "command exists $i"
else
echo "copy command $i"
#cp $i $chroot_bin
new_list=`ldd $i | awk '{ print $1 }' | grep "/lib"`
lib_list=$lib_list`echo "\n$new_list"`
new_list=`ldd $i | awk '{ print $3 }' | grep "/lib"`
lib_list=$lib_list`echo "\n$new_list"`
fi
done
lib_list=`echo "$lib_list" | sort | uniq`
echo "$lib_list"
for i in $lib_list
do
if test -e $chroot_lib/`basename $i`
then
echo "lib exists $i"
else
echo "copy lib $i"
#cp $i $chroot_lib
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment