OSDN Git Service

1-install: avoid overwriting /boot/grub/grub.cfg
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 17 Jan 2018 03:31:09 +0000 (11:31 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 17 Jan 2018 03:31:09 +0000 (11:31 +0800)
Originally we just write a new /boot/grub/grub.cfg to ESP.
It may destroy boot entries of other OSes (e.g. Ubuntu).
That's not good.

To avoid the issue, move our grub.cfg to a higher priority dir
/boot/grub/${grub_cpu}-efi/ which is usually not used.

install/scripts/1-install

index aed38ae..55d2cc5 100644 (file)
@@ -337,9 +337,15 @@ install_to()
                        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
-               mkdir -p hd/boot/grub hd/efi/Android
+               if [ "$efi" = "32" ]; then
+                       grubcfg=hd/boot/grub/i386-efi/grub.cfg
+                       bootefi=bootia32.efi
+               else
+                       grubcfg=hd/boot/grub/x86_64-efi/grub.cfg
+                       bootefi=BOOTx64.EFI
+               fi
+               mkdir -p `dirname $grubcfg` hd/efi/Android
                cp -af grub2/efi/boot/* hd/efi/Android
-               grubcfg=/hd/boot/grub/grub.cfg
 
                # Our grub-efi doesn't support ntfs directly.
                # Copy boot files to ESP so grub-efi could read them
@@ -360,11 +366,6 @@ install_to()
                        dialog --title " Question " --defaultno --yesno "\nEFI boot entries for previous Android-x86 installations were found.\n\nDo you wish to delete them?" 10 61
                        [ $? -eq 0 ] && while read entry; do efibootmgr -Bb "$entry" > /dev/tty4 2>&1; done < /tmp/efientries
                fi
-               if [ "$efi" = "32" ]; then
-                       bootefi=bootia32.efi
-               else
-                       bootefi=BOOTx64.EFI
-               fi
                efibootmgr -v -c -d /dev/$disk -p $bootp -L "Android-x86 $VER" -l /efi/Android/$bootefi > /dev/tty4 2>&1
 
                mountpoint -q /hd && umount /hd