From 8a71d03710d645c18e93f3cbca9cc2b9612f5f7d Mon Sep 17 00:00:00 2001 From: hellodword <46193371+hellodword@users.noreply.github.com> Date: Mon, 5 Feb 2024 08:06:10 +0000 Subject: [PATCH] android-sdk: fix options add usbutils enable custom sdkmanager packages --- src/android-sdk/devcontainer-feature.json | 10 ++++++++++ src/android-sdk/install.sh | 17 ++++++++++++----- test/android-sdk/scenarios.json | 3 ++- test/android-sdk/specific_sdk.sh | 1 + test/android-sdk/test.sh | 1 + 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/android-sdk/devcontainer-feature.json b/src/android-sdk/devcontainer-feature.json index 88134aa..3dc7e75 100644 --- a/src/android-sdk/devcontainer-feature.json +++ b/src/android-sdk/devcontainer-feature.json @@ -18,6 +18,16 @@ "type": "string", "default": "34.0.0", "description": "SDK build-tools version" + }, + "base_packages": { + "type": "string", + "default": "", + "description": "packages will override default packages, split by space" + }, + "extra_packages": { + "type": "string", + "default": "", + "description": "extra packages, split by space" } }, "installsAfter": ["ghcr.io/devcontainers/features/common-utils", "ghcr.io/akhildevelops/devcontainer-features/apt"] diff --git a/src/android-sdk/install.sh b/src/android-sdk/install.sh index 9ddd916..c87ee37 100755 --- a/src/android-sdk/install.sh +++ b/src/android-sdk/install.sh @@ -5,17 +5,24 @@ set +H URL_SDK="https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip" # Options. -PLATFORM=$platform -if [ -z "$PLATFORMS" ]; then +if [ -z "$PLATFORM" ]; then PLATFORM="34" fi -BUILD_TOOLS=$build_tools if [ -z "$BUILD_TOOLS" ]; then BUILD_TOOLS="34.0.0" fi +if [ -n "$BASE_PACKAGES" ]; then + IFS=' ' read -ra PACKAGES <<< "$BASE_PACKAGES" +else + PACKAGES=( "platform-tools" "platforms;android-$PLATFORM" "build-tools;$BUILD_TOOLS" ) +fi +if [ -n "$EXTRA_PACKAGES" ]; then + IFS=' ' read -ra extra <<< "$EXTRA_PACKAGES" + PACKAGES=("${PACKAGES[@]}" "${extra[@]}") +fi DEBIAN_FRONTEND="noninteractive" sudo apt update && - sudo apt install --no-install-recommends -y openjdk-17-jdk-headless unzip wget && + sudo apt install --no-install-recommends -y openjdk-17-jdk-headless unzip wget usbutils && apt clean # Prepare install folder. @@ -49,7 +56,7 @@ export JAVA_HOME=$(dirname $(dirname $(update-alternatives --list javac 2>&1 | h # TODO: Update everything to future-proof for the link getting stale. # yes | sdkmanager "cmdline-tools;latest" # Download the platform tools. -yes | sdkmanager "platform-tools" "platforms;android-$PLATFORM" "build-tools;$BUILD_TOOLS" +yes | sdkmanager "${PACKAGES[@]}" # Restore JAVA_HOME. export JAVA_HOME=$OG_JAVA_HOME diff --git a/test/android-sdk/scenarios.json b/test/android-sdk/scenarios.json index 397a382..a979fae 100644 --- a/test/android-sdk/scenarios.json +++ b/test/android-sdk/scenarios.json @@ -3,7 +3,8 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "android-sdk": { - "platform": "32" + "platform": "32", + "extra_packages": "ndk;25.2.9519653 sources;android-32" } } } diff --git a/test/android-sdk/specific_sdk.sh b/test/android-sdk/specific_sdk.sh index 0d2f2ae..996b0da 100755 --- a/test/android-sdk/specific_sdk.sh +++ b/test/android-sdk/specific_sdk.sh @@ -4,5 +4,6 @@ set -e source dev-container-features-test-lib check "execute command" bash -c "adb --version" +check "execute command" bash -c "sdkmanager --list_installed" reportResults diff --git a/test/android-sdk/test.sh b/test/android-sdk/test.sh index 0d2f2ae..996b0da 100755 --- a/test/android-sdk/test.sh +++ b/test/android-sdk/test.sh @@ -4,5 +4,6 @@ set -e source dev-container-features-test-lib check "execute command" bash -c "adb --version" +check "execute command" bash -c "sdkmanager --list_installed" reportResults