mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
e47396b403
`android update sdk --no-ui` is the standard command line tool for installing the Android SDK. By symlinking into the $ANDROID_HOME/temp dir, the cached files can still be used. This converts the chef recipe to a vagrant shell provisioning script since it was all bash anyway. Some file names no longer officially have a -linux in them, so those were changed to keep the cache working with the default filename.
54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/bin/bash
|
|
#
|
|
|
|
set -e
|
|
|
|
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
|
|
|
|
cd /vagrant/cache
|
|
|
|
# make hard links for `android update sdk` to use and delete
|
|
for f in android_*.zip android-[0-9]*.zip platform-[0-9]*.zip build-tools_r*-linux.zip; do
|
|
rm -f ${ANDROID_HOME}/temp/$f
|
|
ln -s /vagrant/cache/$f ${ANDROID_HOME}/temp/
|
|
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'`
|
|
cached=,build-tools-${ver}${cached}
|
|
done
|
|
|
|
${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all \
|
|
--filter platform-tools,extra-android-m2repository${cached} <<EOH
|
|
y
|
|
|
|
EOH
|
|
|
|
|
|
chmod -R a+rX $ANDROID_HOME/
|
|
find $ANDROID_HOME/ -type f -executable -print0 | xargs -0 chmod a+x
|