add scripts
authorSteven McDonald <steven@steven-mcdonald.id.au>
Sat, 26 Nov 2011 04:49:14 +0000 (15:49 +1100)
committerSteven McDonald <steven@steven-mcdonald.id.au>
Sat, 26 Nov 2011 04:49:14 +0000 (15:49 +1100)
README [new file with mode: 0644]
android/debian-init [new file with mode: 0755]
android/debian-sh [new file with mode: 0755]
debian/debian-init [new file with mode: 0755]
debian/debian-sh [new file with mode: 0755]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e9402a0
--- /dev/null
+++ b/README
@@ -0,0 +1,5 @@
+These scripts are intended to ease the process of bootstrapping a Debian
+chroot on an Android device. Instructions for installing such a chroot
+may be found at:
+
+http://www.steven-mcdonald.id.au/tutorials/debian_on_samsung_galaxy.shtml
diff --git a/android/debian-init b/android/debian-init
new file mode 100755 (executable)
index 0000000..7757597
--- /dev/null
@@ -0,0 +1,36 @@
+#!/system/bin/sh
+
+# is /debian already mounted? if so, skip mounts
+if ! awk '{print $2}' /proc/mounts | grep -q '^/debian$'
+then
+       # create /debian
+       mkdir -p /debian
+
+       # mount /debian
+       mount -t ext3 -o noatime,errors=remount-ro /mnt/sdcard/debian.img /debian
+
+       # bind-mount special file systems from outside
+       for fs in /dev /proc /sys
+       do
+               mount -o bind "$fs" "/debian$fs"
+       done
+
+       # bind-mount android file systems so we can use them from debian
+       # busybox find has no -empty option so we have to do it like this
+       find /debian/android -type d |
+       while read dir
+       do
+               if test -z "$(ls $dir)"
+               then
+                       echo "$dir"
+               fi
+       done |
+       sed 's,^/debian/android,,' |
+       while read fs
+       do
+               mount -o bind "$fs" "/debian/android$fs"
+       done
+fi
+
+# now start debian
+chroot /debian /usr/local/sbin/debian-init
diff --git a/android/debian-sh b/android/debian-sh
new file mode 100755 (executable)
index 0000000..7bea81f
--- /dev/null
@@ -0,0 +1,7 @@
+#!/system/bin/sh
+if whoami | grep -q '^root$'
+then
+       chroot /debian /usr/local/sbin/debian-sh
+else
+       su -c /data/local/bin/debian-sh
+fi
diff --git a/debian/debian-init b/debian/debian-init
new file mode 100755 (executable)
index 0000000..3f24d25
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# initialise debian system from outside the chroot
+# this script gets called from the android init system
+
+# first, set our PATH correctly
+# android uses a retarded PATH
+export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
+
+# what services do we want to start?
+services='
+hostname.sh
+rsyslog
+ssh
+atd
+cron
+rc.local
+'
+
+# start debian services
+for service in $services
+do
+       /usr/sbin/service "$service" start
+done
diff --git a/debian/debian-sh b/debian/debian-sh
new file mode 100755 (executable)
index 0000000..a853092
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# get rid of the retarded export PATH terminal emulator inflicts on us
+read foo
+unset foo
+
+export HOME='/root'
+export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
+export SHELL='/bin/bash'
+export TERM='xterm'
+
+clear
+cd
+/bin/bash