Files
2026-11-17 16:47:14 +01:00

52 lines
2.3 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Builds simply-tv (Android TV app) into dist/simply-tv-<version>.apk.
#
# The build runs in Docker (image from scripts/docker/android.Dockerfile), the host only
# needs Docker. On the first build a signing key is created in keystore/ – keep it (and back
# it up): Android only accepts updates signed with the same key.
#
# BUILD_IN_DOCKER=0 build on the host (needs JDK 17, Android SDK in $ANDROID_HOME, gradle)
# BUILDER_IMAGE=... builder image name (default simply-tv-builder:1)
# DOCKER_ARGS="..." extra arguments for `docker run`
set -euo pipefail
cd "$(dirname "$0")/.."
IMAGE="${BUILDER_IMAGE:-simply-tv-builder:1}"
if [ -z "${SIMPLY_TV_IN_DOCKER:-}" ] && [ "${BUILD_IN_DOCKER:-1}" != 0 ]; then
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
echo ">> building the builder image $IMAGE (first time only, ~1.5 GB)"
docker build -t "$IMAGE" -f scripts/docker/android.Dockerfile scripts/docker
fi
exec docker run --rm \
-e SIMPLY_TV_IN_DOCKER=1 -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" \
-v "$PWD":/src -v simply-tv-gradle:/root/.gradle \
${DOCKER_ARGS:-} "$IMAGE" bash scripts/build-apk.sh "$@"
fi
# ---------------------------------------------------------------- signing key (once)
mkdir -p keystore
if [ ! -f keystore/keystore.properties ]; then
PASS="$(head -c 18 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 20)"
keytool -genkeypair -noprompt -keystore keystore/simply-tv.jks -alias simply-tv \
-keyalg RSA -keysize 3072 -validity 10000 -storepass "$PASS" -keypass "$PASS" \
-dname "CN=simply-tv, O=simply-dvb" >/dev/null
cat > keystore/keystore.properties <<PROPS
storeFile=keystore/simply-tv.jks
storePassword=$PASS
keyAlias=simply-tv
keyPassword=$PASS
PROPS
echo ">> created signing key keystore/simply-tv.jks – back it up together with keystore.properties"
fi
[ -f local.properties ] || echo "sdk.dir=${ANDROID_HOME:-/opt/android-sdk}" > local.properties
gradle --no-daemon -q :app:assembleRelease
VERSION="$(grep -m1 'versionName' app/build.gradle.kts | sed -E 's/.*"(.*)".*/\1/')"
mkdir -p dist
cp app/build/outputs/apk/release/app-release.apk "dist/simply-tv-$VERSION.apk"
if [ -n "${HOST_UID:-}" ]; then
chown -R "$HOST_UID:${HOST_GID:-$HOST_UID}" dist keystore app/build .gradle local.properties 2>/dev/null || true
fi
echo ">> dist/simply-tv-$VERSION.apk"