OSDN Git Service

init: fix localtime_r not work in /init
[android-x86/bootable-newinstaller.git] / initrd / init
index 7b0140f..6c7adc8 100755 (executable)
@@ -3,7 +3,7 @@
 # By Chih-Wei Huang <cwhuang@linux.org.tw>
 # and Thorsten Glaser <tg@mirbsd.org>
 #
-# Last updated 2014/01/15
+# Last updated 2015/10/23
 #
 # License: GNU Public License
 # We explicitely grant the right to use the scripts
@@ -78,8 +78,15 @@ check_root()
        else
                dev=$1
        fi
-       try_mount ro $dev /mnt && [ -e /mnt/$SRC/ramdisk.img ]
-       [ $? -ne 0 ] && return 1
+       try_mount ro $dev /mnt || return 1
+       if [ -n "$iso" -a -e /mnt/$iso ]; then
+               mount --move /mnt /iso
+               mkdir /mnt/iso
+               mount -o loop /iso/$iso /mnt/iso
+               SRC=iso
+       elif [ ! -e /mnt/$SRC/ramdisk.img ]; then
+               return 1
+       fi
        zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
        if [ -e /mnt/$SRC/system.sfs ]; then
                mount -o loop /mnt/$SRC/system.sfs /sfs
@@ -94,9 +101,10 @@ check_root()
                rm -rf *
                return 1
        fi
-       mkdir cache mnt
-       mount -t tmpfs tmpfs cache
+       mkdir mnt
        echo " found at $1"
+       rm /sbin/mke2fs
+       hash -r
 }
 
 remount_rw()
@@ -108,9 +116,9 @@ remount_rw()
 
 debug_shell()
 {
-       if which mksh >/dev/null 2>&1; then
+       if [ -x system/bin/sh ]; then
                echo Running MirBSD Korn Shell...
-               USER="($1)" mksh -l 2>&1
+               USER="($1)" system/bin/sh -l 2>&1
        else
                echo Running busybox ash...
                sh 2>&1
@@ -121,6 +129,16 @@ echo -n Detecting Android-x86...
 
 [ -z "$SRC" -a -n "$BOOT_IMAGE" ] && SRC=`dirname $BOOT_IMAGE`
 
+for c in `cat /proc/cmdline`; do
+       case $c in
+               iso-scan/filename=*)
+                       eval `echo $c | cut -b1-3,18-`
+                       ;;
+               *)
+                       ;;
+       esac
+done
+
 mount -t tmpfs tmpfs /android
 cd /android
 while :; do
@@ -134,26 +152,24 @@ done
 
 ln -s mnt/$SRC /src
 ln -s android/system /
-ln -s ../system/lib/modules /lib
-ln -s ../system/lib/firmware /lib
+ln -s ../system/lib/firmware ../system/lib/modules /lib
 
 if [ -n "$INSTALL" ]; then
-       cd /
-       zcat /src/install.img | cpio -iud > /dev/null
+       zcat /src/install.img | ( cd /; cpio -iud > /dev/null )
 fi
 
 if [ -x system/bin/ln -a \( -n "$DEBUG" -o -n "$BUSYBOX" \) ]; then
        mv /bin /lib .
-       system/bin/ln -s android/lib /lib
-       system/bin/ln -s android/bin /bin
-       sed -i 's|\(PATH *\)\(/sbin\)|\1/bin:\2|' init.rc
-       mv /sbin/* sbin
+       sed -i 's|\( PATH.*\)|\1:/bin|' init.environ.rc
+       rm /sbin/modprobe
+       busybox mv /sbin/* sbin
        rmdir /sbin
-       ln -s android/sbin /
+       ln -s android/bin android/lib android/sbin /
+       hash -r
 fi
 
 # ensure keyboard driver is loaded
-[ -n "$INSTALL" -o -n "$DEBUG" ] && modprobe atkbd
+[ -n "$INSTALL" -o -n "$DEBUG" ] && busybox modprobe -a atkbd hid-apple
 
 if [ 0$DEBUG -gt 0 ]; then
        echo -e "\nType 'exit' to continue booting...\n"
@@ -178,7 +194,6 @@ mount_sdcard
 setup_tslib
 setup_dpi
 post_detect
-find_network_dev_name
 
 if [ 0$DEBUG -gt 1 ]; then
        echo -e "\nUse Alt-F1/F2/F3 to switch between virtual consoles"
@@ -193,6 +208,8 @@ fi
 # since it conflicts with Android's init
 echo > /proc/sys/kernel/hotplug
 
+export ANDROID_ROOT=/system
+
 exec ${SWITCH:-switch_root} /android /init
 
 # avoid kernel panic