Make the filtered source archive more reproducible

This commit is contained in:
Benjamin A. Beasley 2024-04-04 22:38:26 -04:00
commit f5e5a80c16
2 changed files with 18 additions and 3 deletions

View file

@ -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

View file

@ -1 +1 @@
SHA512 (chardet-5.2.0-filtered.tar.xz) = 4f865b958503596cdaf690d0cb586c7c477419ca528b4701d93577c34764fcbab2246d79b82fe25a06246c59cedb9344ec332540efb76cc02d49158fb4903974
SHA512 (chardet-5.2.0-filtered.tar.xz) = 4ed51684c86bab8f4822035d180e375c7f4817e29b172363d1d5183043f0022f2c2245958a4b00064e6dda756c0c1d283bed9c41026c1be93fe87b13940e455c