From: SeokYeon Hwang Date: Thu, 22 Jan 2015 08:37:25 +0000 (+0900) Subject: env: introduced raw image conversion script X-Git-Tag: TizenStudio_2.0_p3.0~363 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F41%2F34241%2F4;p=sdk%2Femulator%2Fqemu.git env: introduced raw image conversion script Introduced raw image conversion script for standalone users and platform developers. Change-Id: I2ea3bd11374bd3a4c7afcb5c6e99d8ca656852c7 Signed-off-by: SeokYeon Hwang --- diff --git a/tizen/supplements/standalone/make_emul_images.sh b/tizen/supplements/standalone/make_emul_images.sh new file mode 100755 index 0000000..58bf176 --- /dev/null +++ b/tizen/supplements/standalone/make_emul_images.sh @@ -0,0 +1,76 @@ +#!/bin/sh -e +# SeokYeon Hwang (syeon.hwang@samsung.com) + +SCRIPT=$(readlink -f $0) +BASEDIR=$(dirname $SCRIPT) + +IMAGE_SIZE=5G +ROOTFS_SIZE=2G +SYSDATA_SIZE=1G +USER_SIZE=2G + +check_util() { + TEMP=`which $1` + if [ -z $TEMP ]; then + if [ $2 = 1 ]; then + echo "'$1' is required." + exit 1 + fi + return 1 + fi + return 0 +} + +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 + +# check prerequsite utils +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 +QEMU_IMG=$TEMP + +# resize raw images +if [ ! -z $SRC_IMG_FILE ]; then + resize2fs $SRC_IMG_FILE $IMAGE_SIZE + cp $SRC_IMG_FILE $EMUL_IMG_RAW_FILE +elif [ -r emulator-rootfs.img ] && [ -r emulator-sysdata.img ] && [ -r emulator-user.img ]; then + PARTITIONIZED=1 + resize2fs emulator-rootfs.img $ROOTFS_SIZE + resize2fs emulator-sysdata.img $SYSDATA_SIZE + resize2fs emulator-user.img $USER_SIZE +elif [ -r emulator-rootfs.img ]; then + resize2fs emulator-rootfs.img $IMAGE_SIZE + cp emulator-rootfs.img $EMUL_IMG_RAW_FILE +elif [ -r platform.img ]; then + resize2fs platform.img $IMAGE_SIZE + cp platform.img $EMUL_IMG_RAW_FILE +else + echo "No rootfs image." + exit 1 +fi + +if [ ! -z $PARTITIONIZED ]; 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 +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