diff --git a/init_env b/init_env index 107679b2d157600aa99509c6518c8a1967b71a21..3918459ff1e9f55cf0e0b27ace27d7e9ced4a802 100644 --- a/init_env +++ b/init_env @@ -20,6 +20,13 @@ _lisa_shell_ret=1 +setup_paths() { + # Bail out if local tools are not installed + [[ -d $LISA_HOME/tools/android-sdk-linux ]] || return + export ANDROID_HOME="$LISA_HOME/tools/android-sdk-linux" + export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH" +} + # Running under BASH if [[ -n $BASH_VERSION ]]; then # Get base installation path of LISA @@ -29,7 +36,7 @@ if [[ -n $BASH_VERSION ]]; then PS1="\[${LISASHELL_BLUE}\][LISAShell \[${LISASHELL_LCYAN}\]\W\[${LISASHELL_BLUE}\]] \> \[${LISASHELL_RESET}\]" # Make sure that bash picks up new location for all binaries - hash -r + hash -r # Running under ZSH elif [[ -n $ZSH_VERSION ]]; then @@ -57,6 +64,8 @@ else echo "Please, source this configuration from a terminal running BASH." fi +setup_paths + return $_lisa_shell_ret # vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab diff --git a/install_base_ubuntu.sh b/install_base_ubuntu.sh index ffee69ee9c540f286beb379fa7b29cf2bd3daa8b..ada1553778f7e8e58ab1dff4555e3435c2898f67 100755 --- a/install_base_ubuntu.sh +++ b/install_base_ubuntu.sh @@ -13,6 +13,12 @@ usage() { echo Usage: "$0" [--install-android-sdk] } +latest_version() { + TOOL=${1} + $SCRIPT_DIR/tools/android-sdk-linux/tools/bin/sdkmanager --list | \ + awk "/ $TOOL/{VER=\$1}; END{print VER}" +} + install_sdk() { apt-get -y install openjdk-8-jre openjdk-8-jdk mkdir -p "$SCRIPT_DIR"/tools @@ -20,31 +26,20 @@ install_sdk() { ANDROID_SDK_URL="https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz" echo "Downloading Android SDK [$ANDROID_SDK_URL]..." wget -qO- $ANDROID_SDK_URL | tar xz -C $SCRIPT_DIR/tools/ + # Find last version of required SDK tools + VER_BUILD_TOOLS=$(latest_version " build-tools") + VER_PLATFORM_TOOLS=$(latest_version " platform-tools") + VER_TOOLS=$(latest_version " tools") expect -c " set timeout -1; spawn $SCRIPT_DIR/tools/android-sdk-linux/tools/android \ - update sdk --no-ui -t tools,platform-tools + update sdk --no-ui -t $VER_BUILD_TOOLS,$VER_PLATFORM_TOOLS,$VER_TOOLS expect { \"Do you accept the license\" { exp_send \"y\r\" ; exp_continue } eof } " fi - - ANDROID_EXPORT="export ANDROID_HOME=$(realpath $SCRIPT_DIR/tools/android-sdk-linux)" - if [ "$(cat ~/.bashrc | grep ANDROID_HOME | wc -l)" -eq 0 ]; then - echo "$ANDROID_EXPORT" >> ~/.bashrc - fi - - PLATFORM_TOOLS_EXPORT="export PATH=\$ANDROID_HOME/platform-tools" - if [ -z "$(cat ~/.bashrc | grep "$PLATFORM_TOOLS_EXPORT")" ]; then - echo "$PLATFORM_TOOLS_EXPORT:\$PATH" >> ~/.bashrc - fi - - TOOLS_EXPORT="export PATH=\$ANDROID_HOME/tools" - if [ -z "$(cat ~/.bashrc | grep "$TOOLS_EXPORT")" ]; then - echo "$TOOLS_EXPORT:\$PATH" >> ~/.bashrc - fi } set -eu