Make the test data source archive mostly-reproducible

This should keep us from having to upload a fresh archive to the
lookaside cache for a new version when the data hasn’t actually
changed.
This commit is contained in:
Benjamin A. Beasley 2023-10-11 12:25:00 -04:00
commit 7af0207616
4 changed files with 25 additions and 7 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@
/pyMapVBVD-0.5.4-test-data.tar.xz
/pyMapVBVD-0.5.5.tar.gz
/pyMapVBVD-0.5.5-test-data.tar.xz
/pyMapVBVD-test-data.tar.xz

View file

@ -11,8 +11,13 @@ Usage: $1 VERSION
Generate a source archive containing the test data files for pyMapVBVD that are
tracked in git LFS and are not included in the default source archive. The
result will be named pyMapVBVD-\${VERSION}-test-data.tar.xz and will be written
result will be named pyMapVBVD-test-data.tar.xz and will be written
into the current working directory.
The script attempts to produce a reproducible archive to avoid uploading
near-duplicate archives to the lookaside cache when the test data does not
change from one version to the next. Accordingly, the top-level directory
pyMapVBVD-\${VERSION}/ is omitted from the archived paths.
EOF
}
@ -41,7 +46,7 @@ GITDIR="$(echo "${FORGEURL}" | sed -r 's@.*/@@')"
#SOURCE0="${FORGEURL}/archive/${VERSION}/pdfminer.six-${VERSION}.tar.gz"
#TARNAME="$(basename "${SOURCE0}")"
TARDIR="pyMapVBVD-${VERSION}"
NEWTAR="${TARDIR}-test-data.tar.xz"
NEWTAR='pyMapVBVD-test-data.tar.xz'
SAVEDIR="${PWD}"
XDIR="$(mktemp -d)"
@ -61,8 +66,20 @@ git lfs ls-files -n |
ln "${fn}" "${DESTDIR}/$(basename "${fn}")"
done
cd "${XDIR}"
tar -cv "${TARDIR}/" | xz -9e > "${NEWTAR}"
cd "${XDIR}/${TARDIR}"
# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html
# We discard mtimes entirely, since git doesnt store mtimes and they are just
# the time we did the git clone.
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' \
--clamp-mtime --mtime='@0' \
. |
xz -9e > "${XDIR}/${NEWTAR}"
cd "${SAVEDIR}"
mv -v "${XDIR}/${NEWTAR}" .

View file

@ -11,7 +11,7 @@ License: MIT AND Unlicense
URL: https://github.com/wtclarke/pymapvbvd
Source0: %{pypi_source pyMapVBVD}
# Generated with Source2: ./get_test_data.sh %%{version}
Source1: pyMapVBVD-%{version}-test-data.tar.xz
Source1: pyMapVBVD-test-data.tar.xz
Source2: get_test_data.sh
BuildArch: noarch
@ -43,7 +43,7 @@ Summary: %{summary}
%prep
%autosetup -n pyMapVBVD-%{version} -p1
%setup -q -T -D -b 1 -n pyMapVBVD-%{version}
%setup -q -T -D -a 1 -c -n pyMapVBVD-%{version}
# We can use the system versioneer to generate _version.py, and can remove the
# bundled, amaglamated versioneer.py to indicate we arent using it.
rm -v versioneer.py

View file

@ -1,2 +1,2 @@
SHA512 (pyMapVBVD-0.5.5.tar.gz) = 7757d9963879efd4e69c6d61ec3e6fcd98153118f891b958351c720705c57cf48ec3dfc459ab0f69fe00b5d9bddc53621340f7b1f6bb88385408932b9fd32b19
SHA512 (pyMapVBVD-0.5.5-test-data.tar.xz) = 8b0d548e1100b15942158e240e795b05a82a3c62ae44f4ccaea84977d4373c19d9ae6b93cd42f49823c4fbf113c3470e72431889d6aff870c4c6fed7202befa8
SHA512 (pyMapVBVD-test-data.tar.xz) = 9fa0530f68b02a8ff26fad1c463db217260c2f31a039b96f30a1fa6bb8b044ab8304edfd06abcaf5e9980ed355f29f0339c6e87e8dbddd67ae85457f384d45dd