• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

bootable/newinstaller


Commit MetaInfo

Révisionc84d951182d0547fbd74830586d684e075646400 (tree)
l'heure2015-05-08 02:04:33
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

support GPT disks

* allow to create GPT partitions
* allow to install to a GPT partition
* allow to install grub2-efi to the ESP partition

Based on the nice work of hatharry <hatharry@gmail.com>.

Change Summary

Modification

--- a/Android.mk
+++ b/Android.mk
@@ -75,7 +75,7 @@ $(INITRD_RAMDISK): $(initrd_bin) $(systemimg) $(TARGET_INITRD_SCRIPTS) | $(ACP)
7575 $(MKBOOTFS) $(TARGET_INSTALLER_OUT) | gzip -9 > $@
7676
7777 INSTALL_RAMDISK := $(PRODUCT_OUT)/install.img
78-$(INSTALL_RAMDISK): $(wildcard $(LOCAL_PATH)/install/*/*) | $(MKBOOTFS)
78+$(INSTALL_RAMDISK): $(wildcard $(LOCAL_PATH)/install/*/* $(LOCAL_PATH)/install/*/*/*/*) | $(MKBOOTFS)
7979 $(if $(TARGET_INSTALL_SCRIPTS),$(ACP) -p $(TARGET_INSTALL_SCRIPTS) $(TARGET_INSTALLER_OUT)/scripts)
8080 $(MKBOOTFS) $(dir $(dir $(<D))) | gzip -9 > $@
8181
@@ -109,7 +109,7 @@ $(EFI_IMAGE): $(wildcard $(LOCAL_PATH)/boot/efi/*/*) $(BUILT_IMG) $(ESP_LAYOUT)
109109 done; \
110110 size=$$(($$(($$(($$(($$(($$size + $$(($$size / 100)))) - 1)) / 32)) + 1)) * 32)); \
111111 rm -f $@.fat; mkdosfs -n Android-x86 -C $@.fat $$size
112- $(hide) mcopy -Qsi $@.fat $(dir $(<D)) $(BUILT_IMG) ::
112+ $(hide) mcopy -Qsi $@.fat $(<D)/../../../install/grub2/efi $(BUILT_IMG) ::
113113 $(hide) mcopy -Qoi $@.fat $(@D)/grub.cfg ::efi/boot
114114 $(hide) cat /dev/null > $@; $(edit_mbr) -l $(ESP_LAYOUT) -i $@ esp=$@.fat
115115 $(hide) rm -f $@.fat
--- a/boot/efi/boot/grub.cfg
+++ b/boot/efi/boot/grub.cfg
@@ -1,18 +1,18 @@
11 menuentry 'Android-x86 VER Live' --class android-x86 {
22 search --file --no-floppy --set=root /system.sfs
3- linuxefi /kernel CMDLINE sdhci.debug_quirks=0x8000 quiet DATA=
3+ linuxefi /kernel CMDLINE quiet DATA=
44 initrdefi /initrd.img
55 }
66
77 menuentry 'Android-x86 VER DEBUG mode' --class android-x86 {
88 search --file --no-floppy --set=root /system.sfs
9- linuxefi /kernel CMDLINE sdhci.debug_quirks=0x8000 DATA= DEBUG=2
9+ linuxefi /kernel CMDLINE DATA= DEBUG=2
1010 initrdefi /initrd.img
1111 }
1212
1313 menuentry 'Android-x86 VER Installation' --class android-x86 {
1414 search --file --no-floppy --set=root /system.sfs
15- linuxefi /kernel CMDLINE sdhci.debug_quirks=0x8000 DEBUG= INSTALL=1
15+ linuxefi /kernel CMDLINE DEBUG= INSTALL=1
1616 initrdefi /initrd.img
1717 }
1818
Binary files /dev/null and b/install/bin/cgdisk differ
Binary files /dev/null and b/install/lib/libgcc_s.so.1 differ
Binary files /dev/null and b/install/lib/libstdc++.so.6 differ
Binary files a/install/lib/libuuid.so.1 and b/install/lib/libuuid.so.1 differ
--- a/install/scripts/1-install
+++ b/install/scripts/1-install
@@ -60,7 +60,12 @@ partition_drive()
6060 choose "Choose Drive" "Please select a drive to edit partitions:"
6161 fi
6262 if [ $retval -eq 0 ]; then
63- cfdisk /dev/$choice
63+ dialog --title " Confirm " --defaultno --yesno "\n Do you want to use GPT?" 7 29
64+ if [ $? -eq 0 ]; then
65+ cgdisk /dev/$choice
66+ else
67+ cfdisk /dev/$choice
68+ fi
6469 if [ $? -eq 0 ]; then
6570 retval=1
6671 else
@@ -72,12 +77,31 @@ partition_drive()
7277
7378 select_dev()
7479 {
75- fdisk -l | grep ^/dev | cut -b6-12,55- | awk '{
76- if (!match($2, "Extended")) {
77- printf("\"%-28s", $0)
78- system("echo -n `cat /sys/block/*/"$1"/../device/model`")
79- printf("\" \"\"\n")
80- }
80+ blkid | grep -v -E "^/dev/block/|^/dev/loop" | cut -b6- | sort | awk '{
81+ t="unknown"
82+ for (i = NF; i > 1; --i)
83+ if (match($i, "^TYPE")) {
84+ t=$i
85+ break
86+ }
87+ gsub(/TYPE=|"/, "", t)
88+ printf("%s\t%s\n", $1, t)
89+ }' > $tempfile
90+
91+ lsblk=`ls /sys/block | grep -v -E "loop|ram|sr|boot|rpmb"`
92+ for d in $lsblk; do
93+ p=0
94+ for i in /sys/block/$d/$d* /sys/block/$d; do
95+ [ -e $i/partition ] && p=1
96+ [ $p -eq 1 -a "$i" = "/sys/block/$d" ] && break
97+ echo $i | grep -q -E "boot|rpmb" && continue
98+ [ -d $i ] && ( grep "`basename $i:`" $tempfile || echo "`basename $i` unknown" )
99+ done
100+ done | awk '{
101+ sub(/:/, "", $1)
102+ printf("\"%-13s%-17s", $1, $2)
103+ system("cd /sys/block; for f in "$1"/device/model "$1"/device/name */"$1"/../device/model */"$1"/../device/name; do [ -e $f ] && echo -n `cat $f` && break; done")
104+ printf("\" \"\"\n")
81105 } END {
82106 printf("\"Create/Modify partitions\" \"\"\n\"Detect devices\" \"\"")
83107 }' > $menufile
@@ -112,7 +136,7 @@ format_fs()
112136 ;;
113137 esac
114138 if [ -n "$cmd" ]; then
115- dialog --title " Confirm " --no-label Skip --yesno \
139+ dialog --title " Confirm " --defaultno --yesno \
116140 "\n You chose to format $1 to $choice.\n All data in that partition will LOSE.\n\n Are you sure to format the partition $1?" 10 51
117141 [ $? -ne 0 ] && return 1
118142 $cmd Android-x86 /dev/$1 | awk '{
@@ -135,7 +159,6 @@ create_menulst()
135159 menulst=/hd/grub/menu.lst
136160 [ -n "$VESA" ] && vga=" vga=788 modeset=0"
137161 echo -e "${GRUB_OPTIONS:-default=0\ntimeout=6\nsplashimage=/grub/android-x86.xpm.gz\n}root (hd0,$1)\n" > $menulst
138- cmdline=`cat /proc/cmdline | sed "s|\(initrd.*img\s*\)||; s|quiet\s*||; s|\(vga=\w\+\?\s*\)||; s|\(DPI=\w\+\?\s*\)||; s|\(INSTALL=\w\+\?\s*\)||; s|\(SRC=\S\+\?\s*\)||; s|\(DEBUG=\w\+\?\s*\)||; s|\(BOOT_IMAGE.*\)||"`
139162
140163 create_entry "Android-x86 $VER" quiet $cmdline
141164 create_entry "Android-x86 $VER (Debug mode)" $cmdline DEBUG=2
@@ -211,6 +234,20 @@ try_upgrade()
211234 done
212235 }
213236
237+get_part_info()
238+{
239+ d=0
240+ while [ 1 ]; do
241+ h=`echo $d | awk '{ printf("%c", $1+97) }'`
242+ for part in /sys/block/[shv]d$h/$1 /sys/block/mmcblk$d/$1; do
243+ [ -d $part ] && break 2
244+ done
245+ d=$(($d+1))
246+ done
247+ p=`cat $part/partition`
248+ disk=$(basename `dirname $part`)
249+}
250+
214251 install_to()
215252 {
216253 cd /
@@ -224,20 +261,15 @@ install_to()
224261 done
225262
226263 fs=`cat /proc/mounts | grep /dev/$1 | awk '{ print $3 }'`
264+ cmdline=`sed "s|\(initrd.*img\s*\)||; s|quiet\s*||; s|\(vga=\w\+\?\s*\)||; s|\(DPI=\w\+\?\s*\)||; s|\(INSTALL=\w\+\?\s*\)||; s|\(SRC=\S\+\?\s*\)||; s|\(DEBUG=\w\+\?\s*\)||; s|\(BOOT_IMAGE=\S\+\?\s*\)||" /proc/cmdline`
227265
228266 asrc=android-$VER
229267 dialog --title " Confirm " --no-label Skip --defaultno --yesno \
230268 "\n Do you want to install boot loader GRUB?" 7 47
231269 if [ $? -eq 0 ]; then
232270 cp -af /grub /hd
233- d=0
234- while [ 1 ]; do
235- h=`echo $d | awk '{ printf("%c", $1+97) }'`
236- [ -d /sys/block/[shv]d$h/$1 ] && break
237- d=$(($d+1))
238- done
239- p=$((`echo $1 | cut -b4-`-1))
240- disk=`echo $1 | cut -b-3`
271+ get_part_info $1
272+ p=$(($p-1))
241273 create_menulst $p
242274 create_winitem $1 $d
243275 rm -f /hd/boot/grub/stage1
@@ -246,6 +278,31 @@ install_to()
246278 [ $? -ne 0 ] && return 255
247279 fi
248280
281+ dialog --title " Confirm " --no-label Skip --defaultno --yesno \
282+ "\n Do you want to install EFI GRUB2?" 7 39
283+ if [ $? -eq 0 ]; then
284+ get_part_info $1
285+ for i in /sys/block/$disk/$disk*; do
286+ [ 0`cat $i/partition` -eq 1 ] && break
287+ done
288+ boot=`basename $i`
289+ mountpoint -q /hd && umount /hd
290+ dialog --title " Confirm " --defaultno --yesno \
291+ "\n Do you want to format the boot partition\n /dev/$boot?" 8 45
292+ [ $? -eq 0 ] && mkdosfs -n EFI /dev/$boot
293+ try_mount rw /dev/$boot /hd
294+ cp -af /grub2/efi /hd
295+ grubcfg=/hd/efi/boot/grub.cfg
296+ echo -e "set timeout=6" > $grubcfg
297+ echo -e "menuentry \"Android-x86 $VER\" {\n\tsearch --set=root --file /$asrc/kernel\n\tlinuxefi /$asrc/kernel quiet $cmdline \n\tinitrdefi /$asrc/initrd.img\n}" >> $grubcfg
298+ echo -e "menuentry \"Android-x86 $VER (DEBUG mode)\" {\n\tsearch --set=root --file /$asrc/kernel\n\tlinuxefi /$asrc/kernel $cmdline DEBUG=2\n\tinitrdefi /$asrc/initrd.img\n}" >> $grubcfg
299+ if [ -e /hd/EFI/Microsoft/Boot/bootmgfw.efi ]; then
300+ echo -e "menuentry \"Windows (UEFI)\" {\n\tsearch --set=root --file /EFI/Microsoft/Boot/bootmgfw.efi\n\tchainloader /EFI/Microsoft/Boot/bootmgfw.efi\n}" >> $grubcfg
301+ fi
302+ mountpoint -q /hd && umount /hd
303+ try_mount rw /dev/$1 /hd
304+ fi
305+
249306 dialog --title " Question " --yesno \
250307 "\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
251308 instal_rw=$?
@@ -274,11 +331,13 @@ install_to()
274331 result=$((`cat /tmp/result`*255))
275332
276333 if [ $result -eq 0 ]; then
277- chmod 644 *
278- chown 0.0 *
279334 for d in android mnt sfs ./$SRC; do
280335 [ -d $d ] && mv $d/* . && rmdir $d
281336 done
337+ chown 0.0 *
338+ for f in *; do
339+ [ -d $f ] || chmod 644 $f
340+ done
282341
283342 case "$fs" in
284343 vfat|fuseblk)
@@ -290,6 +349,7 @@ install_to()
290349 esac
291350 fi
292351
352+ dialog --infobox "\n Syncing to disk..." 5 27
293353 sync
294354
295355 return $result