summaryrefslogtreecommitdiff
path: root/package/build.ubuntu-32
blob: 9e91e44cffb4175b191949cd7483f67cd704f442 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh -xe
# clean
set_var () {
	echo ==== Init ====
	BASE_DIR=`pwd`
	echo $BASE_DIR
	PKG_OS="ubuntu-32"
	PKG_META="remove"
	PKG="public"
	PKG_UPLOAD="EMULATOR_PUBLIC"
	PKG_DIR=$BASE_DIR/EMUL_PKG
	PKG_BIN_DIR=$PKG_DIR/data/tools/emulator
	SWAP_IMG_NAME="swap.img"
	SWAP_DIR=$PKG_BIN_DIR/storages/swap

	mkdir -p $PKG_BIN_DIR/storages/sdcard
	mkdir -p $SWAP_DIR
}

create_sdcard_image () {
	echo ==== Start creating sdcard image ====
	cd $PKG_BIN_DIR/storages/sdcard
	qemu-img create -f raw raw_4G.img 4G 
	mkfs.ext3 -F raw_4G.img 
	qemu-img convert -O qcow2 raw_4G.img sdcard_4G.img
 	rm raw_4G.img

	qemu-img create -f raw raw_8G.img 8G 
	mkfs.ext3 -F raw_8G.img 
	qemu-img convert -O qcow2 raw_8G.img sdcard_8G.img
 	rm raw_8G.img

	qemu-img create -f raw raw_16G.img 16G 
	mkfs.ext3 -F raw_16G.img 
	qemu-img convert -O qcow2 raw_16G.img sdcard_16G.img
 	rm raw_16G.img

	qemu-img create -f raw raw_32G.img 32G 
	mkfs.ext3 -F raw_32G.img 
	qemu-img convert -O qcow2 raw_32G.img sdcard_32G.img
 	rm raw_32G.img
	echo ==== Finish creating sdcard image ====
}

check_swap_image () {
	echo ==== Start checking swap image ====
	if [ -f ${BASE_DIR}/${SWAP_IMG_NAME} ]
	then
		cp "${BASE_DIR}/${SWAP_IMG_NAME}" "${SWAP_DIR}/${SWAP_IMG_NAME}"
	else
		echo "CAUTION!! There's no ${SWAP_IMG_NAME} file."
		echo "Packaging is failed."
		exit 1;
	fi
	echo ==== Finish checking swap image ====
}

set_var

clean()
{
	echo "$SRCDIR"
	rm -rf $PKG_DIR
	rm -rf $BASE_DIR/*.zip
	rm -rf $BASE_DIR/package/emulator-storages.package.$TARGET_OS
}

# build
build() 
{
	create_sdcard_image
	check_swap_image
}

# install
install() 
{
	mkdir -p $SRCDIR/package/emulator-storages.package.$TARGET_OS
	cp -r $PKG_DIR/* $SRCDIR/package/emulator-storages.package.$TARGET_OS/
}

[ "$1" = "clean" ] && clean
[ "$1" = "build" ] && build
[ "$1" = "install" ] && install

echo "success"