summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2023-03-01 17:24:09 +0100
committerLinus Färnstrand <faern@faern.net>2023-03-02 15:37:09 +0100
commit50d0d867c6f806d98f86daa165e283a519279494 (patch)
treea70b20d1a2a0dfa69f8b5767d86506e1c438dd44
parentaf57d5496456e05f4f73db5ca884896faeed9d42 (diff)
downloadmullvadvpn-50d0d867c6f806d98f86daa165e283a519279494.tar.xz
mullvadvpn-50d0d867c6f806d98f86daa165e283a519279494.zip
Build Linux builds in container
-rwxr-xr-xci/buildserver-build.sh62
1 files changed, 43 insertions, 19 deletions
diff --git a/ci/buildserver-build.sh b/ci/buildserver-build.sh
index 38e3f70ded..f631bc6903 100755
--- a/ci/buildserver-build.sh
+++ b/ci/buildserver-build.sh
@@ -63,6 +63,33 @@ upload() {
esac
}
+
+# Run the arguments in an environment suitable for building the app. This
+# means in a container on Linux, and straight up in the local shell elsewhere.
+run_in_build_env() {
+ if [[ "$(uname -s)" == "Linux" ]]; then
+ ./building/container-run.sh linux "$@"
+ else
+ bash -c "$*"
+ fi
+}
+
+# Builds the app and test artifacts and move them to the passed in `artifact_dir`.
+# To cross compile pass in `target` as an environment variable
+# to this function. Must also pass `artifact_dir` to show where to move the built artifacts.
+# Pass all the build arguments as arguments to this function
+build() {
+ local target=${target:-""}
+ local build_args=("${@}")
+
+ run_in_build_env TARGETS="$target" ./build.sh "${build_args[@]}" || return 1
+ mv dist/*.{deb,rpm,exe,pkg} "$artifact_dir" || return 1
+
+ (run_in_build_env gui/scripts/build-test-executable.sh "$target" && \
+ mv "dist/app-e2e-tests-$version"* "$artifact_dir") || \
+ true
+}
+
build_ref() {
ref=$1
tag=${2:-""}
@@ -97,22 +124,28 @@ build_ref() {
git submodule update
git clean -df
- # Make sure we have the latest Rust and Node toolchains before the build
- rustup update
+ if [[ "$(uname -s)" != "Linux" ]]; then
+ echo "Updating Rust toolchain..."
+ rustup update
+ fi
+
+ # podman appends a trailing carriage return to the output. So we use `tr` to strip it
+ local version=""
+ version="$(run_in_build_env cargo run -q --bin mullvad-version | tr -d "\r" || return 0)"
- version="$(cargo run -q --bin mullvad-version || return 0)"
- artifact_dir="dist/$version"
+ local artifact_dir="dist/$version"
mkdir -p "$artifact_dir"
- BUILD_ARGS=(--optimize --sign)
+ local build_args=(--optimize --sign)
if [[ "$(uname -s)" == "Darwin" ]]; then
- BUILD_ARGS+=(--universal)
+ build_args+=(--universal)
fi
- ./build.sh "${BUILD_ARGS[@]}" || return 0
- mv dist/*.{deb,rpm,exe,pkg} "$artifact_dir" || return 0
- (gui/scripts/build-test-executable.sh && mv "dist/app-e2e-tests-$version"* "$artifact_dir") || \
- true
+ artifact_dir=$artifact_dir build "${build_args[@]}" || return 0
+ if [[ "$(uname -s)" == "Linux" ]]; then
+ echo "Building ARM64 installers"
+ target=aarch64-unknown-linux-gnu artifact_dir=$artifact_dir build "${build_args[@]}" || return 0
+ fi
case "$(uname -s)" in
MINGW*|MSYS_NT*)
@@ -123,15 +156,6 @@ build_ref() {
./target/release/mullvad-problem-report.pdb \
-iname "*.pdb" | tar -cJf "$artifact_dir/pdb-$version.tar.xz" -T -
;;
- Linux*)
- echo "Building ARM64 installers"
- TARGETS=aarch64-unknown-linux-gnu ./build.sh "${BUILD_ARGS[@]}" || return 0
- mv dist/*.{deb,rpm} "$artifact_dir" || return 0
-
- (gui/scripts/build-test-executable.sh aarch64-unknown-linux-gnu && \
- mv "dist/app-e2e-tests-$version"* "$artifact_dir") || \
- true
- ;;
esac
# If there is a tag for this commit then we append that to the produced artifacts