2016-06-14 16:34:13 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
|
2016-07-04 14:20:42 +02:00
|
|
|
echo $0
|
2016-06-14 16:34:13 +02:00
|
|
|
set -e
|
2016-06-22 08:06:07 +02:00
|
|
|
set -x
|
2016-06-14 16:34:13 +02:00
|
|
|
|
|
|
|
if [ -z $ANDROID_HOME ]; then
|
|
|
|
echo "ANDROID_HOME env var must be set!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# TODO remove the rm, this should work with an existing ANDROID_HOME
|
|
|
|
if [ ! -x $ANDROID_HOME/tools/android ]; then
|
|
|
|
rm -rf $ANDROID_HOME
|
|
|
|
mkdir ${ANDROID_HOME}
|
|
|
|
mkdir ${ANDROID_HOME}/temp
|
|
|
|
mkdir ${ANDROID_HOME}/platforms
|
|
|
|
mkdir ${ANDROID_HOME}/build-tools
|
|
|
|
cd $ANDROID_HOME
|
|
|
|
|
|
|
|
tools=`ls -1 /vagrant/cache/tools_*.zip | sort -n | tail -1`
|
|
|
|
unzip -qq $tools
|
|
|
|
fi
|
|
|
|
|
2016-09-15 11:29:31 +02:00
|
|
|
# disable the repositories of proprietary stuff
|
|
|
|
disabled="
|
|
|
|
@version@=1
|
|
|
|
@disabled@https\://dl.google.com/android/repository/extras/intel/addon.xml=disabled
|
|
|
|
@disabled@https\://dl.google.com/android/repository/glass/addon.xml=disabled
|
|
|
|
@disabled@https\://dl.google.com/android/repository/sys-img/android/sys-img.xml=disabled
|
|
|
|
@disabled@https\://dl.google.com/android/repository/sys-img/android-tv/sys-img.xml=disabled
|
|
|
|
@disabled@https\://dl.google.com/android/repository/sys-img/android-wear/sys-img.xml=disabled
|
|
|
|
@disabled@https\://dl.google.com/android/repository/sys-img/google_apis/sys-img.xml=disabled
|
|
|
|
"
|
|
|
|
test -d ${HOME}/.android || mkdir ${HOME}/.android
|
2017-03-16 11:43:46 +01:00
|
|
|
# there are currently zero user repos
|
|
|
|
echo 'count=0' > ${HOME}/.android/repositories.cfg
|
2016-09-15 11:29:31 +02:00
|
|
|
for line in $disabled; do
|
|
|
|
echo $line >> ${HOME}/.android/sites-settings.cfg
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2016-06-14 16:34:13 +02:00
|
|
|
cd /vagrant/cache
|
|
|
|
|
2016-06-21 18:12:09 +02:00
|
|
|
# make links for `android update sdk` to use and delete
|
2018-11-28 20:47:09 +01:00
|
|
|
blacklist="build-tools_r17-linux.zip
|
|
|
|
build-tools_r18.0.1-linux.zip
|
|
|
|
build-tools_r18.1-linux.zip
|
|
|
|
build-tools_r18.1.1-linux.zip
|
|
|
|
build-tools_r19-linux.zip
|
|
|
|
build-tools_r19.0.1-linux.zip
|
|
|
|
build-tools_r19.0.2-linux.zip
|
|
|
|
build-tools_r19.0.3-linux.zip
|
|
|
|
build-tools_r21-linux.zip
|
|
|
|
build-tools_r21.0.1-linux.zip
|
|
|
|
build-tools_r21.0.2-linux.zip
|
|
|
|
build-tools_r21.1-linux.zip
|
|
|
|
build-tools_r21.1.1-linux.zip
|
|
|
|
build-tools_r22-linux.zip
|
|
|
|
build-tools_r23-linux.zip
|
|
|
|
android-1.5_r04-linux.zip
|
|
|
|
android-1.6_r03-linux.zip
|
|
|
|
android-2.0_r01-linux.zip
|
|
|
|
android-2.0.1_r01-linux.zip"
|
2016-09-19 13:29:46 +02:00
|
|
|
latestm2=`ls -1 android_m2repository*.zip | sort -n | tail -1`
|
|
|
|
for f in $latestm2 android-[0-9]*.zip platform-[0-9]*.zip build-tools_r*-linux.zip; do
|
2016-06-14 16:34:13 +02:00
|
|
|
rm -f ${ANDROID_HOME}/temp/$f
|
2018-11-28 20:47:09 +01:00
|
|
|
if [[ $blacklist != *$f* ]]; then
|
|
|
|
ln -s /vagrant/cache/$f ${ANDROID_HOME}/temp/
|
|
|
|
fi
|
2016-06-14 16:34:13 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# install all cached platforms
|
|
|
|
cached=""
|
|
|
|
for f in `ls -1 android-[0-9]*.zip platform-[0-9]*.zip`; do
|
|
|
|
sdk=`unzip -c $f "*/build.prop" | sed -n 's,^ro.build.version.sdk=,,p'`
|
|
|
|
cached=,android-${sdk}${cached}
|
|
|
|
done
|
|
|
|
|
|
|
|
# install all cached build-tools
|
|
|
|
for f in `ls -1 build-tools*.zip`; do
|
|
|
|
ver=`unzip -c $f "*/source.properties" | sed -n 's,^Pkg.Revision=,,p'`
|
2016-08-02 18:08:48 +02:00
|
|
|
if [[ $ver == 24.0.0 ]] && [[ $f =~ .*r24\.0\.1.* ]]; then
|
|
|
|
# 24.0.1 has the wrong revision in the zip
|
|
|
|
ver=24.0.1
|
|
|
|
fi
|
2016-06-14 16:34:13 +02:00
|
|
|
cached=,build-tools-${ver}${cached}
|
|
|
|
done
|
|
|
|
|
2016-06-21 18:12:09 +02:00
|
|
|
${ANDROID_HOME}/tools/android update sdk --no-ui --all \
|
2016-06-22 08:06:07 +02:00
|
|
|
--filter platform-tools,extra-android-m2repository${cached} <<EOH
|
2016-06-14 16:34:13 +02:00
|
|
|
y
|
|
|
|
|
|
|
|
EOH
|
|
|
|
|
2017-03-13 16:31:27 +01:00
|
|
|
mkdir -p $ANDROID_HOME/licenses/
|
2017-11-24 09:21:28 +01:00
|
|
|
|
2017-11-14 10:38:48 +01:00
|
|
|
cat << EOF > $ANDROID_HOME/licenses/android-sdk-license
|
|
|
|
|
|
|
|
8933bad161af4178b1185d1a37fbf41ea5269c55
|
2017-11-24 09:21:28 +01:00
|
|
|
|
2017-11-14 10:38:48 +01:00
|
|
|
d56f5187479451eabf01fb78af6dfcb131a6481e
|
2019-03-30 22:10:21 +01:00
|
|
|
|
|
|
|
24333f8a63b6825ea9c5514f83c2829b004d1fee
|
2017-11-14 10:38:48 +01:00
|
|
|
EOF
|
2017-11-24 09:21:28 +01:00
|
|
|
|
|
|
|
cat <<EOF > $ANDROID_HOME/licenses/android-sdk-preview-license
|
|
|
|
|
|
|
|
84831b9409646a918e30573bab4c9c91346d8abd
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > $ANDROID_HOME/licenses/android-sdk-preview-license-old
|
2019-03-30 22:10:21 +01:00
|
|
|
|
2017-11-24 09:21:28 +01:00
|
|
|
79120722343a6f314e0719f863036c702b0e6b2a
|
|
|
|
|
|
|
|
84831b9409646a918e30573bab4c9c91346d8abd
|
|
|
|
EOF
|
|
|
|
|
2017-03-13 16:31:27 +01:00
|
|
|
echo y | $ANDROID_HOME/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.1"
|
|
|
|
echo y | $ANDROID_HOME/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.1"
|
|
|
|
echo y | $ANDROID_HOME/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
|
|
|
|
echo y | $ANDROID_HOME/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
|
2016-06-14 16:34:13 +02:00
|
|
|
|
|
|
|
chmod -R a+rX $ANDROID_HOME/
|
2017-03-22 10:59:44 +01:00
|
|
|
chgrp vagrant $ANDROID_HOME
|
|
|
|
chmod g+w $ANDROID_HOME
|
2016-06-14 16:34:13 +02:00
|
|
|
find $ANDROID_HOME/ -type f -executable -print0 | xargs -0 chmod a+x
|
2017-03-14 12:39:03 +01:00
|
|
|
|
2017-11-14 10:29:21 +01:00
|
|
|
# allow gradle to install newer build-tools and platforms
|
|
|
|
chgrp vagrant $ANDROID_HOME/{build-tools,platforms}
|
|
|
|
chmod g+w $ANDROID_HOME/{build-tools,platforms}
|
2017-03-16 11:43:46 +01:00
|
|
|
|
|
|
|
# allow gradle/sdkmanager to install into the new m2repository
|
|
|
|
test -d $ANDROID_HOME/extras/m2repository || mkdir -p $ANDROID_HOME/extras/m2repository
|
|
|
|
find $ANDROID_HOME/extras/m2repository -type d | xargs chgrp vagrant
|
|
|
|
find $ANDROID_HOME/extras/m2repository -type d | xargs chmod g+w
|