From b9242ef702027dfe4eec872fa46a915b67c86655 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 28 Jun 2024 16:08:09 +0100 Subject: [PATCH 1/2] Revert "install_base.sh: Fixup devlib parameter handling" This reverts commit 13d943eea6f09b6482a2091a7099f9bed07914ba. --- install_base.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/install_base.sh b/install_base.sh index 96533b0f2..ce3048e6e 100755 --- a/install_base.sh +++ b/install_base.sh @@ -207,16 +207,14 @@ for arg in "${args[@]}"; do handled=0 case "$arg" in - "--cleanup-android-sdk" | "--install-android-platform-tools" ) + "--cleanup-android-sdk" | \ + "--install-android-tools" | \ + "--install-android-platform-tools" | \ + "--install-all") devlib_params+=(${arg}) handled=1 ;;& - "--install-android-tools" | "--install-all" ) - devlib_params+=("--install-android-tools") - handled=1 - ;;& - "--install-doc-extras" | "--install-all") apt_packages+=(plantuml graphviz pandoc) # plantuml can be installed from the AUR -- GitLab From b5f61f312562357b42dd22ce118c06a77e055fa2 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 28 Jun 2024 16:08:18 +0100 Subject: [PATCH 2/2] Revert "install_base.sh: Offload Android SDK/tools installation to devlib" This reverts commit 8bbce4c268c80c03c8ebc458ae00a846d36abf98. --- install_base.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 9 deletions(-) diff --git a/install_base.sh b/install_base.sh index ce3048e6e..7cb08914c 100755 --- a/install_base.sh +++ b/install_base.sh @@ -58,6 +58,81 @@ cd "$LISA_HOME" || (echo "LISA_HOME ($LISA_HOME) does not exists" && exit 1) # Must be kept in sync with shell/lisa_shell export ANDROID_HOME="$LISA_HOME/tools/android-sdk-linux/" +ANDROID_SDK_ROOT="$ANDROID_HOME" +mkdir -p "$ANDROID_HOME" + +# No need for the whole SDK for this one +install_android_platform_tools() { + echo "Installing Android platform tools ..." + + local url="https://dl.google.com/android/repository/platform-tools-latest-linux.zip" + local archive="$ANDROID_HOME/android-platform-tools.zip" + + wget --no-verbose "$url" -O "$archive" && + echo "Extracting $archive ..." && + unzip -q -o "$archive" -d "$ANDROID_HOME" +} + +cleanup_android_home() { + echo "Cleaning up Android SDK: $ANDROID_HOME" + rm -r "$ANDROID_HOME" + mkdir -p "$ANDROID_HOME" +} + +install_android_sdk_manager() { + echo "Installing Android SDK manager ..." + + # URL taken from "Command line tools only": https://developer.android.com/studio + # Used to be "https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip" + # Used to be "https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip" + # Used to be "https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip" + # Used to be "https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip" + local url="https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" + local archive="$ANDROID_HOME/android-sdk-manager.zip" + rm "$archive" &>/dev/null + + echo "Downloading Android SDK manager from: $url" + wget --no-verbose "$url" -O "$archive" && + echo "Extracting $archive ..." && + unzip -q -o "$archive" -d "$ANDROID_HOME" + + yes | (call_android_sdkmanager --licenses || true) + call_android_sdkmanager --list +} + +# Android SDK is picky on Java version, so we need to set JAVA_HOME manually. +# In most distributions, Java is installed under /usr/lib/jvm so use that. +# according to the distribution +ANDROID_SDK_JAVA_VERSION=17 +find_java_home() { + _JAVA_BIN=$(find -L /usr/lib/jvm -path "*$ANDROID_SDK_JAVA_VERSION*/bin/java" -not -path '*/jre/bin/*' -print -quit) + _JAVA_HOME=$(dirname "$_JAVA_BIN")/../ + + echo "Found JAVA_HOME=$_JAVA_HOME" +} + +call_android_sdk() { + # Used to be: + # local tool="$ANDROID_HOME/tools/bin/$1" + local tool="$ANDROID_HOME/cmdline-tools/bin/$1" + shift + echo "Using JAVA_HOME=$_JAVA_HOME for Android SDK" >&2 + # Use grep to remove the progress bar, as there is no CLI option for the SDK + # manager to do that + JAVA_HOME=$_JAVA_HOME "$tool" "$@" | grep -v '\[=' +} + +call_android_sdkmanager() { + call_android_sdk sdkmanager --sdk_root="$ANDROID_SDK_ROOT" "$@" +} + +# Needs install_android_sdk_manager first +install_android_tools() { + # We could use install_android_platform_tools here for platform-tools if the + # SDK starts being annoying + yes | call_android_sdkmanager --verbose --channel=0 --install "build-tools;34.0.0" + yes | call_android_sdkmanager --verbose --channel=0 --install "platform-tools" +} install_apt() { echo "Installing apt packages ..." @@ -111,6 +186,10 @@ apt_packages=( python3-tk python3-setuptools qemu-user-static + rsync + sshpass + unzip + wget ) # pacman-based distributions like Archlinux or its derivatives @@ -124,6 +203,10 @@ pacman_packages=( python-pip python-setuptools qemu-user-static + rsync + sshpass + unzip + wget ) HOST_ARCH="$(uname -m)" @@ -201,17 +284,33 @@ fi # Use conditional fall-through ;;& to all matching all branches with # --install-all -devlib_params=() for arg in "${args[@]}"; do # We need this flag since *) does not play well with fall-through ;;& handled=0 case "$arg" in - "--cleanup-android-sdk" | \ - "--install-android-tools" | \ - "--install-android-platform-tools" | \ - "--install-all") - devlib_params+=(${arg}) + "--cleanup-android-sdk") + install_functions+=(cleanup_android_home) + handled=1 + ;;& + + "--install-android-tools" | "--install-all") + install_functions+=( + find_java_home + install_android_sdk_manager # Needed by install_android_build_tools + install_android_tools + ) + apt_packages+=(openjdk-$ANDROID_SDK_JAVA_VERSION-jre openjdk-$ANDROID_SDK_JAVA_VERSION-jdk) + pacman_packages+=(jre$ANDROID_SDK_JAVA_VERSION-openjdk jdk$ANDROID_SDK_JAVA_VERSION-openjdk) + handled=1 + ;;& + + # Not part of --install-all since that is already satisfied by + # --install-android-tools The advantage of that method is that it does not + # require the Java JDK/JRE to be installed, and is a bit quicker. However, + # it will not provide the build-tools which are needed by devlib. + "--install-android-platform-tools") + install_functions+=(install_android_platform_tools) handled=1 ;;& @@ -301,6 +400,14 @@ ordered_functions=( # pre-requisites are there install_apt install_pacman + + find_java_home + # cleanup must be done BEFORE installing + cleanup_android_home + install_android_sdk_manager # Needed by install_android_build_tools + install_android_tools + install_android_platform_tools + register_pip_extra_requirements ) @@ -324,9 +431,7 @@ for _func in "${ordered_functions[@]}"; do fi done done -[[ ${ret} == 0 ]] || exit ${ret} -"${LISA_HOME}/external/devlib/tools/android/setup_host.sh" "${devlib_params[@]}" -exit $? +exit $ret # vim: set tabstop=4 shiftwidth=4 textwidth=80 expandtab: -- GitLab