diff options
| author | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-01-01 00:00:00 +0000 |
| commit | 7e04941bccb2683f8a6e3ee38a99c50129234dd1 (patch) | |
| tree | 471227fa437291e7a6b499e3de6c106c54eaf311 /ci/setup-toolchain.sh | |
| download | rsend-7e04941bccb2683f8a6e3ee38a99c50129234dd1.tar.gz | |
rsend: push phone folders to a home SSH host over rsync
A small Android app for one-way folder backup, a KISS alternative to
Syncthing. It bundles rsync (built from pinned source via the NDK) and
a pure-Go SSH transport, both shipped in the APK as lib*.so and run from
the native library directory.
rsend pins the host key, stores the ed25519 identity Keystore-encrypted,
pushes each folder additively or as a mirror, and runs on demand or on a
WiFi-only schedule. The build is self-contained and reproducible: make
setup provisions the toolchain, make builds rsync, rsh, and the APK.
Diffstat (limited to 'ci/setup-toolchain.sh')
| -rwxr-xr-x | ci/setup-toolchain.sh | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ci/setup-toolchain.sh b/ci/setup-toolchain.sh new file mode 100755 index 0000000..c832708 --- /dev/null +++ b/ci/setup-toolchain.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Provision the pinned Android build toolchain into TOOLCHAIN_DIR (default +# $HOME/toolchains): JDK 17, Android cmdline-tools, SDK platform, build-tools, +# NDK, and Gradle. Idempotent: re-running only fills what is missing. Writes an +# env.sh to source before building. This is what CI runs to get a build host. +set -eu + +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +. "$root/versions" + +dir=${TOOLCHAIN_DIR:-$HOME/toolchains} +sdk="$dir/android-sdk" +mkdir -p "$dir/dl" + +# JDK 17 (Temurin). +if [ ! -x "$dir/jdk17/bin/java" ]; then + echo "setup: JDK $JDK_VERSION" + curl -fsSL "https://api.adoptium.net/v3/binary/latest/${JDK_VERSION}/ga/linux/x64/jdk/hotspot/normal/eclipse" -o "$dir/dl/jdk.tar.gz" + mkdir -p "$dir/jdk17" + tar xzf "$dir/dl/jdk.tar.gz" -C "$dir/jdk17" --strip-components=1 +fi +export JAVA_HOME="$dir/jdk17" +export PATH="$JAVA_HOME/bin:$PATH" + +# Android cmdline-tools. +if [ ! -x "$sdk/cmdline-tools/latest/bin/sdkmanager" ]; then + echo "setup: cmdline-tools $ANDROID_CMDLINE_TOOLS" + curl -fsSL "https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_TOOLS}_latest.zip" -o "$dir/dl/clt.zip" + rm -rf "$dir/dl/clt" + python3 -m zipfile -e "$dir/dl/clt.zip" "$dir/dl/clt" + mkdir -p "$sdk/cmdline-tools" + rm -rf "$sdk/cmdline-tools/latest" + mv "$dir/dl/clt/cmdline-tools" "$sdk/cmdline-tools/latest" + chmod +x "$sdk/cmdline-tools/latest/bin/"* +fi + +# SDK packages. +echo "setup: sdk packages" +yes | "$sdk/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null 2>&1 || true +"$sdk/cmdline-tools/latest/bin/sdkmanager" \ + "platform-tools" \ + "platforms;android-${ANDROID_PLATFORM}" \ + "build-tools;${ANDROID_BUILD_TOOLS}" \ + "ndk;${ANDROID_NDK}" >/dev/null + +# Gradle. +if [ ! -x "$dir/gradle-${GRADLE_VERSION}/bin/gradle" ]; then + echo "setup: Gradle $GRADLE_VERSION" + curl -fsSL "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" -o "$dir/dl/gradle.zip" + python3 -m zipfile -e "$dir/dl/gradle.zip" "$dir" + chmod +x "$dir/gradle-${GRADLE_VERSION}/bin/gradle" +fi + +# Go (pinned; builds rsh). +if [ ! -x "$dir/go/bin/go" ]; then + echo "setup: Go $GO_VERSION" + curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o "$dir/dl/go.tar.gz" + rm -rf "$dir/go" + tar xzf "$dir/dl/go.tar.gz" -C "$dir" +fi + +# Emit the env to source before building. +cat > "$dir/env.sh" <<EOF +export JAVA_HOME="$dir/jdk17" +export GOROOT="$dir/go" +export ANDROID_HOME="$sdk" +export ANDROID_SDK_ROOT="$sdk" +export ANDROID_NDK_HOME="$sdk/ndk/${ANDROID_NDK}" +export GRADLE_HOME="$dir/gradle-${GRADLE_VERSION}" +export PATH="\$JAVA_HOME/bin:$dir/go/bin:\$GRADLE_HOME/bin:$sdk/cmdline-tools/latest/bin:$sdk/platform-tools:\$PATH" +EOF + +echo "setup: done; source $dir/env.sh" |