diff --git a/images/linux/scripts/installers/android.sh b/images/linux/scripts/installers/android.sh index 3c44f86dc..4b292d3f7 100644 --- a/images/linux/scripts/installers/android.sh +++ b/images/linux/scripts/installers/android.sh @@ -50,8 +50,24 @@ mkdir -p ${ANDROID_SDK_ROOT} # Download the latest command line tools so that we can accept all of the licenses. # See https://developer.android.com/studio/#command-tools +cmdlineToolsVersion=$(get_toolset_value '.android."cmdline-tools"') +if [[ $cmdlineToolsVersion == "latest" ]]; then + repositoryXmlUrl="https://dl.google.com/android/repository/repository2-1.xml" + download_with_retries $repositoryXmlUrl "/tmp" "repository2-1.xml" + cmdlineToolsVersion=$( + yq -p=xml \ + '.sdk-repository.remotePackage[] | select(."+path" == "cmdline-tools;latest").archives.archive[].complete.url | select(contains("commandlinetools-linux"))' \ + /tmp/repository2-1.xml + ) + + if [[ -z $cmdlineToolsVersion ]]; then + echo "Failed to parse latest command-line tools version" + exit 1 + fi +fi + cmdlineTools="android-cmdline-tools.zip" -download_with_retries https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip "." $cmdlineTools +download_with_retries "https://dl.google.com/android/repository/${cmdlineToolsVersion}" "." $cmdlineTools unzip -qq $cmdlineTools -d ${ANDROID_SDK_ROOT}/cmdline-tools # Command line tools need to be placed in ${ANDROID_SDK_ROOT}/sdk/cmdline-tools/latest to determine SDK root mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 0e914d720..ba9bbcb84 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -86,6 +86,7 @@ "maven": "3.8.5" }, "android": { + "cmdline-tools": "latest", "platform_min_version": "23", "build_tools_min_version": "23.0.1", "extra_list": [ diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 0c5b19f99..92acdeca3 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -87,6 +87,7 @@ "maven": "3.8.5" }, "android": { + "cmdline-tools": "latest", "platform_min_version": "27", "build_tools_min_version": "27.0.0", "extra_list": [ diff --git a/images/linux/toolsets/toolset-2204.json b/images/linux/toolsets/toolset-2204.json index 8bea46597..2477ee697 100644 --- a/images/linux/toolsets/toolset-2204.json +++ b/images/linux/toolsets/toolset-2204.json @@ -73,6 +73,7 @@ "maven": "3.8.5" }, "android": { + "cmdline-tools": "latest", "platform_min_version": "27", "build_tools_min_version": "27.0.0", "extra_list": [ diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index bdd5847ab..1f64a3365 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -242,8 +242,8 @@ "{{template_dir}}/scripts/installers/vcpkg.sh", "{{template_dir}}/scripts/installers/dpkg-config.sh", "{{template_dir}}/scripts/installers/mongodb.sh", - "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/yq.sh", + "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/pypy.sh", "{{template_dir}}/scripts/installers/python.sh", "{{template_dir}}/scripts/installers/aws.sh" diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index ee9fb00f7..7c386927e 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -243,8 +243,8 @@ "{{template_dir}}/scripts/installers/vcpkg.sh", "{{template_dir}}/scripts/installers/dpkg-config.sh", "{{template_dir}}/scripts/installers/mongodb.sh", - "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/yq.sh", + "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/pypy.sh", "{{template_dir}}/scripts/installers/python.sh", "{{template_dir}}/scripts/installers/graalvm.sh" diff --git a/images/linux/ubuntu2204.pkr.hcl b/images/linux/ubuntu2204.pkr.hcl index 22c5ae652..570629ed9 100644 --- a/images/linux/ubuntu2204.pkr.hcl +++ b/images/linux/ubuntu2204.pkr.hcl @@ -313,8 +313,8 @@ build { "${path.root}/scripts/installers/packer.sh", "${path.root}/scripts/installers/vcpkg.sh", "${path.root}/scripts/installers/dpkg-config.sh", - "${path.root}/scripts/installers/android.sh", "${path.root}/scripts/installers/yq.sh", + "${path.root}/scripts/installers/android.sh", "${path.root}/scripts/installers/pypy.sh", "${path.root}/scripts/installers/python.sh", "${path.root}/scripts/installers/graalvm.sh"