Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[macos] move adnroid "cmdline-tools" to toolset
  • Loading branch information
ilia-shipitsin committed Oct 16, 2023
commit 85eba658949ff2404ca807550e4a0eb2a592d295
26 changes: 21 additions & 5 deletions images/macos/provision/core/android-toolsets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,37 @@ ANDROID_NDK_MAJOR_LATEST=$(get_toolset_value '.android.ndk."versions"[-1]')
# Get the latest command line tools from https://developer.android.com/studio#cmdline-tools
# Newer version(s) require Java 11 by default
# See https://github.com/actions/runner-images/issues/6960
ANDROID_OSX_SDK_URL="https://dl.google.com/android/repository/commandlinetools-mac-9123335_latest.zip"
ANDROID_HOME=$HOME/Library/Android/sdk
ANDROID_OSX_SDK_FILE=tools-macosx.zip

pushd $HOME
# 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" and .channelRef."+@ref" == "channel-0").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

echo "Downloading android command line tools..."
download_with_retries $ANDROID_OSX_SDK_URL "." $ANDROID_OSX_SDK_FILE
download_with_retries "https://dl.google.com/android/repository/${cmdlineToolsVersion}" /tmp $ANDROID_OSX_SDK_FILE

echo "Uncompressing android command line tools..."
mkdir -p $HOME/Library/Android/sdk
unzip -q $ANDROID_OSX_SDK_FILE -d $HOME/Library/Android/sdk/cmdline-tools
unzip -q /tmp/$ANDROID_OSX_SDK_FILE -d $HOME/Library/Android/sdk/cmdline-tools
# Command line tools need to be placed in $HOME/Library/Android/sdk/cmdline-tools/latest to function properly
mv $HOME/Library/Android/sdk/cmdline-tools/cmdline-tools $HOME/Library/Android/sdk/cmdline-tools/latest
rm -f $ANDROID_OSX_SDK_FILE
rm -f /tmp/$ANDROID_OSX_SDK_FILE

echo ANDROID_HOME is $ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin
Expand Down
1 change: 1 addition & 0 deletions images/macos/toolsets/toolset-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
}
},
"android": {
"cmdline-tools": "commandlinetools-mac-9123335_latest.zip",
"platform_min_version": "27",
"build_tools_min_version": "27.0.0",
"extra-list": [
Expand Down
1 change: 1 addition & 0 deletions images/macos/toolsets/toolset-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
}
},
"android": {
"cmdline-tools": "commandlinetools-mac-9123335_latest.zip",
"platform_min_version": "27",
"build_tools_min_version": "27.0.0",
"extra-list": [
Expand Down
1 change: 1 addition & 0 deletions images/macos/toolsets/toolset-13.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}
},
"android": {
"cmdline-tools": "commandlinetools-mac-9123335_latest.zip",
"platform_min_version": "27",
"build_tools_min_version": "27.0.0",
"extra-list": [
Expand Down