113 lines
4.1 KiB
Bash
Executable file
113 lines
4.1 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
|
|
}
|
|
|
|
test -f android-sdk/.installed.platform.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.platform.version.$APP_VERSION_SDK_TARGET
|
|
}
|
|
|
|
exec bash
|
|
|
|
#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
|
|
# )"
|
|
# sdkmanager list_installed | -q grep "$EXACTVERSION_BUILDTOOLS" || {
|
|
# sdkmanager --install "$EXACTVERSION_BUILDTOOLS"
|
|
# }
|
|
# touch android-sdk/.installed.buildtools.version.$APP_VERSION_SDK_TARGET
|
|
#}
|
|
|
|
#sdkmanager --list | grep build-tools | grep -v rc
|
|
|
|
#
|
|
#ENV PATH="$BUILD_TOOLS_LATEST/bin:$PATH"
|
|
##TODO make this automatic
|
|
#ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk/"
|
|
#ENV LIBRARY_PATH="$LIBRARY_PATH:$BUILD_TOOLS_LATEST/lib"
|
|
#RUN echo you selected to accept the licenses/TOS
|
|
#RUN echo "$YESACCEPT" | sdkmanager --install "build-tools;33.0.2"
|
|
#RUN echo "$YESACCEPT" | sdkmanager --install "platforms;android-33"
|
|
##RUN echo "$YESACCEPT" | sdkmanager --install "ndk;28.0.12433566"
|
|
##RUN echo "$YESACCEPT" | sdkmanager --install "system-images;android-33;aosp_atd;x86_64"
|
|
##RUN echo "$YESACCEPT" | sdkmanager --install "emulator"
|
|
##RUN echo "no" | avdmanager --verbose create avd --force --name "thedevice" --package 'system-images;android-33;aosp_atd;x86_64' --tag "aosp_atd" --abi "x86_64"
|
|
##RUN echo "$YESACCEPT" | sdkmanager --install "platform-tools"
|
|
#COPY entrypoint.sh /entrypoint.sh
|
|
#RUN chown 0:0 /entrypoint.sh
|
|
#RUN chmod 0700 /entrypoint.sh
|
|
#WORKDIR /apk
|
|
#ENTRYPOINT ["/entrypoint.sh"]
|
|
#RUN echo "$YESACCEPT" | tee yesaccept
|