-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Richard Cunningham
committed
Nov 21, 2024
1 parent
d5429c2
commit 6d933bb
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
.devcontainer/features/stolen4test/devcontainer-feature.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "Pinched Android SDK", | ||
"id": "stolen-android-sdk", | ||
"version": "1.2.0", | ||
"description": "Stolen for testing feature publishing.", | ||
"containerEnv": { | ||
"ANDROID_HOME": "/usr/local/lib/android", | ||
"ANDROID_SDK_ROOT": "$ANDROID_HOME", | ||
"PATH": "$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools" | ||
}, | ||
"options": { | ||
"platform": { | ||
"type": "string", | ||
"default": "34", | ||
"description": "SDK platform version" | ||
}, | ||
"build_tools": { | ||
"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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
set -e | ||
set +H | ||
|
||
URL_SDK="https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip" | ||
|
||
# Options. | ||
if [ -z "$PLATFORM" ]; then | ||
PLATFORM="34" | ||
fi | ||
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 usbutils && | ||
apt clean | ||
|
||
# Prepare install folder. | ||
mkdir -p "$ANDROID_HOME" | ||
chown -R "$_REMOTE_USER:$_REMOTE_USER" "$ANDROID_HOME" | ||
|
||
su - "$_REMOTE_USER" | ||
|
||
cd $ANDROID_HOME | ||
|
||
wget -q "$URL_SDK" -O sdk.zip | ||
unzip sdk.zip | ||
rm sdk.zip | ||
|
||
mkdir -p $ANDROID_HOME/cmdline-tools/latest | ||
cd $ANDROID_HOME/cmdline-tools | ||
shopt -s extglob dotglob | ||
mv !(latest) latest | ||
shopt -u dotglob | ||
|
||
cd $ANDROID_HOME | ||
|
||
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin" | ||
|
||
# Save original JAVA_HOME. | ||
OG_JAVA_HOME=$JAVA_HOME | ||
|
||
# thanks https://askubuntu.com/questions/772235/how-to-find-path-to-java#comment2258200_1029326. | ||
export JAVA_HOME=$(dirname $(dirname $(update-alternatives --list javac 2>&1 | head -n 1))) | ||
|
||
# TODO: Update everything to future-proof for the link getting stale. | ||
# yes | sdkmanager "cmdline-tools;latest" | ||
# Download the platform tools. | ||
yes | sdkmanager "${PACKAGES[@]}" | ||
|
||
# Restore JAVA_HOME. | ||
export JAVA_HOME=$OG_JAVA_HOME | ||
|
||
# Make sure the Android SDK has the correct permissions. | ||
sudo chown -R "$_REMOTE_USER:$_REMOTE_USER" "$ANDROID_HOME" | ||
|
||
# Exist subshell. | ||
exit |