-
Notifications
You must be signed in to change notification settings - Fork 3.8k
GH-46336: [Release][Packaging] Add support for Reproducible Builds for source archive #46342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
32a825c
baa6718
370364c
f6f206a
f71132d
49b0858
0f9048d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,12 @@ | |
# under the License. | ||
# | ||
|
||
# This must generate reproducible source archive. For reproducible | ||
# source archive, we must use the same timestamp, user, group and so | ||
# on. | ||
# | ||
# See also https://reproducible-builds.org/ for Reproducible Builds. | ||
|
||
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
SOURCE_TOP_DIR="$(cd "${SOURCE_DIR}/../../" && pwd)" | ||
|
||
|
@@ -46,18 +52,70 @@ rm -rf ${root_folder} | |
# Resolve symbolic and hard links | ||
rm -rf ${root_folder}.tmp | ||
mv ${root_folder} ${root_folder}.tmp | ||
cp -R -L ${root_folder}.tmp ${root_folder} | ||
cp -a -L ${root_folder}.tmp ${root_folder} | ||
rm -rf ${root_folder}.tmp | ||
|
||
# Create a dummy .git/ directory to download the source files from GitHub with Source Link in C#. | ||
# Create a dummy .git/ directory to download the source files from | ||
# GitHub with Source Link in C#. See the followings for more Source | ||
# Link support and why we need a dummy .git directory: | ||
# * https://github.com/apache/arrow/issues/21580 | ||
# * https://github.com/apache/arrow/pull/4488 | ||
# | ||
# We need to set constant timestamp for a dummy .git/ directory for | ||
# Reproducible Builds. We use mtime of csharp/ for it. If | ||
# SOURCE_DATE_EPOCH is defined, this mtime is overwritten when tar | ||
# file is created. | ||
if stat --help > /dev/null 2>&1; then | ||
# GNU stat | ||
# | ||
# touch accepts YYYYMMDDhhmm.ss format but GNU stat doesn't support | ||
# for outputting with the format. So we use date for it. | ||
csharp_mtime=$(date --date="$(stat --format="%y" csharp)" +%Y%m%d%H%M.%S) | ||
else | ||
# BSD stat | ||
csharp_mtime=$(stat -f %Sm -t %Y%m%d%H%M.%S csharp) | ||
fi | ||
dummy_git=${root_folder}/csharp/dummy.git | ||
mkdir ${dummy_git} | ||
pushd ${dummy_git} | ||
echo ${release_hash} > HEAD | ||
echo "[remote \"origin\"] url = https://github.com/${GITHUB_REPOSITORY:-apache/arrow}.git" >> config | ||
mkdir objects refs | ||
find . -exec touch -t "${csharp_mtime}" '{}' ';' | ||
popd | ||
touch -t "${csharp_mtime}" ${root_folder}/csharp | ||
|
||
# Create new tarball from modified source directory | ||
tar czf ${tarball} ${root_folder} | ||
# Create new tarball from modified source directory. | ||
# | ||
# We need to strip unreproducible information. See also: | ||
# https://reproducible-builds.org/docs/stripping-unreproducible-information/ | ||
# | ||
# We need GNU tar for Reproducible Builds. We want to use the same | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping we can use something like https://salsa.debian.org/reproducible-builds/strip-nondeterminism but it might not have support for tar files.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, I didn't know the tool. It's introduced in https://reproducible-builds.org/docs/stripping-unreproducible-information/ . The approaches used here are listed in https://reproducible-builds.org/docs/archives/ . Let's use GNU tar for now because strip-nondeterminism doesn't have tar support. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a comment pointing to https://reproducible-builds.org/docs/stripping-unreproducible-information/ ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I've added. |
||
# owner, group, mode, file order for Reproducible Builds. | ||
# See also: https://reproducible-builds.org/docs/archives/ | ||
# | ||
# gzip --no-name is for omitting timestamp in .gz. It's also for | ||
# Reproducible Builds. | ||
if type gtar > /dev/null 2>&1; then | ||
gtar=gtar | ||
else | ||
gtar=tar | ||
fi | ||
gtar_options=( | ||
--group=0 \ | ||
--mode=a=rX,u+w \ | ||
--numeric-owner \ | ||
--owner=0 \ | ||
--sort=name \ | ||
) | ||
if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then | ||
gtar_options+=(--mtime="$(date +%Y-%m-%dT%H:%M:%S --date=@${SOURCE_DATE_EPOCH})") | ||
fi | ||
set -x | ||
${gtar} \ | ||
"${gtar_options[@]}" \ | ||
-cf \ | ||
- \ | ||
${root_folder} | \ | ||
gzip --no-name > ${tarball} | ||
rm -rf ${root_folder} |
Uh oh!
There was an error while loading. Please reload this page.