From f5e5a80c16e1d278f037a3233e6564207c4734aa Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 4 Apr 2024 22:38:26 -0400 Subject: [PATCH] Make the filtered source archive more reproducible --- get_source | 19 +++++++++++++++++-- sources | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/get_source b/get_source index 513d1d3..7b8cede 100755 --- a/get_source +++ b/get_source @@ -25,10 +25,25 @@ curl -L -O "${URL}" ARCHIVE="$(find . -mindepth 1 -maxdepth 1 -type f -name '*.tar.gz' -print -quit)" echo "--> Extracting: $(basename "${ARCHIVE}")" 1>&2 tar -xzf "${ARCHIVE}" +cp -p "${ARCHIVE}" /tmp/ echo '--> Removing tests due to licensing issues' 1>&2 -rm -rvf */tests/ +TARDIR="$(basename "${ARCHIVE}" '.tar.gz')" +MTIME="$(stat -c '%Y' "${TARDIR}")" +rm -rvf "${TARDIR}/tests/" +# Restore the original mtime even though we modified the base directory by +# removing the tests. +touch -d @"${MTIME}" "${TARDIR}" FILTERED="$(basename "${ARCHIVE}" .tar.gz)-filtered.tar.xz" echo "--> Re-archiving: ${FILTERED}" 1>&2 -tar -c "${FILTERED}" */ | xz -9e > "${FILTERED}" +# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html +TZ=UTC LC_ALL=C tar \ + --create --verbose \ + --sort=name \ + --format=posix \ + --numeric-owner --owner=0 --group=0 \ + --mode=go+u,go-w \ + --pax-option='delete=atime,delete=ctime' \ + "${TARDIR}/" | + xz -9e > "${FILTERED}" mv -v "${FILTERED}" "${OUTDIR}" echo 'Done.' 1>&2 diff --git a/sources b/sources index 44e7115..92192b4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (chardet-5.2.0-filtered.tar.xz) = 4f865b958503596cdaf690d0cb586c7c477419ca528b4701d93577c34764fcbab2246d79b82fe25a06246c59cedb9344ec332540efb76cc02d49158fb4903974 +SHA512 (chardet-5.2.0-filtered.tar.xz) = 4ed51684c86bab8f4822035d180e375c7f4817e29b172363d1d5183043f0022f2c2245958a4b00064e6dda756c0c1d283bed9c41026c1be93fe87b13940e455c