chiark / gitweb /
Stuff
authorJonathan Amery <jdamery+zgit@ysolde.ucam.org>
Thu, 11 Jun 2015 14:17:20 +0000 (15:17 +0100)
committerJonathan Amery <jdamery+zgit@ysolde.ucam.org>
Thu, 11 Jun 2015 14:19:45 +0000 (15:19 +0100)
debinit.sh

index aabda5936ac39ab4f28f22c394ec493cc3436e04..142d35cb9cd154a168f1719e73e0bd7d04cdad42 100644 (file)
@@ -1,6 +1,7 @@
 #!/sbin/busybox sh
 
 # initramfs pre-boot init script
+# Initial version copied from http://whiteboard.ping.se/Android/Debian
 
 # Mount the /proc and /sys filesystems
 /sbin/busybox mount -t proc none /proc
 # Populate /dev
 /sbin/busybox mdev -s
 
-# Mount the root filesystem, second partition on micro SDcard
-/sbin/busybox mount -t ext4 -o noatime,nodiratime,errors=panic /dev/mmcblk1p2 /mnt/root
+# Mount the Debian root filesystem, third partition on micro SDcard
+# We don't care if this fails, we'll handle that later
+/sbin/busybox mount -t ext4 -o noatime,nodiratime,errors=panic /dev/mmcblk1p3 /debian/
+
+# This directory exists in both the initramfs and the Debian fs
+/sbin/busybox mount -t ramfs ramfs /debian/android
+
+# Copy from the initramfs into the new android root
+cd /debian/android
+/sbin/busybox gunzip -c < /initrd.img | /sbin/busybox cpio -i
+
+exec >>/debian/android/log/boot-wrapper.log 2>&1
+
+/sbin/busybox echo "`/sbin/busybox date` Booting"
+
+/sbin/busybox [ -x /debian/etc/stage2init.sh ] && /sbin/busybox chroot /debian/ /debian/etc/stage2init.sh
+
+/sbin/busybox echo "`/sbin/busybox date` Cleaning up boot mounts"
 
 # Clean up
 /sbin/busybox umount /proc
 /sbin/busybox umount /sys
 /sbin/busybox umount /dev
 
-# Transfer root to SDcard
-exec /sbin/busybox switch_root /mnt/root /etc/init
+/sbin/busybox echo "`/sbin/busybox date` Starting Android's init"
+
+# Chroot into /debian/android/ and start Android's init
+exec /sbin/busybox chroot /debian/android/ /init "$*"