Skip to content

Instantly share code, notes, and snippets.

@nickwph
Last active February 25, 2016 18:27
Show Gist options
  • Save nickwph/2b7b5c5c76163c17c78b to your computer and use it in GitHub Desktop.
Save nickwph/2b7b5c5c76163c17c78b to your computer and use it in GitHub Desktop.
# filtering function from sdk list
function get_id_with_regex {
android list sdk --all --extended | grep $1 | sed 's/.*"\(.*\)".*/\1/g' | tr '\n' ','
}
# grep ids
INSTALL_FILTER=$(get_id_with_regex 'build-tools') # build-tools-*
INSTALL_FILTER+=$(get_id_with_regex '"android-\(1[5-9]\|[2-9][0-9]\)') # android-15 to android-99
INSTALL_FILTER+='tools,'
INSTALL_FILTER+='platform-tool,'
INSTALL_FILTER+='extra-android-support,'
INSTALL_FILTER+='extra-android-m2repository,'
INSTALL_FILTER+='extra-google-m2repository,'
echo "installing: $INSTALL_FILTER"
# install sdk
expect -c "
set timeout -1;
spawn android update sdk --no-ui --all --filter $INSTALL_FILTER;
expect {
\"Do you accept the license\" { exp_send \y\r\ ; exp_continue }
eof
}"
# remove things not needed
rm -rf $ANDROID_HOME/temp/*
rm -rf $ANDROID_HOME/samples/*
rm -rf $ANDROID_HOME/sources/*
rm -rf $ANDROID_HOME/system-images/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment