bootable/newinstaller
Révision | e8e6a6ef8927c0cd956494c0f374717c67a37cbf (tree) |
---|---|
l'heure | 2010-12-19 04:19:51 |
Auteur | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
installer: several improvements
* better support of installation to ntfs and vfat
* provide a way to create a fake sdcard after installation
@@ -15,6 +15,11 @@ try_mount() | ||
15 | 15 | mount -o $RW $@ || mount.ntfs-3g -o rw,force $@ |
16 | 16 | } |
17 | 17 | |
18 | +remount_rw() | |
19 | +{ | |
20 | + mount -o remount,rw /mnt | |
21 | +} | |
22 | + | |
18 | 23 | if [ -n "$DEBUG" ]; then |
19 | 24 | LOG=/tmp/log |
20 | 25 | set -x |
@@ -60,7 +65,7 @@ while [ 1 ]; do | ||
60 | 65 | elif [ -e /mnt/$SRC/system.img ]; then |
61 | 66 | mount -o loop /mnt/$SRC/system.img system |
62 | 67 | else |
63 | - mount -o remount,rw /mnt | |
68 | + remount_rw | |
64 | 69 | mount --bind /mnt/$SRC/system system |
65 | 70 | fi |
66 | 71 | mkdir cache mnt mnt/sdcard |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # |
2 | 2 | # By Chih-Wei Huang <cwhuang@linux.org.tw> |
3 | -# Last updated 2010/11/17 | |
3 | +# Last updated 2010/12/19 | |
4 | 4 | # |
5 | 5 | # License: GNU Public License |
6 | 6 | # We explicitely grant the right to use the scripts |
@@ -15,10 +15,10 @@ mount_data() | ||
15 | 15 | elif [ -b "/dev/$DATA" ]; then |
16 | 16 | mount /dev/$DATA data |
17 | 17 | elif [ -d /mnt/$SRC/data ]; then |
18 | - mount -o remount,rw /mnt | |
18 | + remount_rw | |
19 | 19 | mount --bind /mnt/$SRC/data data |
20 | 20 | elif [ -f /mnt/$SRC/data.img ]; then |
21 | - mount -o remount,rw /mnt | |
21 | + remount_rw | |
22 | 22 | mount -o loop /mnt/$SRC/data.img data |
23 | 23 | else |
24 | 24 | device_mount_data || mount -t tmpfs tmpfs data |
@@ -28,12 +28,17 @@ mount_data() | ||
28 | 28 | mount_sdcard() |
29 | 29 | { |
30 | 30 | mountpoint -q sdcard && return |
31 | + if [ -n "$SDCARD" -a -e /mnt/$SRC$SDCARD ]; then | |
32 | + remount_rw | |
33 | + sddir=`dirname $SDCARD` | |
34 | + mkdir /android$sddir | |
35 | + mount --bind /mnt/$SRC$sddir /android$sddir | |
36 | + elif [ "$SDCARD" = "premount" ]; then | |
31 | 37 | # WARNING: premount the sdcard is deprecated since froyo-x86. |
32 | 38 | # It is left only for backward compatibility and may be removed |
33 | 39 | # in the future. |
34 | - if [ "$SDCARD" = "premount" ]; then | |
35 | 40 | if [ -d /mnt/$SRC/sdcard ]; then |
36 | - mount -o remount,rw /mnt | |
41 | + remount_rw | |
37 | 42 | mount --bind /mnt/$SRC/sdcard mnt/sdcard |
38 | 43 | elif [ -d data/sdcard ]; then |
39 | 44 | mount --bind data/sdcard mnt/sdcard |
@@ -1,6 +1,6 @@ | ||
1 | 1 | # |
2 | 2 | # By Chih-Wei Huang <cwhuang@linux.org.tw> |
3 | -# Last updated 2010/10/14 | |
3 | +# Last updated 2010/12/19 | |
4 | 4 | # |
5 | 5 | # License: GNU Public License |
6 | 6 | # We explicitely grant the right to use the scripts |
@@ -63,7 +63,7 @@ format_fs() | ||
63 | 63 | cmd="mkntfs -fL" |
64 | 64 | ;; |
65 | 65 | fat32) |
66 | - cmd="mkdosfs -vn" | |
66 | + cmd="newfs_msdos -L" | |
67 | 67 | ;; |
68 | 68 | *) |
69 | 69 | ;; |
@@ -118,6 +118,59 @@ create_winitem() | ||
118 | 118 | fi |
119 | 119 | } |
120 | 120 | |
121 | +create_img() | |
122 | +{ | |
123 | + bname=`basename $2` | |
124 | + if [ -e $2 ]; then | |
125 | + dialog --title " Confirm " --yesno \ | |
126 | + "\n $bname exists. Overwrite it?" 7 38 | |
127 | + [ $? -ne 0 ] && return 255 | |
128 | + rm -f $2 | |
129 | + fi | |
130 | + dialog --title " Question " --nook --nocancel --inputbox \ | |
131 | + "\nPlease input the size of the $bname in MB (max 2047):" 8 63 $1 2> $tempfile | |
132 | + size=`cat $tempfile` | |
133 | + [ 0$size -le 0 -o 0$size -gt 2047 ] && size=2047 | |
134 | + ( dd bs=1M count=$size if=/dev/zero | pv -ns ${size}m | dd of=$2 ) 2>&1 \ | |
135 | + | progress_bar "Creating $bname" "Expect to write $size MB..." | |
136 | +} | |
137 | + | |
138 | +create_data_img() | |
139 | +{ | |
140 | + dialog --title " Confirm " --yesno \ | |
141 | + "\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 | |
142 | + | |
143 | + if [ $? -eq 0 ]; then | |
144 | + if create_img 512 data.img; then | |
145 | + losetup /dev/loop6 data.img | |
146 | + mke2fs -jL /data /dev/loop6 > /dev/tty6 | |
147 | + fi | |
148 | + else | |
149 | + dialog --title " Warning " --msgbox \ | |
150 | + "\nOK. So data will be save to a RAMDISK(tmpfs), and lose after power off." 8 49 | |
151 | + fi | |
152 | +} | |
153 | + | |
154 | +create_sdcard_img() | |
155 | +{ | |
156 | + case "$fs" in | |
157 | + vfat|fuseblk) | |
158 | + mkdir sd | |
159 | + sdcard=sd/sdcard.img | |
160 | + ;; | |
161 | + *) | |
162 | + sdcard=data/sdcard.img | |
163 | + ;; | |
164 | + esac | |
165 | + | |
166 | + if create_img 2047 $sdcard; then | |
167 | + losetup /dev/loop7 $sdcard | |
168 | + newfs_msdos -L sdcard /dev/loop7 > /dev/tty7 2>&1 | |
169 | + fi | |
170 | + sed -i "s|\(SDCARD=\S\+\?\s*\)||; s|\(SRC=\S\+\?\s*\)|\1 SDCARD=/$sdcard|" $menulst | |
171 | + dialog --ok-label Reboot --msgbox "\n The fake SD card is created successfully." 7 47 | |
172 | +} | |
173 | + | |
121 | 174 | install_to() |
122 | 175 | { |
123 | 176 | mountpoint -q /hd && umount /hd |
@@ -130,15 +183,6 @@ install_to() | ||
130 | 183 | done |
131 | 184 | |
132 | 185 | fs=`cat /proc/mounts | grep /dev/$1 | awk '{ print $3 }'` |
133 | - if [ "$fs" = "vfat" ]; then | |
134 | - dialog --title " Warning " --yesno \ | |
135 | - "\nYou are going to install Android-x86 to a fat32 partition. Though this is possible, android cannot save user data to that partition. So data will be save to a RAMDISK(tmpfs), and lose after power off.\n\nAre you sure to continue?" 12 63 | |
136 | - [ $? -ne 0 ] && return 1 | |
137 | - elif [ "$fs" = "fuseblk" ]; then | |
138 | - dialog --title " Warning " --yesno \ | |
139 | - "\nYou are going to install Android-x86 to an NTFS partition. Though this is possible, some user data cannot be saved properly to that partition and will lose after power off.\n\nAre you sure to continue?" 11 63 | |
140 | - [ $? -ne 0 ] && return 1 | |
141 | - fi | |
142 | 186 | |
143 | 187 | asrc=android-$VER |
144 | 188 | dialog --title " Confirm " --no-label Skip --yesno \ |
@@ -159,7 +203,7 @@ install_to() | ||
159 | 203 | [ $? -ne 0 ] && return 255 |
160 | 204 | fi |
161 | 205 | |
162 | - dialog --title " Question " --defaultno --yesno \ | |
206 | + [ "$fs" != "vfat" ] && dialog --title " Question " --defaultno --yesno \ | |
163 | 207 | "\nDo you want to install /system directory as read-write?\n\nLet /system be read-write make it easier to debug, but it needs more disk space and longer installation time." 10 61 |
164 | 208 | instal_rw=$? |
165 | 209 |
@@ -181,7 +225,15 @@ install_to() | ||
181 | 225 | mv mnt/$SRC/* . && rm -rf mnt |
182 | 226 | [ -d android ] && mv android/* . && rmdir android |
183 | 227 | |
184 | - [ "$fs" != "vfat" ] && mkdir data | |
228 | + case "$fs" in | |
229 | + vfat|fuseblk) | |
230 | + create_data_img | |
231 | + ;; | |
232 | + *) | |
233 | + mkdir data | |
234 | + ;; | |
235 | + esac | |
236 | + | |
185 | 237 | sync |
186 | 238 | |
187 | 239 | return $((`cat /tmp/result`*255)) |
@@ -219,8 +271,8 @@ do_install() | ||
219 | 271 | |
220 | 272 | [ -n "$VESA" ] || runit="Run Android-x86" |
221 | 273 | dialog --clear --title ' Congratulations! ' \ |
222 | - --menu "\n Android-x86 is installed successfully.\n " 11 51 13 \ | |
223 | - "$runit" "" "Reboot" "" 2> $tempfile | |
274 | + --menu "\n Android-x86 is installed successfully.\n " 12 51 13 \ | |
275 | + "$runit" "" "Create a fake SD card" "" "Reboot" "" 2> $tempfile | |
224 | 276 | case "`cat $tempfile`" in |
225 | 277 | Run*) |
226 | 278 | cd /android |
@@ -232,7 +284,15 @@ do_install() | ||
232 | 284 | else |
233 | 285 | mount -o loop /hd/$asrc/system.img system |
234 | 286 | fi |
235 | - [ -d /hd/$asrc/data ] && mount --bind /hd/$asrc/data data | |
287 | + if [ -d /hd/$asrc/data ]; then | |
288 | + mount --bind /hd/$asrc/data data | |
289 | + elif [ -e /hd/$asrc/data.img ]; then | |
290 | + mount -o loop /hd/$asrc/data.img data | |
291 | + fi | |
292 | + ;; | |
293 | + Create*) | |
294 | + create_sdcard_img | |
295 | + rebooting | |
236 | 296 | ;; |
237 | 297 | *) |
238 | 298 | rebooting |