OSDN Git Service

Add a script to run Android-x86 in QEMU
[android-x86/bootable-newinstaller.git] / initrd / init
index 9f1e1bf..32d6a4e 100755 (executable)
@@ -3,7 +3,7 @@
 # By Chih-Wei Huang <cwhuang@linux.org.tw>
 # and Thorsten Glaser <tg@mirbsd.org>
 #
-# Last updated 2015/10/05
+# Last updated 2017/04/23
 #
 # License: GNU Public License
 # We explicitely grant the right to use the scripts
@@ -65,7 +65,7 @@ try_mount()
                RW="nolock,$RW"
        fi
        # FIXME: any way to mount ntfs gracefully?
-       mount -o $RW $@ || mount.ntfs-3g -o rw,force $@
+       mount -o $RW,noatime $@ || mount.ntfs-3g -o rw,force $@
 }
 
 check_root()
@@ -84,24 +84,30 @@ check_root()
                mkdir /mnt/iso
                mount -o loop /iso/$iso /mnt/iso
                SRC=iso
-       elif [ ! -e /mnt/$SRC/ramdisk.img ]; then
+       fi
+       if [ -e /mnt/$SRC/$RAMDISK ]; then
+               zcat /mnt/$SRC/$RAMDISK | cpio -id > /dev/null
+       elif [ -b /dev/$RAMDISK ]; then
+               zcat /dev/$RAMDISK | cpio -id > /dev/null
+       else
                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
-               mount -o loop /sfs/system.img system
+               mount -o loop,noatime /mnt/$SRC/system.sfs /sfs
+               mount -o loop,noatime /sfs/system.img system
        elif [ -e /mnt/$SRC/system.img ]; then
                remount_rw
-               mount -o loop /mnt/$SRC/system.img system
+               mount -o loop,noatime /mnt/$SRC/system.img system
        elif [ -d /mnt/$SRC/system ]; then
                remount_rw
                mount --bind /mnt/$SRC/system system
+       elif [ -e /mnt/build.prop ]; then
+               mount --bind /mnt system
        else
                rm -rf *
                return 1
        fi
-       mkdir mnt
+       mkdir -p mnt
        echo " found at $1"
        rm /sbin/mke2fs
        hash -r
@@ -128,6 +134,7 @@ debug_shell()
 echo -n Detecting Android-x86...
 
 [ -z "$SRC" -a -n "$BOOT_IMAGE" ] && SRC=`dirname $BOOT_IMAGE`
+[ -z "$RAMDISK" ] && RAMDISK=ramdisk.img || RAMDISK=${RAMDISK##/dev/}
 
 for c in `cat /proc/cmdline`; do
        case $c in
@@ -168,19 +175,19 @@ if [ -x system/bin/ln -a \( -n "$DEBUG" -o -n "$BUSYBOX" \) ]; then
        hash -r
 fi
 
+# load scripts
+for s in `ls /scripts/* /src/scripts/*`; do
+       test -e "$s" && source $s
+done
+
 # ensure keyboard driver is loaded
-[ -n "$INSTALL" -o -n "$DEBUG" ] && modprobe atkbd
+[ -n "$INSTALL" -o -n "$DEBUG" ] && auto_detect &
 
 if [ 0$DEBUG -gt 0 ]; then
        echo -e "\nType 'exit' to continue booting...\n"
        debug_shell debug-found
 fi
 
-# load scripts
-for s in `ls /scripts/* /src/scripts/*`; do
-       test -e "$s" && source $s
-done
-
 # A target should provide its detect_hardware function.
 # On success, return 0 with the following values set.
 # return 1 if it wants to use auto_detect
@@ -200,14 +207,19 @@ if [ 0$DEBUG -gt 1 ]; then
        echo -e "Type 'exit' to enter Android...\n"
 
        debug_shell debug-late
+       SETUPWIZARD=${SETUPWIZARD:-0}
 fi
 
+[ "$SETUPWIZARD" = "0" ] && echo "ro.setupwizard.mode=DISABLED" >> default.prop
+
 [ -n "$DEBUG" ] && SWITCH=${SWITCH:-chroot}
 
 # We must disable mdev before switching to Android
 # 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