#!/bin/sh -e
# SeokYeon Hwang (syeon.hwang@samsung.com)
+# Sooyoung Ha (yoosah.ha@samsung.com)
SCRIPT=$(readlink -f $0)
BASEDIR=$(dirname $SCRIPT)
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
# 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
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
/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