OXYGENHUB
# 060d459ff6c6 oxygenflow / images / android / build.sh
2.0 KiB · Bourne Again Shell (bash) · executable · last changed The Android image: JDK, SDK, NDK, Gradle and the app's dependencies, offline (closes #19) 10 days ago source blame history raw
1
#!/bin/sh
2
# Build the OxygenFlow Android image and write it as a root file system
3
# tarball for `flow rootfs import` (oxygenflow#19). Run from any directory;
4
# the app is expected next to this repository (../oxygenhub-android), with
5
# its subrepos checked out. Rebuild when the app's SDK, NDK, Gradle or
6
# dependency versions change, or rust-core's Cargo.lock does.
7
set -eu
8
here=$(cd "$(dirname "$0")" && pwd)
9
dev=$(cd "$here/../../.." && pwd)
10
app="$dev/oxygenhub-android"
11
out=${1:-$here/oxygenflow-android.tar}
12
# Command-line tools 23.0, as Google's repository2-3.xml lists them.
13
CMDLINE_TOOLS=commandlinetools-linux-16111833_latest.zip
14
CMDLINE_TOOLS_SHA1=e025545c62a8e64c7559119566a569fb1dec5f60
15
GRADLE_VERSION=9.6.0
16
17
mkdir -p "$here/dl"
18
if [ ! -f "$here/dl/cmdline-tools.zip" ]; then
19
    curl -fsSL "https://dl.google.com/android/repository/$CMDLINE_TOOLS" -o "$here/dl/cmdline-tools.zip"
20
fi
21
echo "$CMDLINE_TOOLS_SHA1  $here/dl/cmdline-tools.zip" | sha1sum -c - >/dev/null
22
if [ ! -f "$here/dl/gradle.zip" ]; then
23
    curl -fsSL "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip" -o "$here/dl/gradle.zip"
24
fi
25
# Gradle publishes each distribution's SHA-256 beside it.
26
want=$(curl -fsSL "https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip.sha256")
27
echo "$want  $here/dl/gradle.zip" | sha256sum -c - >/dev/null
28
29
# The app, without build output, and rust-core's crates vendored.
30
rm -rf "$here/app" "$here/vendor"
31
mkdir -p "$here/app"
32
tar -C "$app" --exclude='./build' --exclude='./app/build' --exclude='./rust-core/target' \
33
    --exclude='./.gradle' --exclude='./.oxy' --exclude='./local.properties' -cf - . | tar -C "$here/app" -xf -
34
cargo vendor --locked --versioned-dirs --manifest-path "$app/rust-core/Cargo.toml" "$here/vendor" >/dev/null
35
chmod -R a+rX "$here/vendor" "$here/app"
36
docker build -q -t oxygenflow-android --build-arg GRADLE_VERSION=$GRADLE_VERSION "$here"
37
id=$(docker create oxygenflow-android)
38
docker export "$id" -o "$out"
39
docker rm "$id" >/dev/null
40
rm -rf "${here:?}/app" "${here:?}/vendor"
41
echo "$out"