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