This commit is contained in:
Mateusz Gruszczyński committed 2026-11-17 16:47:14 +01:00
commit 4cb9717db2
97 files changed
+5946

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#!/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"
+18
View File
@@ -0,0 +1,18 @@
# Build environment for simply-tv: JDK 17 + Android SDK (platform 34) + Gradle.
FROM eclipse-temurin:17-jdk-jammy
ARG CMDLINE_TOOLS=11076708
ARG GRADLE=8.14.3
ENV ANDROID_HOME=/opt/android-sdk \
GRADLE_HOME=/opt/gradle \
PATH=/opt/gradle/bin:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/platform-tools:$PATH
RUN apt-get update && apt-get install -y --no-install-recommends curl unzip ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p $ANDROID_HOME/cmdline-tools \
&& curl -fsSL -o /tmp/clt.zip https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS}_latest.zip \
&& unzip -q /tmp/clt.zip -d $ANDROID_HOME/cmdline-tools && mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest \
&& rm /tmp/clt.zip \
&& yes | sdkmanager --licenses >/dev/null \
&& sdkmanager "platforms;android-34" "build-tools;34.0.0" "platform-tools" >/dev/null \
&& curl -fsSL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE}-bin.zip \
&& unzip -q /tmp/gradle.zip -d /opt && mv /opt/gradle-${GRADLE} /opt/gradle && rm /tmp/gradle.zip
WORKDIR /src
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Installs (or updates) simply-tv on the TV over the network with adb.
#
# scripts/install-tv.sh 192.168.1.50 # newest dist/simply-tv-*.apk
# scripts/install-tv.sh 192.168.1.50 file.apk
#
# On the TV first: Settings → System → About → press "Build" 7 times (developer mode),
# then Settings → System → Developer options → "Network debugging" (or "USB debugging") on.
# On the first connection the TV asks to allow this computer – choose "Always allow".
# adb runs in the builder container when it is not installed on the host.
set -euo pipefail
cd "$(dirname "$0")/.."
TV="${1:?usage: $0 <tv-address> [apk]}"
APK="${2:-$(ls -t dist/simply-tv-*.apk 2>/dev/null | head -1)}"
[ -f "$APK" ] || { echo "no APK – run scripts/build-apk.sh first" >&2; exit 1; }
case "$TV" in *:*) ;; *) TV="$TV:5555" ;; esac
STEPS="adb connect $TV && sleep 2 && adb -s $TV install -r '$APK' && adb -s $TV shell am start -n io.simplydvb.tv/.ui.MainActivity"
echo ">> connecting to $TV (confirm on the TV if asked) and installing $APK"
if command -v adb >/dev/null 2>&1; then
bash -c "$STEPS"
else
# one container for all steps (the adb server lives as long as the container)
docker run --rm --network host -v "$PWD":/src -v simply-tv-adb:/root/.android \
"${BUILDER_IMAGE:-simply-tv-builder:1}" bash -c "$STEPS"
fi
echo ">> done – simply-tv is open on the TV"