Skip to content

Commit ea451dc

Browse files
committed
Try reproducible builds on local host
1 parent d9c1881 commit ea451dc

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

dev/tasks/linux-packages/apache-arrow-apt-source/debian/rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export DH_OPTIONS
1212
override_dh_auto_build:
1313
gpg \
1414
--no-default-keyring \
15+
--homedir /tmp \
1516
--keyring ./apache-arrow-apt-source.kbx \
1617
--import KEYS
1718
gpg \
1819
--no-default-keyring \
20+
--homedir /tmp \
1921
--keyring ./apache-arrow-apt-source.kbx \
2022
--armor \
2123
--export > apache-arrow-apt-source.asc

dev/tasks/linux-packages/apache-arrow/apt/debian-trixie/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ RUN \
3939
apt install -y -V ${quiet} \
4040
base-files \
4141
build-essential \
42+
ccache \
4243
clang \
4344
cmake \
4445
debhelper \

dev/tasks/linux-packages/apt/build.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
LANG=C
2222

23-
set -u
23+
set -ux
24+
25+
# Set consistent umask for reproducible file permissions
26+
umask 0022
2427

2528
run()
2629
{
@@ -48,8 +51,9 @@ architecture=$(dpkg-architecture -q DEB_BUILD_ARCH)
4851
debuild_options=()
4952
dpkg_buildpackage_options=(-us -uc)
5053

51-
run mkdir -p /build
52-
run cd /build
54+
build_root_dir="/build"
55+
run mkdir -p "${build_root_dir}"
56+
run pushd "${build_root_dir}"
5357
find . -not -path ./ccache -a -not -path "./ccache/*" -delete
5458
if which ccache > /dev/null 2>&1; then
5559
export CCACHE_COMPILERCHECK=content
@@ -67,6 +71,9 @@ if which ccache > /dev/null 2>&1; then
6771
debuild_options+=(--prepend-path=/usr/lib/ccache)
6872
fi
6973
fi
74+
build_dir="${build_root_dir}/build-${PACKAGE}-${VERSION}"
75+
run mkdir -p "${build_dir}"
76+
run pushd "${build_dir}"
7077
run cp /host/tmp/${PACKAGE}-${VERSION}.tar.gz \
7178
${PACKAGE}_${VERSION}.orig.tar.gz
7279
run tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
@@ -80,7 +87,7 @@ case "${VERSION}" in
8087
${PACKAGE}-${VERSION}
8188
;;
8289
esac
83-
run cd ${PACKAGE}-${VERSION}/
90+
run pushd ${PACKAGE}-${VERSION}/
8491
platform="${distribution}-${code_name}"
8592
if [ -d "/host/tmp/debian.${platform}-${architecture}" ]; then
8693
run cp -rp "/host/tmp/debian.${platform}-${architecture}" debian
@@ -102,7 +109,7 @@ df -h
102109
if which ccache > /dev/null 2>&1; then
103110
ccache --show-stats --verbose || :
104111
fi
105-
run cd -
112+
run popd
106113

107114
repositories="/host/repositories"
108115
package_initial=$(echo "${PACKAGE}" | sed -e 's/\(.\).*/\1/')
@@ -116,3 +123,7 @@ run \
116123
-exec cp '{}' "${pool_dir}/" ';'
117124

118125
run chown -R "$(stat --format "%u:%g" "${repositories}")" "${repositories}"
126+
run find "${repositories}"
127+
128+
run popd
129+
rm -rf "${build_dir}"

dev/tasks/linux-packages/package-task.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ def docker_run(os, architecture, console: false)
150150
end
151151
pass_through_env_names = [
152152
"DEB_BUILD_OPTIONS",
153+
"HOME",
153154
"RPM_BUILD_NCPUS",
155+
"TZ",
154156
]
155157
pass_through_env_names.each do |name|
156158
value = ENV[name]
@@ -188,7 +190,7 @@ def docker_run(os, architecture, console: false)
188190
run_command_line << image
189191
run_command_line << "/host/build.sh" unless console
190192

191-
sh(*build_command_line)
193+
sh(*build_command_line) if Dir.exist?(ENV["HOME"])
192194
sh(*run_command_line)
193195
end
194196

0 commit comments

Comments
 (0)