blob: 193e55ed915e4f347f0071028a6732ba058d7817 (
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
|
#!/bin/sh -xe
# clean
set_var () {
echo ==== Init ====
BASE_DIR=`pwd`
echo $BASE_DIR
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
for size in 4 8 16 32
do
echo "make sdcard_${size}G image"
${ROOTDIR}/tools/emulator/bin/qemu-img create -f raw raw_${size}G.img ${size}G
mkfs.ext4 -F raw_${size}G.img
${ROOTDIR}/tools/emulator/bin/qemu-img convert -O qcow2 raw_${size}G.img sdcard_ext4_${size}G.img
rm raw_${size}G.img
done
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()
{
if test ! -e "${ROOTDIR}/tools/emulator/bin/qemu-img"
then
echo "qemu-img tools does not exist.\n"
exit 1
fi
create_sdcard_image
check_swap_image
}
# install
install()
{
mkdir -p $SRCDIR/package/emulator-storages.package.$TARGET_OS
mv $PKG_DIR/* $SRCDIR/package/emulator-storages.package.$TARGET_OS/
}
[ "$1" = "clean" ] && clean
[ "$1" = "build" ] && build
[ "$1" = "install" ] && install
echo "success"
|