Skip to content

Commit ddbc3dc

Browse files
committed
GH-47074: [Release] Use reproducible mtime for csharp/ in source archive (#47076)
### Rationale for this change The current source archive creation is reproducible when we use the same Git working tree. But it's not reproducible when we use different Git working trees. ### What changes are included in this PR? Use the committer date of the target commit instead of the `charp/` mtime in the current Git working tree for `csharp/` in the source archive. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #47074 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 0534eb2 commit ddbc3dc

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

dev/release/utils-create-release-tarball.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,26 @@ rm -rf ${root_folder}.tmp
6262
# * https://github.com/apache/arrow/pull/4488
6363
#
6464
# We need to set constant timestamp for a dummy .git/ directory for
65-
# Reproducible Builds. We use mtime of csharp/ for it. If
66-
# SOURCE_DATE_EPOCH is defined, this mtime is overwritten when tar
67-
# file is created.
68-
if stat --help > /dev/null 2>&1; then
69-
# GNU stat
70-
#
71-
# touch accepts YYYYMMDDhhmm.ss format but GNU stat doesn't support
72-
# for outputting with the format. So we use date for it.
73-
csharp_mtime=$(date --date="$(stat --format="%y" csharp)" +%Y%m%d%H%M.%S)
74-
else
75-
# BSD stat
76-
csharp_mtime=$(stat -f %Sm -t %Y%m%d%H%M.%S csharp)
77-
fi
65+
# Reproducible Builds. We use committer date of the target commit hash
66+
# for it. If SOURCE_DATE_EPOCH is defined, this mtime is overwritten
67+
# when tar file is created.
68+
csharp_mtime=$(TZ=UTC \
69+
git \
70+
-C "${SOURCE_TOP_DIR}" \
71+
log \
72+
--format=%cd \
73+
--date=format:%Y%m%d%H%M.%S \
74+
-n1 \
75+
"${release_hash}")
7876
dummy_git=${root_folder}/csharp/dummy.git
7977
mkdir ${dummy_git}
8078
pushd ${dummy_git}
8179
echo ${release_hash} > HEAD
8280
echo "[remote \"origin\"] url = https://github.com/${GITHUB_REPOSITORY:-apache/arrow}.git" >> config
8381
mkdir objects refs
84-
find . -exec touch -t "${csharp_mtime}" '{}' ';'
82+
TZ=UTC find . -exec touch -t "${csharp_mtime}" '{}' ';'
8583
popd
86-
touch -t "${csharp_mtime}" ${root_folder}/csharp
84+
TZ=UTC touch -t "${csharp_mtime}" ${root_folder}/csharp
8785

8886
# Create new tarball from modified source directory.
8987
#

dev/release/verify-release-candidate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ ensure_source_directory() {
791791
fetch_archive ${dist_name}
792792
git clone https://github.com/${GITHUB_REPOSITORY}.git arrow
793793
pushd arrow
794-
dev/release/utils-create-release-tarball.sh ${VERSION} ${RC_NUMBER}
794+
"${SOURCE_DIR}/utils-create-release-tarball.sh" ${VERSION} ${RC_NUMBER}
795795
if ! cmp ${dist_name}.tar.gz ../${dist_name}.tar.gz; then
796796
echo "Source archive isn't reproducible"
797797
return 1

0 commit comments

Comments
 (0)