chiark / gitweb /
set up install/delete lists for "push" commands from server
[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     if [[ $ver == 24.0.0 ]] && [[ $f =~ .*r24\.0\.1.* ]]; then
45         # 24.0.1 has the wrong revision in the zip
46         ver=24.0.1
47     fi
48     cached=,build-tools-${ver}${cached}
49 done
50
51 ${ANDROID_HOME}/tools/android update sdk --no-ui --all \
52     --filter platform-tools,extra-android-m2repository${cached} <<EOH
53 y
54
55 EOH
56
57
58 chmod -R a+rX $ANDROID_HOME/
59 find $ANDROID_HOME/ -type f -executable -print0 | xargs -0 chmod a+x