summaryrefslogtreecommitdiffhomepage
path: root/building
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2025-01-23 17:50:06 +0100
committerKalle Lindström <karl.lindstrom@mullvad.net>2025-01-23 17:50:06 +0100
commit1a58706ffd5cb0702a1ba3281fd648deb9b6501e (patch)
tree48c607aeefc99a1b06a28dd786172eb695197ede /building
parentdfa29794bdc5e8f6211b3eaf6c5fd15a220265d2 (diff)
downloadmullvadvpn-1a58706ffd5cb0702a1ba3281fd648deb9b6501e.tar.xz
mullvadvpn-1a58706ffd5cb0702a1ba3281fd648deb9b6501e.zip
Add script to generate rustc --remap-path-prefix
This is needed for reproducible builds. The script gets the file paths to the user's Cargo and Rustup home dirs, as well as the path to the Mullvad app source dir. These paths are then remapped to fixed values which is needed to make the build reproducible.
Diffstat (limited to 'building')
-rwxr-xr-xbuilding/rustc-remap-path-prefix.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/building/rustc-remap-path-prefix.sh b/building/rustc-remap-path-prefix.sh
new file mode 100755
index 0000000000..0531d206e7
--- /dev/null
+++ b/building/rustc-remap-path-prefix.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+# Returns the rustc `--remap-path-prefix` flags needed to replace file paths
+# that gets put in the build artifacts with fixed values in order to make
+# the build reproducible across different machines.
+
+set -eu
+
+SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
+CARGO_HOME_PATH=${CARGO_HOME:-$HOME/.cargo}
+RUSTUP_HOME_PATH=${RUSTUP_HOME:-$HOME/.rustup}
+
+echo "--remap-path-prefix $CARGO_HOME_PATH=/CARGO_HOME \
+--remap-path-prefix $RUSTUP_HOME_PATH=/RUSTUP_HOME \
+--remap-path-prefix $SOURCE_DIR=/SOURCE_DIR"