+ create_entry "Android-x86 $VER (Debug mode)" $cmdline DEBUG=2
+ create_entry "Android-x86 $VER (Debug nomodeset)" nomodeset $cmdline DEBUG=2
+ create_entry "Android-x86 $VER (Debug video=LVDS-1:d)" video=LVDS-1:d $cmdline DEBUG=2
+}
+
+create_winitem()
+{
+ win=`fdisk -l /dev/$(echo $1 | cut -b-3) | grep ^/dev | cut -b6-12,55- | awk '{
+ if (match($2, "NTFS"))
+ print $1
+ }' | head -1`
+ if [ -n "$win" ]; then
+ dialog --title " Confirm " --yesno \
+ "\nThe installer found a Windows partition in /dev/$win.\n\nDo you want to create a boot item for Windows?" 9 59
+ [ $? -ne 0 ] && return 1
+ wp=$((`echo $win | cut -b4-`-1))
+ echo -e "title Windows\n\trootnoverify (hd$d,$wp)\n\tchainloader +1\n" >> $menulst
+ fi
+}
+
+create_img()
+{
+ bname=`basename $2`
+ if [ -e $2 ]; then
+ dialog --title " Confirm " --defaultno --yesno \
+ "\n $bname exists. Overwrite it?" 7 38
+ [ $? -ne 0 ] && return 255
+ rm -f $2
+ fi
+ dialog --title " Question " --nook --nocancel --inputbox \
+ "\nPlease input the size of the $bname in MB:" 8 63 $1 2> $tempfile
+ size=`cat $tempfile`
+ [ 0$size -le 0 ] && size=1024
+ ( dd bs=1M count=$size if=/dev/zero | pv -ns ${size}m | dd of=$2 ) 2>&1 \
+ | progress_bar "Creating $bname" "Expect to write $size MB..."
+}
+
+create_data_img()
+{
+ dialog --title " Confirm " --yesno \
+ "\nThe installer is going to create a disk image to save the user data. At least 512MB free disk space is recommended.\n\nAre you sure to create the image?" 11 62
+
+ if [ $? -eq 0 ]; then
+ if create_img 512 data.img; then
+ losetup /dev/loop6 data.img
+ mke2fs -jL /data /dev/loop6 > /dev/tty6
+ fi
+ [ $? -ne 0 ] && dialog --msgbox "\n Failed to create data.img." 7 33
+ else
+ dialog --title " Warning " --msgbox \
+ "\nOK. So data will be save to a RAMDISK(tmpfs), and lose after power off." 8 49
+ fi
+}
+
+try_upgrade()
+{
+ [ -d $1 ] && return
+ PREV_VERS="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
+ prev=hd/android-$v
+ if [ -d $prev ]; then
+ dialog --title " Question " --yesno \
+ "\nAn older Android-x86 version $v is detected.\nWould you like to upgrade it?" 8 55
+ if [ $? -eq 0 ]; then
+ mv $prev $1
+ 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
+ fi
+ fi
+ done
+}
+
+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; do
+ [ -d $part ] && break 2
+ done
+ d=$(($d+1))
+ done
+ p=`cat $part/partition`
+ disk=$(basename `dirname $part`)