diff options
| author | Albin <albin@mullvad.net> | 2022-11-30 14:44:35 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2022-12-01 14:45:49 +0100 |
| commit | 32738ecae0f4cc2683698ecaf551583d8aef189d (patch) | |
| tree | b1c4a171ffab41c6cba64dd732c94a6c9b167e94 | |
| parent | 72814641a327f15d014b95dab178a5c4658dd05d (diff) | |
| download | mullvadvpn-32738ecae0f4cc2683698ecaf551583d8aef189d.tar.xz mullvadvpn-32738ecae0f4cc2683698ecaf551583d8aef189d.zip | |
Add containerized build script for android and linux
| -rwxr-xr-x | building/containerized-build.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/building/containerized-build.sh b/building/containerized-build.sh new file mode 100755 index 0000000000..d2386473cb --- /dev/null +++ b/building/containerized-build.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Builds the Android or Linux app in the current build container, as designated +# by the *-container-image.txt files. Uses podman unless overridden using the +# environment variable `CONTAINER_RUNNER`. Note that this script uses named +# docker volumes that can be overridden using enviornment variables (see the +# beginning of the script). + +set -eu + +REPO_MOUNT_TARGET="/build" +CARGO_TARGET_VOLUME_NAME=${CARGO_TARGET_VOLUME_NAME:-"cargo-target"} +CARGO_REGISTRY_VOLUME_NAME=${CARGO_REGISTRY_VOLUME_NAME:-"cargo-registry"} +GRADLE_CACHE_VOLUME_NAME=${GRADLE_CACHE_VOLUME_NAME:-"gradle-cache"} +CONTAINER_RUNNER=${CONTAINER_RUNNER:-"podman"} + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +REPO_DIR="$( cd "$SCRIPT_DIR/.." && pwd )" +cd "$SCRIPT_DIR" + +source "$REPO_DIR/scripts/utils/log" + +case ${1-:""} in + linux) + container_image_name=$(cat "$SCRIPT_DIR/linux-container-image.txt") + build_command=("$REPO_MOUNT_TARGET/build.sh") + shift 1 + ;; + android) + container_image_name=$(cat "$SCRIPT_DIR/android-container-image.txt") + build_command=("$REPO_MOUNT_TARGET/build-apk.sh" "--no-docker") + optional_gradle_cache_volume=(-v "$GRADLE_CACHE_VOLUME_NAME:/root/.gradle:Z") + shift 1 + ;; + *) + log_error "Invalid platform. Specify 'linux' or 'android' as first argument" + exit 1 +esac + +set -x +exec "$CONTAINER_RUNNER" run --rm -it \ + -v "$REPO_DIR:$REPO_MOUNT_TARGET:Z" \ + -v "$CARGO_TARGET_VOLUME_NAME:/root/.cargo/target:Z" \ + -v "$CARGO_REGISTRY_VOLUME_NAME:/root/.cargo/registry:Z" \ + "${optional_gradle_cache_volume[@]}" \ + "$container_image_name" \ + "${build_command[@]}" "$@" |
