Skip to content

Commit f9d9c17

Browse files
committed
Make yashrs and brush builds deterministic
1 parent d301a68 commit f9d9c17

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

variants/brush.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,42 @@ shvr_build_brush ()
5252
tar --extract \
5353
--file="${build_srcdir}.tar.gz" \
5454
--strip-components=1 \
55-
--directory="${build_srcdir}"
55+
--directory="${build_srcdir}" \
56+
--owner=0 \
57+
--group=0 \
58+
--mode=go-w \
59+
--touch
5660

5761
cd "${build_srcdir}"
5862

59-
RUSTFLAGS="-A unused_imports" cargo build --release
63+
# Build with reproducible flags
64+
# Use fixed source date epoch and disable compiler timestamp features
65+
export SOURCE_DATE_EPOCH=1
66+
export TZ=UTC
67+
export RUSTFLAGS="-A unused_imports -C target-feature=-crt-static"
68+
69+
cargo build --release
70+
71+
unset SOURCE_DATE_EPOCH TZ RUSTFLAGS
6072

6173
mkdir -p "${SHVR_DIR_OUT}/brush_${version}/bin"
6274
cp "./target/release/brush" "${SHVR_DIR_OUT}/brush_$version/bin"
6375

76+
# Strip binary to ensure reproducible output
77+
strip --strip-all "${SHVR_DIR_OUT}/brush_${version}/bin/brush"
78+
79+
# Ensure consistent permissions and timestamps
80+
touch -d "@1" "${SHVR_DIR_OUT}/brush_${version}/bin/brush"
81+
chmod 755 "${SHVR_DIR_OUT}/brush_${version}/bin/brush"
82+
6483
"${SHVR_DIR_OUT}/brush_${version}/bin/brush" -c "echo brush version $version"
6584
}
6685

6786
shvr_deps_brush ()
6887
{
6988
shvr_versioninfo_brush "$1"
7089
apt-get -y install \
71-
curl wget gcc
90+
curl wget gcc binutils
7291

7392
if ! test -f "$HOME/.cargo/env"
7493
then

variants/yashrs.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,42 @@ shvr_build_yashrs ()
5353
tar --extract \
5454
--file="${build_srcdir}.tar.gz" \
5555
--strip-components=1 \
56-
--directory="${build_srcdir}"
56+
--directory="${build_srcdir}" \
57+
--owner=0 \
58+
--group=0 \
59+
--mode=go-w \
60+
--touch
5761

5862
cd "${build_srcdir}"
5963

64+
# Build with reproducible flags
65+
# Use fixed source date epoch and disable compiler timestamp features
66+
export SOURCE_DATE_EPOCH=1
67+
export TZ=UTC
68+
export RUSTFLAGS="-C target-feature=-crt-static"
69+
6070
cargo build --release
6171

72+
unset SOURCE_DATE_EPOCH TZ RUSTFLAGS
73+
6274
mkdir -p "${SHVR_DIR_OUT}/yashrs_${version}/bin"
6375
cp "./target/release/yash3" "${SHVR_DIR_OUT}/yashrs_$version/bin"
6476

77+
# Strip binary to ensure reproducible output
78+
strip --strip-all "${SHVR_DIR_OUT}/yashrs_${version}/bin/yash3"
79+
80+
# Ensure consistent permissions and timestamps
81+
touch -d "@1" "${SHVR_DIR_OUT}/yashrs_${version}/bin/yash3"
82+
chmod 755 "${SHVR_DIR_OUT}/yashrs_${version}/bin/yash3"
83+
6584
"${SHVR_DIR_OUT}/yashrs_${version}/bin/yash3" -c "echo yashrs version $version"
6685
}
6786

6887
shvr_deps_yashrs ()
6988
{
7089
shvr_versioninfo_yashrs "$1"
7190
apt-get -y install \
72-
curl wget gcc
91+
curl wget gcc binutils
7392

7493
if ! test -f "$HOME/.cargo/env"
7594
then

0 commit comments

Comments
 (0)