chiark / gitweb /
82e4ed4389323e2d39b18d18735f493d92795674
[fdroidserver.git] / buildserver / provision-android-sdk
1 #!/bin/bash
2 #
3
4 set -e
5 set -x
6
7 if [ -z $ANDROID_HOME ]; then
8     echo "ANDROID_HOME env var must be set!"
9     exit 1
10 fi
11
12 # TODO remove the rm, this should work with an existing ANDROID_HOME
13 if [ ! -x $ANDROID_HOME/tools/android ]; then
14     rm -rf $ANDROID_HOME
15     mkdir ${ANDROID_HOME}
16     mkdir ${ANDROID_HOME}/temp
17     mkdir ${ANDROID_HOME}/platforms
18     mkdir ${ANDROID_HOME}/build-tools
19     cd $ANDROID_HOME
20
21     tools=`ls -1 /vagrant/cache/tools_*.zip | sort -n | tail -1`
22     unzip -qq $tools
23 fi
24
25 cd /vagrant/cache
26
27 # make links for `android update sdk` to use and delete
28 for f in android_*.zip android-[0-9]*.zip platform-[0-9]*.zip build-tools_r*-linux.zip; do
29     rm -f ${ANDROID_HOME}/temp/$f
30     ln -s /vagrant/cache/$f ${ANDROID_HOME}/temp/
31 done
32
33 # install all cached platforms
34 cached=""
35 for f in `ls -1 android-[0-9]*.zip platform-[0-9]*.zip`; do
36     sdk=`unzip -c $f "*/build.prop" | sed -n 's,^ro.build.version.sdk=,,p'`
37     cached=,android-${sdk}${cached}
38 done
39
40 # install all cached build-tools
41 for f in `ls -1 build-tools*.zip`; do
42     ver=`unzip -c $f "*/source.properties" | sed -n 's,^Pkg.Revision=,,p'`
43     cached=,build-tools-${ver}${cached}
44 done
45
46 ${ANDROID_HOME}/tools/android update sdk --no-ui --all \
47     --filter platform-tools,extra-android-m2repository${cached} <<EOH
48 y
49
50 EOH
51
52
53 chmod -R a+rX $ANDROID_HOME/
54 find $ANDROID_HOME/ -type f -executable -print0 | xargs -0 chmod a+x