@@ -514,11 +514,11 @@ ifneq ($$($(2)_OVERRIDE_SRCDIR),)
$(2)_VERSION = custom
endif
-$(2)_SOURCE_EXT = .tar.gz
ifndef $(2)_SOURCE
ifdef $(3)_SOURCE
$(2)_SOURCE = $$($(3)_SOURCE)
else ifdef $(2)_VERSION
+ # _SOURCE_EXT is defined below, after we compute the _SITE_METHOD
$(2)_SOURCE ?= $$($(2)_BASENAME_RAW)$$($(2)_SOURCE_EXT)
endif
endif
@@ -564,6 +564,12 @@ ifndef $(2)_DL_OPTS
endif
endif
+ifneq ($$(filter git,$$($(2)_SITE_METHOD)),)
+$(2)_SOURCE_EXT = .tar.xz
+else
+$(2)_SOURCE_EXT = .tar.gz
+endif
+
ifneq ($$(filter bzr cvs hg,$$($(2)_SITE_METHOD)),)
BR_NO_CHECK_HASH_FOR += $$($(2)_SOURCE)
endif
@@ -170,8 +170,8 @@ _git checkout -f -q "'${cset}'"
_git clean -ffdx
# Get date of commit to generate a reproducible archive.
-# %cD is RFC2822, so it's fully qualified, with TZ and all.
-date="$( _git log -1 --pretty=format:%cD )"
+# %ci is ISO 8601, so it's fully qualified, with TZ and all.
+date="$( _git log -1 --pretty=format:%ci )"
# There might be submodules, so fetch them.
if [ ${recurse} -eq 1 ]; then
@@ -201,12 +201,20 @@ find . -not -type d \
-and -not -path "./.git/*" >"${output}.list"
LC_ALL=C sort <"${output}.list" >"${output}.list.sorted"
-# Create GNU-format tarballs, since that's the format of the tarballs on
-# sources.buildroot.org and used in the *.hash files
+# Explicit options to ensure reproducibility of the archive
+pax_options="delete=atime,delete=ctime,delete=mtime"
+pax_options+=",exthdr.name=%d/PaxHeaders/%f,exthdr.mtime={${date}}"
+
+# Create tarballs in the posix format, since that's the most
+# reproducible format
+printf 'Creating tarball (%d files)...\n' "$( cat "${output}.list.sorted" |wc -l )"
tar cf - --transform="s#^\./#${basename}/#" \
- --numeric-owner --owner=0 --group=0 --mtime="${date}" --format=gnu \
+ --numeric-owner --owner=0 --group=0 --mtime="${date}" \
+ --format=posix \
+ --pax-option="${pax_options}" \
-T "${output}.list.sorted" >"${output}.tar"
-gzip -6 -n <"${output}.tar" >"${output}"
+printf 'Compressing tarball (%d bytes)...\n' "$( stat -c %s "${output}.tar" )"
+xz -9 <"${output}.tar" >"${output}"
rm -f "${output}.list"
rm -f "${output}.list.sorted"