@@ -54,10 +54,43 @@ SUBDIRS = \
5454 contrib/vagrant-ci/centos-9s-x64
5555
5656
57- # Hide the buildsystem's username, at least with GNU tar.
58- TAR_OPTIONS = --owner=0 --group=0
57+ # Normalize tar header fields so two builds of the same source tree produce a
58+ # byte-identical tarball, following the GNU tar reproducibility guidance:
59+ # https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html
60+ # --format=posix stable, version-independent header encoding (configure.ac
61+ # selects tar-pax so $(am__tar) emits posix)
62+ # --pax-option=... keep tar's PID out of extended-header names and omit
63+ # atime/ctime, leaving the archive in the ustar subset
64+ # --sort=name stable member order
65+ # --numeric-owner do not record buildslave user/group names
66+ # --owner=0 --group=0 deterministic ownership
67+ # --mode=go+u,go-w deterministic permissions
68+ # mtime clamping (the manual's --clamp-mtime --mtime) is handled by the
69+ # touch -d @$$SOURCE_DATE_EPOCH call in dist-hook below.
70+ TAR_OPTIONS = \
71+ --format=posix \
72+ --pax-option=exthdr.name=%d/PaxHeaders/%f \
73+ --pax-option=delete=atime,delete=ctime \
74+ --sort=name \
75+ --numeric-owner --owner=0 --group=0 \
76+ --mode=go+u,go-w
5977export TAR_OPTIONS
6078
79+ # The same guidance says to "run GNU tar in the C locale" alongside the options
80+ # above; its example invokes "LC_ALL=C tar ...".
81+ LC_ALL = C
82+ export LC_ALL
83+
84+ # --no-name strips the mtime from the gzip header. --best is automake's default
85+ GZIP_ENV = "--best --no-name"
86+
87+ # Clamp every mtime in the source tarball to SOURCE_DATE_EPOCH, so that it
88+ # follows the commit the tarball was made from rather than the time it was built.
89+ dist-hook :
90+ if [ -n " $$ SOURCE_DATE_EPOCH" ]; then \
91+ find $(distdir ) -exec touch -d @$$ SOURCE_DATE_EPOCH {} + ; \
92+ fi
93+
6194
6295EXTRA_DIST = CHANGELOG.md INSTALL README.md LICENSE CFVERSION
6396
0 commit comments