summaryrefslogtreecommitdiff
path: root/tools/dist/docker/scripts/install-android-tools
blob: 8a617d9942baa2c16f29dfe979a4497557bc80ed (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
87
88
89
90
#!/bin/bash

BASH_RC=~/.bashrc
GODOT_BUILD_TOOLS_PATH=/godot-dev/build-tools
mkdir -p $GODOT_BUILD_TOOLS_PATH
cd $GODOT_BUILD_TOOLS_PATH

ANDROID_BASE_URL=http://dl.google.com/android

ANDROID_SDK_RELEASE=android-sdk_r24.4.1
ANDROID_SDK_DIR=android-sdk-linux
ANDROID_SDK_FILENAME=$ANDROID_SDK_RELEASE-linux.tgz
ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME
ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR
ANDROID_SDK_SHA1=725bb360f0f7d04eaccff5a2d57abdd49061326d

ANDROID_NDK_RELEASE=android-ndk-r10e
ANDROID_NDK_DIR=$ANDROID_NDK_RELEASE
ANDROID_NDK_FILENAME=$ANDROID_NDK_RELEASE-linux-x86_64.bin
ANDROID_NDK_URL=$ANDROID_BASE_URL/ndk/$ANDROID_NDK_FILENAME
ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR
ANDROID_NDK_MD5=19af543b068bdb7f27787c2bc69aba7f

echo
echo "Download and install Android development tools ..."
echo

if [ ! -e $ANDROID_SDK_FILENAME ]; then
	echo "Downloading: Android SDK ..."
	wget $ANDROID_SDK_URL
else
	echo $ANDROID_SDK_SHA1 $ANDROID_SDK_FILENAME > $ANDROID_SDK_FILENAME.sha1
	sha1sum --check --strict $ANDROID_SDK_FILENAME.sha1
	if [ ! $? -eq 0 ]; then
		echo "Downloading: Android SDK ..."
		wget $ANDROID_SDK_URL
	fi
fi

if [ ! -d $ANDROID_SDK_DIR ]; then
	tar -xvzf $ANDROID_SDK_FILENAME
fi

if [ ! -e $ANDROID_NDK_FILENAME ]; then
	echo "Downloading: Android NDK ..."
	wget $ANDROID_NDK_URL
else
	echo $ANDROID_NDK_MD5 $ANDROID_NDK_FILENAME > $ANDROID_NDK_FILENAME.md5
	md5sum --check --strict $ANDROID_NDK_FILENAME.md5
	if [ ! $? -eq 0 ]; then
		echo "Downloading: Android NDK ..."
		wget $ANDROID_NDK_URL
	fi
fi

if [ ! -d $ANDROID_NDK_DIR ]; then
	chmod a+x $ANDROID_NDK_FILENAME
	./$ANDROID_NDK_FILENAME
	echo
fi

cd $ANDROID_SDK_DIR/tools
chmod a+x android

if ! ./android list target | grep -q 'android-19'; then
	echo "Installing: Android Tools ..."
	echo y | ./android update sdk --no-ui --all --filter "platform-tools,android-19,build-tools-19.1.0,\
	extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,\
	extra-google-play_apk_expansion,extra-google-play_billing,extra-google-play_licensing"
fi

EXPORT_VAL="export ANDROID_HOME=$ANDROID_SDK_PATH"
if ! grep -q "^$EXPORT_VAL" $BASH_RC; then
        echo $EXPORT_VAL >> ~/.bashrc
fi


EXPORT_VAL="export ANDROID_NDK_ROOT=$ANDROID_NDK_PATH"
if ! grep -q "^$EXPORT_VAL" $BASH_RC; then
        echo $EXPORT_VAL >> ~/.bashrc
fi

EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools"
if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools.*" $BASH_RC; then
        echo $EXPORT_VAL >> ~/.bashrc
fi

echo
echo "Done!"
echo