add gitignore; dev build-android-app.sh

This commit is contained in:
Alexander Mahr 2024-12-25 09:59:34 +01:00
parent 037828ba3c
commit 3213741d5c
2 changed files with 35 additions and 6 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/Dockerfile

View file

@ -23,11 +23,39 @@ do
done
DockerfileContent(){
cat << DOCKERFILEEOF
cat << 'DOCKERFILEEOF'
FROM debian:latest
RUN apt-get update -y && apt-get install -y make
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/
COPY --from=docker:cli /usr/local/libexec/docker /usr/local/libexec/docker
ARG YESACCEPT=n
RUN test "$YESACCEPT" = "y" || { printf "\033[31;1;4m%s\n%s\033[0m " "FAILED TO BUILD CONTAINER: You did not ACCEPT THE UPSTREAM LICENSE" " -> export YESACCEPT=y" >&2; exit 1; }
RUN apt-get update -y && apt-get install -y make openjdk-17-jdk-headless unzip zip wget curl
ENV ANDROID_SDK_ROOT="/opt/android"
ENV BUILD_TOOLS_LATEST="$ANDROID_SDK_ROOT/cmdline-tools/latest"
SHELL ["/bin/bash", "-c"]
RUN BUILD_TOOLS="$(realpath -m "$BUILD_TOOLS_LATEST/..")";\
mkdir -p "$BUILD_TOOLS";\
cd "$BUILD_TOOLS";\
pwd;\
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
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"
DOCKERFILEEOF
}
@ -39,7 +67,7 @@ diff Dockerfile <(DockerfileContent) 2>/dev/null > /dev/null || {
IMAGE=android-app:"$($HASH Dockerfile | tr -cd '[a-zA-Z0-9]' | head -c 12)"
$CONTAINERRUNTIME build --tag "$IMAGE" .
$CONTAINERRUNTIME build --build-arg YESACCEPT="$YESACCEPT" --tag "$IMAGE" .
SOCKET="$($CONTAINERRUNTIME context inspect | grep '"Host":' | cut -d'"' -f4)"
test "${SOCKET:0:8}" = "unix:///" || {
@ -47,5 +75,5 @@ test "${SOCKET:0:8}" = "unix:///" || {
exit 4
}
$CONTAINERRUNTIME run -v "${SOCKET:7}":"/var/run/docker.sock" -it --rm "$IMAGE"
$CONTAINERRUNTIME run -e YESACCEPT="$YESACCEPT" -v "${SOCKET:7}":"/var/run/docker.sock" -it --rm "$IMAGE"