#!/bin/sh # Build the OxygenFlow Android image and write it as a root file system # tarball for `flow rootfs import` (oxygenflow#19). Run from any directory; # the app is expected next to this repository (../oxygenhub-android), with # its subrepos checked out. Rebuild when the app's SDK, NDK, Gradle or # dependency versions change, or rust-core's Cargo.lock does. set -eu here=$(cd "$(dirname "$0")" && pwd) dev=$(cd "$here/../../.." && pwd) app="$dev/oxygenhub-android" out=${1:-$here/oxygenflow-android.tar} # Command-line tools 23.0, as Google's repository2-3.xml lists them. CMDLINE_TOOLS=commandlinetools-linux-16111833_latest.zip CMDLINE_TOOLS_SHA1=e025545c62a8e64c7559119566a569fb1dec5f60 GRADLE_VERSION=9.6.0 mkdir -p "$here/dl" if [ ! -f "$here/dl/cmdline-tools.zip" ]; then curl -fsSL "https://dl.google.com/android/repository/$CMDLINE_TOOLS" -o "$here/dl/cmdline-tools.zip" fi echo "$CMDLINE_TOOLS_SHA1 $here/dl/cmdline-tools.zip" | sha1sum -c - >/dev/null if [ ! -f "$here/dl/gradle.zip" ]; then curl -fsSL "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip" -o "$here/dl/gradle.zip" fi # Gradle publishes each distribution's SHA-256 beside it. want=$(curl -fsSL "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip.sha256") echo "$want $here/dl/gradle.zip" | sha256sum -c - >/dev/null # The app, without build output, and rust-core's crates vendored. rm -rf "$here/app" "$here/vendor" mkdir -p "$here/app" tar -C "$app" --exclude='./build' --exclude='./app/build' --exclude='./rust-core/target' \ --exclude='./.gradle' --exclude='./.oxy' --exclude='./local.properties' -cf - . | tar -C "$here/app" -xf - cargo vendor --locked --versioned-dirs --manifest-path "$app/rust-core/Cargo.toml" "$here/vendor" >/dev/null chmod -R a+rX "$here/vendor" "$here/app" docker build -q -t oxygenflow-android --build-arg GRADLE_VERSION=$GRADLE_VERSION "$here" id=$(docker create oxygenflow-android) docker export "$id" -o "$out" docker rm "$id" >/dev/null rm -rf "${here:?}/app" "${here:?}/vendor" echo "$out"