OSDN Git Service

installer: support read-write installation
authorChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 18 Dec 2010 12:47:03 +0000 (20:47 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 18 Dec 2010 12:47:03 +0000 (20:47 +0800)
The user now can decide whether to install /system as read-write.
Easier for debugging but needs more disk space.

initrd/init
install/scripts/1-install

index 1b93c6c..d42d1d6 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/busybox sh
 #
 # By Chih-Wei Huang <cwhuang@linux.org.tw>
-# Last updated 2010/09/13
+# Last updated 2010/12/18
 #
 # License: GNU Public License
 # We explicitely grant the right to use the scripts
@@ -46,7 +46,7 @@ while [ 1 ]; do
        for device in /dev/sr* /dev/sd[a-z]*; do
                try_mount ro $device /mnt || continue
                cd /mnt/$SRC
-               if [ ! -e ramdisk.img -o ! \( -e system.img -o -e system.sfs \) ]; then
+               if [ ! -e ramdisk.img -o ! \( -e system.sfs -o -e system.img -o -d system \) ]; then
                        cd /
                        umount /mnt
                        continue
@@ -57,8 +57,11 @@ while [ 1 ]; do
                if [ -e /mnt/$SRC/system.sfs ]; then
                        mount -o loop /mnt/$SRC/system.sfs /sfs
                        mount -o loop /sfs/system.img system
-               else
+               elif [ -e /mnt/$SRC/system.img ]; then
                        mount -o loop /mnt/$SRC/system.img system
+               else
+                       mount -o remount,rw /mnt
+                       mount --bind /mnt/$SRC/system system
                fi
                mkdir cache mnt mnt/sdcard
                mount -t tmpfs tmpfs cache
index feafc8d..89db519 100644 (file)
@@ -159,19 +159,29 @@ install_to()
                [ $? -ne 0 ] && return 255
        fi
 
-       cd /mnt/$SRC
-       files="kernel initrd.img ramdisk.img system.*"
+       dialog --title " Question " --defaultno --yesno \
+               "\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
+       instal_rw=$?
+
+       cd /
+       files="mnt/$SRC/kernel mnt/$SRC/initrd.img mnt/$SRC/ramdisk.img"
+       [ $instal_rw -eq 0 ] && files="$files android/system" || files="$files mnt/$SRC/system.*"
        size=0
-       for s in `ls -ks $files | awk '{print $1}'`; do
+       for s in `du -sk $files | awk '{print $1}'`; do
                size=$(($size+$s))
        done
-       mkdir /hd/$asrc
-       ( ls $files | cpio -H newc -o | pv -ns ${size}k | ( cd /hd/$asrc; cpio -iud > /dev/null; echo $? > /tmp/result )) 2>&1 \
+       mkdir hd/$asrc
+       cd hd/$asrc
+       rm -rf system*
+       ( ( cd /; find $files | cpio -H newc -o ) | pv -ns ${size}k | ( cpio -iud > /dev/null; echo $? > /tmp/result )) 2>&1 \
                | progress_bar "Installing Android-x86" "Expect to write $size KB..."
 
-       chmod 644 /hd/$asrc/*
-       chown 0.0 /hd/$asrc/*
-       [ "$fs" != "vfat" ] && mkdir /hd/$asrc/data
+       chmod 644 *
+       chown 0.0 *
+       mv mnt/$SRC/* . && rm -rf mnt
+       [ -d android ] && mv android/* . && rmdir android
+
+       [ "$fs" != "vfat" ] && mkdir data
        sync
 
        return $((`cat /tmp/result`*255))