supplements: modify make_emul_images.sh
authorSooyoung Ha <yoosah.ha@samsung.com>
Wed, 27 May 2015 05:45:00 +0000 (14:45 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 27 May 2015 06:21:42 +0000 (15:21 +0900)
add e2fsck check for raw image.
The default result is compressed image.

Change-Id: Ic9d42877319fcb7df9f18842aabcd44330366b1c
Signed-off-by: Sooyoung Ha <yoosah.ha@samsung.com>
tizen/supplements/standalone/make_emul_images.sh

index 58bf176ade1d526909810068c0b71e7c93dc6aac..1960c520b9ec6dce0be4729b1fe46ec5ae2d1d33 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh -e
 # SeokYeon Hwang (syeon.hwang@samsung.com)
+# Sooyoung Ha    (yoosah.ha@samsung.com)
 
 SCRIPT=$(readlink -f $0)
 BASEDIR=$(dirname $SCRIPT)
@@ -21,14 +22,25 @@ check_util() {
     return 0
 }
 
+check_e2fsck_result() {
+    if [ $1 = 1 ]; then
+        echo "e2fsck catched file system errors, but corrected well."
+        return 0
+    else
+        echo "e2fsck failed $1"
+        return $1
+    fi
+}
+
 if [ ! -z $1 ]; then
     SRC_IMG_FILE=$1
 fi
 EMUL_IMG_RAW_FILE=emul_img.raw
-EMUL_IMG_QCOW2_FILE=emul_img.qcow2
-EMUL_IMG_COMPRESSED_QCOW2_FILE=emul_img.compressed.qcow2
+EMUL_IMG_QCOW2_FILE=emulimg.x86
+PARTITIONIZED=0
 
 # check prerequsite utils
+check_util e2fsck 1
 check_util resize2fs 1
 check_util dd 1
 check_util /bin/echo 1
@@ -37,17 +49,23 @@ QEMU_IMG=$TEMP
 
 # resize raw images
 if [ ! -z $SRC_IMG_FILE ]; then
+    e2fsck -f $SRC_IMG_FILE
     resize2fs $SRC_IMG_FILE $IMAGE_SIZE
-    cp $SRC_IMG_FILE $EMUL_IMG_RAW_FILE
+    EMUL_IMG_RAW_FILE=$SRC_IMG_FILE
 elif [ -r emulator-rootfs.img ] && [ -r emulator-sysdata.img ] && [ -r emulator-user.img ]; then
     PARTITIONIZED=1
+    e2fsck -f emulator-rootfs.img || check_e2fsck_result $?
+    e2fsck -f emulator-sysdata.img || check_e2fsck_result $?
+    e2fsck -f emulator-user.img || check_e2fsck_result $?
     resize2fs emulator-rootfs.img $ROOTFS_SIZE
     resize2fs emulator-sysdata.img $SYSDATA_SIZE
     resize2fs emulator-user.img $USER_SIZE
 elif [ -r emulator-rootfs.img ]; then
+    e2fsck -f emulator-rootfs.img
     resize2fs emulator-rootfs.img $IMAGE_SIZE
     cp emulator-rootfs.img $EMUL_IMG_RAW_FILE
 elif [ -r platform.img ]; then
+    e2fsck -f platform.img
     resize2fs platform.img $IMAGE_SIZE
     cp platform.img $EMUL_IMG_RAW_FILE
 else
@@ -55,7 +73,7 @@ else
     exit 1
 fi
 
-if [ ! -z $PARTITIONIZED ]; then
+if [ $PARTITIONIZED = 1 ]; then
     # generate space for partition table
     dd if=/dev/zero of=temp_img.raw bs=1 count=0 seek=1M
 
@@ -70,7 +88,5 @@ if [ ! -z $PARTITIONIZED ]; then
     /bin/echo -ne "n\np\n1\n\n+$ROOTFS_SIZE\nn\np\n2\n\n+$SYSDATA_SIZE\nn\np\n3\n\n\nw\n" | fdisk $EMUL_IMG_RAW_FILE
 fi
 
-# generate qcow2 image
-$QEMU_IMG convert -O qcow2 $EMUL_IMG_RAW_FILE $EMUL_IMG_QCOW2_FILE
 # generate compressed qcow2 image
-$QEMU_IMG convert -c -O qcow2 $EMUL_IMG_RAW_FILE $EMUL_IMG_COMPRESSED_QCOW2_FILE
+$QEMU_IMG convert -c -O qcow2 $EMUL_IMG_RAW_FILE $EMUL_IMG_QCOW2_FILE