From: Sooyoung Ha Date: Wed, 20 Apr 2016 06:31:44 +0000 (+0900) Subject: supplements: modify make_emul_images.sh script X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=245537d1cbfe4d31c36e6fb4edeb0b5acc80b9c9;p=sdk%2Femulator%2Fqemu.git supplements: modify make_emul_images.sh script Now it supports 2 partition image converting. Change-Id: I2d7df78acaa5110575d1dfa968323f813855beec Signed-off-by: Sooyoung Ha --- diff --git a/tizen/supplements/standalone/make_emul_images.sh b/tizen/supplements/standalone/make_emul_images.sh index 1960c520b9..8cd28872d6 100755 --- a/tizen/supplements/standalone/make_emul_images.sh +++ b/tizen/supplements/standalone/make_emul_images.sh @@ -5,10 +5,19 @@ SCRIPT=$(readlink -f $0) BASEDIR=$(dirname $SCRIPT) +IMAGE_COUNT=0 +IMAGE_LIST="" IMAGE_SIZE=5G -ROOTFS_SIZE=2G -SYSDATA_SIZE=1G -USER_SIZE=2G +PARTITION_SIZE=2G + +if [ ! -z $1 ]; then + SRC_IMG_FILE=$1 +fi +EMUL_IMG_RAW_FILE=emul_img.raw +EMUL_IMG_QCOW2_FILE=emulimg.x86 +PARTITIONIZED=0 + +TEMP="" check_util() { TEMP=`which $1` @@ -32,60 +41,63 @@ check_e2fsck_result() { fi } -if [ ! -z $1 ]; then - SRC_IMG_FILE=$1 -fi -EMUL_IMG_RAW_FILE=emul_img.raw -EMUL_IMG_QCOW2_FILE=emulimg.x86 -PARTITIONIZED=0 +gen_parted_raw_image() { + # generate space for partition table + dd if=/dev/zero of=temp_img.raw bs=1 count=0 seek=1M + + # concatenate raw images into a single image + cat $* >> temp_img.raw + + # convert raw image to sparse type + cp --sparse=always temp_img.raw $EMUL_IMG_RAW_FILE + rm -f temp_img.raw + + TMP_CMD="" + TMP_CNT=1 + while [ $TMP_CNT -lt $# ]; do + TMP_CMD="${TMP_CMD}n\np\n${TMP_CNT}\n\n+${PARTITION_SIZE}\n" + TMP_CNT=`expr $TMP_CNT + 1` + done + TMP_CMD="${TMP_CMD}n\np\n${TMP_CNT}\n\n\nw\n" + /bin/echo -ne "$TMP_CMD" | fdisk $EMUL_IMG_RAW_FILE +} # check prerequsite utils check_util e2fsck 1 check_util resize2fs 1 check_util dd 1 check_util /bin/echo 1 -check_util $BASEDIR/../emulator/bin/qemu-img 0 || check_util $HOME/tizen-sdk/tools/emulator/bin/qemu-img 0 || check_util qemu-img 1 +check_util qemu-img 0 || check_util $HOME/tizen-sdk/tools/emulator/bin/qemu-img 1 QEMU_IMG=$TEMP # resize raw images if [ ! -z $SRC_IMG_FILE ]; then e2fsck -f $SRC_IMG_FILE - resize2fs $SRC_IMG_FILE $IMAGE_SIZE - 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 + IMAGE_LIST=$SRC_IMG_FILE + IMAGE_COUNT=1 else - echo "No rootfs image." - exit 1 + for TMP_IMG in `ls *.img`; do + if [ $IMAGE_COUNT = 3 ]; then + echo "The maximum partition is 3!" + echo "Skip $TMP_IMG!" + continue + fi + IMAGE_COUNT=`expr $IMAGE_COUNT + 1` + echo "$IMAGE_COUNT: found $TMP_IMG" + e2fsck -f $TMP_IMG || check_e2fsck_result $? + resize2fs $TMP_IMG $PARTITION_SIZE + IMAGE_LIST="${IMAGE_LIST}${TMP_IMG} " + done fi -if [ $PARTITIONIZED = 1 ]; then - # generate space for partition table - dd if=/dev/zero of=temp_img.raw bs=1 count=0 seek=1M - - # concatenate raw images into a single image - cat emulator-rootfs.img emulator-sysdata.img emulator-user.img >> temp_img.raw - - # convert raw image to sparse type - cp --sparse=always temp_img.raw $EMUL_IMG_RAW_FILE - rm -f temp_img.raw - - # partitioning image - /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 +if [ $IMAGE_COUNT = 0 ]; then + echo "No rootfs image." + exit 1 +elif [ $IMAGE_COUNT = 1 ]; then + resize2fs $IMAGE_LIST $IMAGE_SIZE + EMUL_IMG_RAW_FILE=$IMAGE_LIST +else + gen_parted_raw_image $IMAGE_LIST fi # generate compressed qcow2 image