OSDN Git Service

Let users specify the target disk to auto install
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 8 Feb 2018 04:59:07 +0000 (12:59 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 8 Feb 2018 04:59:07 +0000 (12:59 +0800)
It's a little tricky to select ESP if auto install to non-first disk.
Instead of using the ESP from the first disk, we select the ESP on the
target disk. This is useful if auto install to a USB disk.

boot/isolinux/isolinux.cfg
install/grub2/efi/boot/android.cfg
install/scripts/1-install

index 8f2df61..5ebea7c 100644 (file)
@@ -40,9 +40,9 @@ label vesa
 menu separator
 
 label auto_install
-       menu label Audo_^Installation - Auto Install to first harddisk
+       menu label Audo_^Installation - Auto Install to specified harddisk
        kernel /kernel
-       append initrd=/initrd.img CMDLINE AUTO_INSTALL=1 DEBUG=
+       append initrd=/initrd.img CMDLINE AUTO_INSTALL=0 DEBUG=
 
 label auto_update
        menu label Audo_^Update - Auto update Android-x86
index 315e228..6292e9c 100644 (file)
@@ -47,7 +47,7 @@ fi
 submenu "Advanced options -> " {
        add_entry "$live - No Hardware Acceleration" quiet nomodeset HWACCEL=0
        if [ -s ($android)$kdir/install.img ]; then
-               add_entry "Auto Install to first harddisk" AUTO_INSTALL=1
+               add_entry "Auto Install to specified harddisk" AUTO_INSTALL=0
                add_entry "Auto Update" AUTO_INSTALL=update
        fi
        if [ "$grub_cpu" != "i386" ]; then
index 806b4d3..20261d9 100644 (file)
@@ -1,6 +1,6 @@
 #
 # By Chih-Wei Huang <cwhuang@linux.org.tw>
-# Last updated 2018/02/07
+# Last updated 2018/02/08
 #
 # License: GNU Public License
 # We explicitely grant the right to use the scripts
@@ -85,6 +85,7 @@ auto_partition()
                answer=`find_partition $1 $p`
                [ -n "$answer" ] && break
        done
+       [ -n "$efi" ] && mkdosfs -n EFI /dev/`find_partition $1 1`
 }
 
 partition_drive()
@@ -396,22 +397,20 @@ install_to()
        [ -n "$efi" ] && adialog --title " Confirm " --no-label Skip --yesno \
                "\n Do you want to install EFI GRUB2?" 7 39
        if [ $? -eq 0 ]; then
-               for i in `list_disks`; do
+               [ -z "$AUTO_INSTALL" -o -n "$AUTO_UPDATE" ] && for i in `list_disks`; do
                        disk=`basename $i`
                        esp=`sgdisk --print /dev/$disk 2> /dev/null | grep EF00 | awk '{print $1}'`
                        [ -n "$esp" ] && boot=`find_partition $disk $esp` && break
                done
                if [ -z "$esp" ]; then
                        get_part_info $1
-                       boot=`basename $(blkid /dev/$disk* | grep vfat | cut -d: -f1 | head -1)`
-                       [ -z "$boot" ] && boot=`find_partition $disk 1`
+                       boot=$(blkid /dev/$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
                mkdir -p efi
                mountpoint -q efi && umount efi
-               while [ 1 ]; do
-                       [ -n "$AUTO_INSTALL" -a -z "$AUTO_UPDATE" ] && mkdosfs -n EFI /dev/$boot
-                       try_mount rw /dev/$boot efi && break
+               until try_mount rw /dev/$boot efi; do
                        dialog --title " Confirm " --defaultno --yesno "\n Cannot mount /dev/$boot.\n Do you want to format it?" 8 37
                        [ $? -eq 0 ] && mkdosfs -n EFI /dev/$boot
                done