Last active
August 29, 2015 14:14
-
-
Save kingargyle/4fbd94837a0efbdb9632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2013 Embark Mobile | |
# Modified to work with Eclipse HIPP instance by David Carver | |
# Licensed under the MIT License. | |
# https://github.com/embarkmobile/android-sdk-installer | |
set +e | |
#detecting os | |
os=linux | |
if [[ `uname` == 'Darwin' ]]; then | |
os=osx | |
fi | |
# Constants | |
if [[ $os == 'linux' ]]; then | |
SDK_FILE=android-sdk_r24.0.2-linux.tgz | |
elif [[ $os == 'osx' ]]; then | |
SDK_FILE=android-sdk_r24.0.2-macosx.zip | |
fi | |
SDK_URL=http://dl.google.com/android/$SDK_FILE | |
DEFAULT_INSTALL=platform-tools | |
# Defaults | |
INSTALLER_DIR=$WORKSPACE/.android-sdk-installer | |
INSTALL="" | |
LICENSES="android-sdk-license-5be876d5" | |
if [ -d "$INSTALLER_DIR" ]; then | |
echo "Android SDK Directory exists. Not re-installing." | |
exit | |
fi | |
for i in "$@" | |
do | |
case $i in | |
--dir=*) | |
INSTALLER_DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` | |
;; | |
--install=*) | |
INSTALL=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` | |
;; | |
--accept=*) | |
LICENSES=`echo $i | sed 's/[-a-zA-Z0-9]*=//'` | |
;; | |
*) | |
# unknown option | |
;; | |
esac | |
done | |
# Expand the path | |
if [[ $os == 'linux' ]]; then | |
INSTALLER_DIR=`readlink -f "$INSTALLER_DIR"` | |
elif [[ $os == 'osx' ]]; then | |
INSTALLER_DIR=`stat -f "$INSTALLER_DIR"` | |
fi | |
TOOLS_DIR=$INSTALLER_DIR/tools | |
echo "Installing SDK in $INSTALLER_DIR" | |
mkdir -p $INSTALLER_DIR | |
mkdir -p $TOOLS_DIR | |
echo "Downloading SDK" | |
wget -c -O $INSTALLER_DIR/$SDK_FILE $SDK_URL | |
echo "Extracting SDK" | |
if [[ $os == 'linux' ]]; then | |
tar xzf $INSTALLER_DIR/$SDK_FILE --directory $INSTALLER_DIR | |
export ANDROID_HOME=$INSTALLER_DIR/android-sdk-linux | |
elif [[ $os == 'osx' ]]; then | |
unzip -q -d $INSTALLER_DIR $INSTALLER_DIR/$SDK_FILE | |
export ANDROID_HOME=$INSTALLER_DIR/android-sdk-macosx | |
fi | |
# Setup environment file | |
echo "export ANDROID_HOME=$ANDROID_HOME" > $INSTALLER_DIR/env | |
echo "export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$TOOLS_DIR:\$PATH" >> $INSTALLER_DIR/env | |
# Install components | |
ALL_INSTALL=$DEFAULT_INSTALL | |
echo "Installing $ALL_INSTALL" | |
#bash $TOOLS_DIR/accept-licenses -x "$ANDROID_HOME/tools/android update sdk --no-ui -a --filter $ALL_INSTALL" "$LICENSES" | |
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | $ANDROID_HOME/tools/android update sdk --proxy-host proxy.eclipse.org --proxy-port 9898 --no-ui -a --filter tools,platform-tools,build-tools-21.1.2,android-21,android-20,android-19,android-18,android-17,android-16,sample-21,sample-20,sample-16,android-14,sample-14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment