Fedora chroot for Android device
#!/system/bin/sh | |
# Don't add a trailing slash, the script is fragile | |
ROOT=/mnt/sdcard | |
error() | |
{ | |
echo '*** ' $1 ' ***' | |
exit 1; | |
} | |
mountfs() | |
{ | |
if cut -f 2 -d " " /proc/mounts | grep -q $4 ; then return ; fi | |
mount $1 $2 $3 $4 || error "Failed to mount $3" | |
} | |
if [ ! -d $ROOT ] ; then error "Wrong mount point" ; fi | |
# Verify that we'll be able to mount /dev in the chroot | |
if ! grep -q devtmpfs /proc/filesystems ; then error "Your kernel doesn't have devtmpfs support" ; fi | |
# Mount everything | |
mountfs -t ext4 /dev/block/mmcblk1 $ROOT | |
mountfs -t proc none $ROOT/proc | |
mountfs -t sysfs none $ROOT/sys | |
mountfs -t devtmpfs none $ROOT/dev | |
if [ ! -d $ROOT/dev/pts ] ; then mkdir $ROOT/dev/pts; fi | |
mountfs -t devpts none $ROOT/dev/pts | |
mountfs -t tmpfs none $ROOT/run | |
# Last minute fixes | |
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/sbin:/usr/local/sbin:/usr/games" | |
export PS1="$USER@$HOSTNAME:${PWD:-?} # " | |
# Set up internet using Google's DNS servers | |
if [ ! -f $ROOT/etc/resolv.conf ] ; then | |
echo "nameserver 8.8.8.8" > $ROOT/etc/resolv.conf | |
echo "nameserver 8.8.4.4" >> $ROOT/etc/resolv.conf | |
fi | |
# And the chroot is ready | |
/system/xbin/chroot /mnt/sdcard/ /bin/bash || error "Failed to setup chroot" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment