X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=initrd%2Finit;h=b204c27bb7890bd4512e73b347241510953c0da4;hb=d9cf94c51253afa7fd8dbefe1fe7635c07e55cc6;hp=ed0202ff87524b1bf41e56649040ce7a8efda43e;hpb=9342b19ec4d7a996503a914049201926dcc0e3a6;p=android-x86%2Fbootable-newinstaller.git diff --git a/initrd/init b/initrd/init index ed0202f..b204c27 100755 --- a/initrd/init +++ b/initrd/init @@ -3,8 +3,6 @@ # By Chih-Wei Huang # and Thorsten Glaser # -# Last updated 2015/10/23 -# # License: GNU Public License # We explicitely grant the right to use the scripts # with Android-x86 project. @@ -12,8 +10,11 @@ PATH=/sbin:/bin:/system/bin:/system/xbin; export PATH +# auto installation +[ -n "$AUTO_INSTALL" ] && INSTALL=1 + # configure debugging output -if [ -n "$DEBUG" ]; then +if [ -n "$DEBUG" -o -n "$INSTALL" ]; then LOG=/tmp/log set -x else @@ -62,10 +63,20 @@ try_mount() RW=$1; shift if [ "${ROOT#*:/}" != "$ROOT" ]; then # for NFS roots, use nolock to avoid dependency to portmapper - RW="nolock,$RW" + mount -o $RW,noatime,nolock $@ + return $? fi - # FIXME: any way to mount ntfs gracefully? - mount -o $RW,noatime $@ || mount.ntfs-3g -o rw,force $@ + case $(blkid $1) in + *TYPE=*ntfs*) + mount.ntfs-3g -o rw,force $@ + ;; + *TYPE=*) + mount -o $RW,noatime $@ + ;; + *) + return 1 + ;; + esac } check_root() @@ -83,25 +94,30 @@ check_root() mount --move /mnt /iso 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,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,noatime /mnt/$SRC/system.img system - elif [ -d /mnt/$SRC/system ]; then + elif [ -s /mnt/$SRC/system/build.prop ]; then remount_rw mount --bind /mnt/$SRC/system system + elif [ -z "$SRC" -a -s /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 @@ -119,6 +135,7 @@ debug_shell() if [ -x system/bin/sh ]; then echo Running MirBSD Korn Shell... USER="($1)" system/bin/sh -l 2>&1 + [ $? -ne 0 ] && /bin/sh 2>&1 else echo Running busybox ash... sh 2>&1 @@ -128,10 +145,12 @@ 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 iso-scan/filename=*) + SRC=iso eval `echo $c | cut -b1-3,18-` ;; *) @@ -142,7 +161,7 @@ done mount -t tmpfs tmpfs /android cd /android while :; do - for device in ${ROOT:-/dev/[hmsv][dmr][0-9a-z]*}; do + for device in ${ROOT:-/dev/[hmnsvx][dmrv][0-9a-z]*}; do check_root $device && break 2 mountpoint -q /mnt && umount /mnt done @@ -158,8 +177,8 @@ if [ -n "$INSTALL" ]; then 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 . +if [ -x system/bin/ln -a -n "$BUSYBOX" ]; then + mv -f /bin /lib . sed -i 's|\( PATH.*\)|\1:/bin|' init.environ.rc rm /sbin/modprobe busybox mv /sbin/* sbin @@ -168,19 +187,22 @@ 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" ] && busybox modprobe -a atkbd hid-apple +if [ -n "$INSTALL" -o -n "$DEBUG" ]; then + busybox modprobe -a atkbd hid-apple + auto_detect & +fi 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,8 +222,11 @@ 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