OSDN Git Service

init: support Xen hypervisor device
[android-x86/bootable-newinstaller.git] / install / scripts / 1-install
index 0ef318b..1a50ebf 100644 (file)
@@ -61,7 +61,7 @@ find_partition()
 
 list_disks()
 {
-       for b in /sys/block/[shv]d[a-z] /sys/block/mmcblk? /sys/block/nvme*; do
+       for b in /sys/block/[shv]d[a-z] /sys/block/xvd[a-z] /sys/block/mmcblk? /sys/block/nvme*; do
                [ -d $b ] && echo $b
        done
 }
@@ -171,7 +171,7 @@ select_dev()
                for i in /sys/block/$d/$d*; do
                        [ -d $i ] || continue
                        echo $i | grep -qE "loop|ram|sr|boot|rpmb" && continue
-                       f=$(grep "`basename $i`" $tempfile || printf "%-11s%-29s" `basename $i` unknown)
+                       f=$(grep "`basename $i`" $tempfile || printf "%-11s%-30s" `basename $i` unknown)
                        sz=$(size_gb $i)
                        [ "$sz" = "0.00GB" ] || printf "$f%10s\n" $sz
                done
@@ -208,7 +208,7 @@ convert_fs()
 format_fs()
 {
        local cmd
-       echo -e '"Do not format" ""\next4 ""\nntfs ""\nfat32 ""' > $menufile
+       echo -e '"Do not re-format" ""\next4 ""\nntfs ""\nfat32 ""' > $menufile
        set_answer_if_auto $FORCE_FORMAT
        choose "Choose filesystem" "Please select a filesystem to format $1:"
        case "$choice" in
@@ -322,26 +322,34 @@ create_data_img()
 try_upgrade()
 {
        [ -d $1 ] && return
-       PREV_VERS="$PREV_VERS 7.1-r2 7.1-r1 7.1-rc2 7.1-rc1 6.0-r3 6.0-r2 6.0-r1 6.0-rc2 6.0-rc1 5.1-rc1 4.4-r5 4.4-r4 4.4-r3 4.4-r2 4.4-r1 4.4-RC2 4.4-RC1 4.4-test 4.3-test 4.2-test 4.0-r1 4.0-RC2 4.0-RC1"
-       for v in $PREV_VERS; do
-               local prev
-               if [ -d hd/$v ]; then
-                       prev=hd/$v
-               elif [ -d hd/android-$v ]; then
-                       prev=hd/android-$v
-               else
-                       continue
-               fi
+
+       for d in hd/*; do
+               [ -e "$d"/ramdisk.img -a -n "`ls "$d"/system* 2> /dev/null`" ] && echo \"`basename $d`\" \"\"
+       done | sort -r > $menufile
+
+       count=`wc -l < $menufile`
+       if [ $count -gt 1 ]; then
+               echo -e '"" ""\n"Install to new folder '`basename $1`'" ""' >> $menufile
+               choose "Multiple older versions are found" "Please select one to upgrade:"
+       elif [ $count -eq 1 ]; then
+               eval choice=`awk '{ print $1 }' $menufile`
                set_answer_if_auto 1
                adialog --title " Question " --yesno \
-                       "\nAn older version $v is detected.\nWould you like to upgrade it?" 8 51
-               if [ $? -eq 0 ]; then
+                       "\nAn older version $choice is detected.\nWould you like to upgrade it?" 8 61
+               [ $? -eq 0 ] || choice=
+       fi
+
+       if [ -n "$choice" ]; then
+               prev=hd/$choice
+               if [ -d "$prev" ]; then
                        mv $prev $1
+                       for d in `find hd -type l -maxdepth 1`; do
+                               [ "`readlink $d`" = "$choice" ] && ln -sf `basename $1` $d
+                       done
                        rm -rf $1/data/dalvik-cache/* $1/data/system/wpa_supplicant
-                       sed -i 's/\(ctrl_interface=\)\(.*\)/\1wlan0/' $1/data/misc/wifi/wpa_supplicant.conf
-                       break
+                       [ -s $1/data/misc/wifi/wpa_supplicant.conf ] && sed -i 's/\(ctrl_interface=\)\(.*\)/\1wlan0/' $1/data/misc/wifi/wpa_supplicant.conf
                fi
-       done
+       fi
 }
 
 get_part_info()
@@ -349,7 +357,7 @@ get_part_info()
        d=0
        while [ 1 ]; do
                h=`echo $d | awk '{ printf("%c", $1+97) }'`
-               for part in /sys/block/[shv]d$h/$1 /sys/block/mmcblk$d/$1 /sys/block/nvme0n$(($d+1))/$1; do
+               for part in /sys/block/[shv]d$h/$1 /sys/block/xvd$h/$1 /sys/block/mmcblk$d/$1 /sys/block/nvme0n$(($d+1))/$1; do
                        [ -d $part ] && break 2
                done
                d=$(($d+1))
@@ -423,7 +431,7 @@ install_to()
                done
                if [ -z "$esp" ]; then
                        get_part_info $1
-                       boot=$(blkid /dev/$disk* | grep vfat | cut -d: -f1 | head -1)
+                       boot=$(blkid /dev/$disk* | grep -v $disk: | grep vfat | cut -d: -f1 | head -1)
                        [ -z "$boot" ] && boot=`find_partition $disk 1` || boot=`basename $boot`
                        esp=`cat /sys/block/$disk/$boot/partition`
                fi
@@ -479,7 +487,10 @@ install_to()
                fi
        fi
 
-       set_answer_if_auto 0
+       try_upgrade hd/$asrc
+
+       ! test -f hd/$asrc/system.img -o -d hd/$asrc/system
+       set_answer_if_auto $?
        adialog --title " Question " --defaultno --yesno \
                "\nDo you want to install /system directory as read-write?\n\nMaking /system be read-write is easier for debugging, but it needs more disk space and longer installation time." 10 61
        instal_rw=$?
@@ -499,7 +510,7 @@ install_to()
        for s in `du -sk $files | awk '{print $1}'`; do
                size=$(($size+$s))
        done
-       try_upgrade hd/$asrc
+
        mkdir -p hd/$asrc
        cd hd/$asrc
        rm -rf system*
@@ -541,6 +552,7 @@ install_hd()
                        answer=${answer:-$(blkid | grep -v loop | sort | grep ext4 | cut -d: -f1 | head -1)}
                        [ -b "$answer" -o -b /dev/$answer ] && answer=`basename $answer` || answer=
                        AUTO_UPDATE=${answer:-$AUTO_UPDATE}
+                       [ -z "$AUTO_UPDATE" ] && AUTO_INSTALL=
                        ;;
                *)
                        [ -z "$answer" ] && set_answer_if_auto Create