• 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évisione8e6a6ef8927c0cd956494c0f374717c67a37cbf (tree)
l'heure2010-12-19 04:19:51
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

installer: several improvements

* better support of installation to ntfs and vfat
* provide a way to create a fake sdcard after installation

Change Summary

Modification

--- a/initrd/init
+++ b/initrd/init
@@ -15,6 +15,11 @@ try_mount()
1515 mount -o $RW $@ || mount.ntfs-3g -o rw,force $@
1616 }
1717
18+remount_rw()
19+{
20+ mount -o remount,rw /mnt
21+}
22+
1823 if [ -n "$DEBUG" ]; then
1924 LOG=/tmp/log
2025 set -x
@@ -60,7 +65,7 @@ while [ 1 ]; do
6065 elif [ -e /mnt/$SRC/system.img ]; then
6166 mount -o loop /mnt/$SRC/system.img system
6267 else
63- mount -o remount,rw /mnt
68+ remount_rw
6469 mount --bind /mnt/$SRC/system system
6570 fi
6671 mkdir cache mnt mnt/sdcard
--- a/initrd/scripts/2-mount
+++ b/initrd/scripts/2-mount
@@ -1,6 +1,6 @@
11 #
22 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3-# Last updated 2010/11/17
3+# Last updated 2010/12/19
44 #
55 # License: GNU Public License
66 # We explicitely grant the right to use the scripts
@@ -15,10 +15,10 @@ mount_data()
1515 elif [ -b "/dev/$DATA" ]; then
1616 mount /dev/$DATA data
1717 elif [ -d /mnt/$SRC/data ]; then
18- mount -o remount,rw /mnt
18+ remount_rw
1919 mount --bind /mnt/$SRC/data data
2020 elif [ -f /mnt/$SRC/data.img ]; then
21- mount -o remount,rw /mnt
21+ remount_rw
2222 mount -o loop /mnt/$SRC/data.img data
2323 else
2424 device_mount_data || mount -t tmpfs tmpfs data
@@ -28,12 +28,17 @@ mount_data()
2828 mount_sdcard()
2929 {
3030 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
3137 # WARNING: premount the sdcard is deprecated since froyo-x86.
3238 # It is left only for backward compatibility and may be removed
3339 # in the future.
34- if [ "$SDCARD" = "premount" ]; then
3540 if [ -d /mnt/$SRC/sdcard ]; then
36- mount -o remount,rw /mnt
41+ remount_rw
3742 mount --bind /mnt/$SRC/sdcard mnt/sdcard
3843 elif [ -d data/sdcard ]; then
3944 mount --bind data/sdcard mnt/sdcard
--- a/install/scripts/1-install
+++ b/install/scripts/1-install
@@ -1,6 +1,6 @@
11 #
22 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3-# Last updated 2010/10/14
3+# Last updated 2010/12/19
44 #
55 # License: GNU Public License
66 # We explicitely grant the right to use the scripts
@@ -63,7 +63,7 @@ format_fs()
6363 cmd="mkntfs -fL"
6464 ;;
6565 fat32)
66- cmd="mkdosfs -vn"
66+ cmd="newfs_msdos -L"
6767 ;;
6868 *)
6969 ;;
@@ -118,6 +118,59 @@ create_winitem()
118118 fi
119119 }
120120
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+
121174 install_to()
122175 {
123176 mountpoint -q /hd && umount /hd
@@ -130,15 +183,6 @@ install_to()
130183 done
131184
132185 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
142186
143187 asrc=android-$VER
144188 dialog --title " Confirm " --no-label Skip --yesno \
@@ -159,7 +203,7 @@ install_to()
159203 [ $? -ne 0 ] && return 255
160204 fi
161205
162- dialog --title " Question " --defaultno --yesno \
206+ [ "$fs" != "vfat" ] && dialog --title " Question " --defaultno --yesno \
163207 "\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
164208 instal_rw=$?
165209
@@ -181,7 +225,15 @@ install_to()
181225 mv mnt/$SRC/* . && rm -rf mnt
182226 [ -d android ] && mv android/* . && rmdir android
183227
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+
185237 sync
186238
187239 return $((`cat /tmp/result`*255))
@@ -219,8 +271,8 @@ do_install()
219271
220272 [ -n "$VESA" ] || runit="Run Android-x86"
221273 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
224276 case "`cat $tempfile`" in
225277 Run*)
226278 cd /android
@@ -232,7 +284,15 @@ do_install()
232284 else
233285 mount -o loop /hd/$asrc/system.img system
234286 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
236296 ;;
237297 *)
238298 rebooting