monado/.gitlab-ci/templates/install-android-sdk.sh.jinja

48 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# Copyright 2022, Collabora, Ltd. and the Monado contributors
# SPDX-License-Identifier: BSL-1.0
#{# ignore the warning, this is actually the template to edit. #}#
#######################################################
# GENERATED - DO NOT EDIT #
# see .gitlab-ci/install-android-sdk.sh.jinja instead #
#######################################################
#{#
Please run the following after editing:
make -f .gitlab-ci/ci-scripts.mk
#}#
# Partially inspired by https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/
{% for distro in distributions -%} {%- for image in distro.images if "android_compile_sdk" in image %}
set -eo pipefail
VERSION={{image.android_cli_tools}}
ROOT=${ROOT:-/opt/android-sdk}
ANDROID_COMPILE_SDK=${ANDROID_COMPILE_SDK:-{{image.android_compile_sdk}}}
ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-{{image.android_build_tools}}}
mkdir -p "$ROOT"
FN=commandlinetools-linux-${VERSION}_latest.zip
wget https://dl.google.com/android/repository/$FN
unzip $FN -d "$ROOT/extract"
mkdir -p "$ROOT/cmdline-tools"
mv "$ROOT/extract/cmdline-tools/" "$ROOT/cmdline-tools/latest/"
mv "$ROOT/extract/" "$ROOT/cmdline-tools/"
SDKMANAGER=$ROOT/cmdline-tools/latest/bin/sdkmanager
echo "Installing the Android compile SDK platform android-${ANDROID_COMPILE_SDK}"
echo y | $SDKMANAGER "platforms;android-${ANDROID_COMPILE_SDK}" >> /dev/null
echo "Installing the Android platform tools"
echo y | $SDKMANAGER "platform-tools" >> /dev/null
echo "Installing the Android build tools ${ANDROID_BUILD_TOOLS}"
echo y | $SDKMANAGER "build-tools;${ANDROID_BUILD_TOOLS}" >> /dev/null
set +o pipefail
yes | $SDKMANAGER --licenses
set -o pipefail
{% endfor -%} {%- endfor %}