79 lines
2.7 KiB
Bash
Executable file
79 lines
2.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
# get configuration
|
|
source app-config.sh
|
|
|
|
|
|
# in case needed download and install `sdkmanager`
|
|
type sdkmanager 2>/dev/null || (
|
|
BUILD_TOOLS="$(realpath -m "$BUILD_TOOLS_LATEST/..")"
|
|
mkdir -p "$BUILD_TOOLS"
|
|
cd "$BUILD_TOOLS"
|
|
for LATESTTOOLS in \
|
|
"$(curl 'https://developer.android.com/studio#command-line-tools-only' |
|
|
grep -e 'https://dl.google.com/android/repository/commandlinetools-linux-.*_latest.zip' | cut -f2 -d'"')" \
|
|
'https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip'
|
|
do
|
|
echo "testing to get '$LATESTTOOLS'"
|
|
echo test "${LATESTTOOLS:0:22}" = "https://dl.google.com/" -a "${LATESTTOOLS:(-11)}" = "_latest.zip"
|
|
test "${LATESTTOOLS:0:22}" = "https://dl.google.com/" -a "${LATESTTOOLS:(-11)}" = "_latest.zip" || {
|
|
echo "unsure of URL $LATESTTOOLS correct, skipping it..." >&2
|
|
continue;
|
|
}
|
|
wget -O cmdline-tools.zip "$LATESTTOOLS"
|
|
unzip cmdline-tools.zip && break || {
|
|
echo "error downloading working cmdline-tools.zip"
|
|
exit 1
|
|
}
|
|
done
|
|
ls
|
|
ls cmdline-tools
|
|
rm cmdline-tools.zip
|
|
mv -v cmdline-tools "$BUILD_TOOLS_LATEST" || true
|
|
)
|
|
|
|
test -f android-sdk/.installed.buildtools.version.$APP_VERSION_SDK_TARGET || {
|
|
EXACTVERSION_BUILDTOOLS="$(
|
|
sdkmanager --list 2>/dev/null |
|
|
sed 's/^ *//' |
|
|
grep -e 'build-tools;'"$APP_VERSION_SDK_TARGET"'\.[0-9]*\.[0-9]*\ ' |
|
|
cut -f1 -d' ' |
|
|
sort |
|
|
tail -n 1
|
|
)"
|
|
test -z "$EXACTVERSION_BUILDTOOLS" && {
|
|
echo "ERROR cannot get '$EXACTVERSION_BUILDTOOLS'" >&2
|
|
echo "dropping to shell..." >&2
|
|
exec bash
|
|
}
|
|
sdkmanager --list_installed | grep -q "$EXACTVERSION_BUILDTOOLS" || {
|
|
sdkmanager --install "$EXACTVERSION_BUILDTOOLS"
|
|
}
|
|
echo "$EXACTVERSION_BUILDTOOLS" > android-sdk/.installed.buildtools.version.$APP_VERSION_SDK_TARGET
|
|
ln -rvsf android-sdk/.installed.buildtools.version.{$APP_VERSION_SDK_TARGET,current}
|
|
}
|
|
|
|
test -f android-sdk/.installed.platforms.version.$APP_VERSION_SDK_TARGET || {
|
|
EXACTVERSION_PLATFORM="$(
|
|
sdkmanager --list 2>/dev/null |
|
|
sed 's/^ *//' |
|
|
grep -e 'platforms;android-'"$APP_VERSION_SDK_TARGET"'\ ' |
|
|
cut -f1 -d' ' |
|
|
sort |
|
|
tail -n 1
|
|
)"
|
|
test -z "$EXACTVERSION_PLATFORM" && {
|
|
echo "ERROR cannot get '$EXACTVERSION_PLATFORM'" >&2
|
|
echo "dropping to shell..." >&2
|
|
exec bash
|
|
}
|
|
sdkmanager --list_installed | grep -q "$EXACTVERSION_PLATFORM" || {
|
|
sdkmanager --install "$EXACTVERSION_PLATFORM"
|
|
}
|
|
echo "$EXACTVERSION_PLATFORM" > android-sdk/.installed.platforms.version.$APP_VERSION_SDK_TARGET
|
|
ln -rvsf android-sdk/.installed.platforms.version.{$APP_VERSION_SDK_TARGET,current}
|
|
}
|
|
|
|
touch android-sdk/installed
|