Omit lenna.png from the source archive

- https://pagure.io/neuro-sig/NeuroFedora/issue/576
- https://github.com/G-Node/nixpy/issues/545
This commit is contained in:
Benjamin A. Beasley 2024-12-06 10:11:30 -05:00
commit d1a96adae4
4 changed files with 72 additions and 5 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
/nixpy-1.5.1.tar.gz
/nixpy-1.5.2.tar.gz
/nixpy-1.5.3.tar.gz
/nixpy-1.5.3-filtered.tar.gz

50
get_source Executable file
View file

@ -0,0 +1,50 @@
#!/bin/sh
set -o errexit
set -o nounset
if [ "$#" != '1' ]
then
cat 1>&2 <<EOF
Usage: $0 VERSION
Downloads the requested version and creates a filtered source tarball.
EOF
exit 1
fi
VERSION="${1}"
OUTDIR="${PWD}"
TMPDIR="$(mktemp -d)"
trap "rm -rf '${TMPDIR}'" INT TERM EXIT
cd "${TMPDIR}"
REPO="https://github.com/G-node/nixpy"
URL="${REPO}/archive/${VERSION}/nixpy-${VERSION}.tar.gz"
echo "--> Downloading: ${URL}" 1>&2
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}"
echo '--> Removing Lenna/Lena image due to licensing and other issues' 1>&2
TARDIR="$(basename "${ARCHIVE}" '.tar.gz')"
MTIME="$(stat -c '%Y' "${TARDIR}")"
# https://github.com/G-Node/nixpy/issues/545
find "${TARDIR}" -type f -name lenna.png -print -delete
# Make sure the original mtime is preserved even if we modified the base
# directory by removing something at the top level. (So far, we didnt.)
touch -d @"${MTIME}" "${TARDIR}"
FILTERED="$(basename "${ARCHIVE}" .tar.gz)-filtered.tar.gz"
echo "--> Re-archiving: ${FILTERED}" 1>&2
# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html
TZ=UTC LC_ALL=C tar \
--create \
--sort=name \
--format=posix \
--numeric-owner --owner=0 --group=0 \
--mode=go+u,go-w \
--pax-option='delete=atime,delete=ctime' \
"${TARDIR}/" |
gzip -9 > "${FILTERED}"
mv -v "${FILTERED}" "${OUTDIR}"
echo 'Done.' 1>&2

View file

@ -11,12 +11,22 @@ Summary: Python bindings for NIX
# Automatically converted from old format: BSD - review is highly recommended.
License: LicenseRef-Callaway-BSD
URL: %forgeurl
Source0: %forgesource
# We need to upload a filtered version of the source archive because
# docs/source/examples/lenna.png has several issues, including the lack of a
# license. We have asked upstream to deal with this in
# Please consider replacing lenna.png
# https://github.com/G-Node/nixpy/issues/545
# but for now, we must obtain the filtered archive by running the script in
# Source2:
# ./get_source ${VERSION}
%dnl Source0: %forgesource
Source0: nixpy-%{version}-filtered.tar.gz
# The tagged snapshot on GitHub still says "dev" but the manually uploaded
# release does not, so use the info.json from there
# https://github.com/G-Node/nixpy/issues/528
Source1: info.json
# * Script used to obtain Source0: ./get_source %%{version}
Source2: get_source
BuildArch: noarch
# No need for nix, they're uncoupling it from the C++
@ -48,7 +58,7 @@ BuildRequires: %{py3_dist matplotlib}
%{description}
%prep
%forgesetup
%autosetup -n nixpy-%{version}
# it sets examples_path based on the name of the cwd
sed -i "s/nixpy/nixpy-%{version}/" nixio/test/test_doc_examples.py
@ -66,7 +76,13 @@ cp %{SOURCE1} nixio/info.json -v -p
%pyproject_save_files nixio
%check
%{pytest}
# These require the removed lenna.png sample file:
k="${k-}${k+ and }not (TestDocumentationExamples and test_image_data)"
k="${k-}${k+ and }not (TestDocumentationExamples and test_image_with_metadata)"
k="${k-}${k+ and }not (TestDocumentationExamples and test_multiple_rois)"
k="${k-}${k+ and }not (TestDocumentationExamples and test_single_roi)"
%pytest -k "${k-}"
%files -n python3-nixio -f %{pyproject_files}
%{_bindir}/nixio

View file

@ -1 +1 @@
SHA512 (nixpy-1.5.3.tar.gz) = 1b3fd6bb638797a90a2e899d9ae3663a6a0ee3dfc5fe8c6c0806ed5ac2a34ef54771cdb1a715bf400020c6f5df7f3f348ee7129ed1e055381fa11aa5a8b6b218
SHA512 (nixpy-1.5.3-filtered.tar.gz) = 00472f0666b4313124b90b8f14219d1f2a5e56e7174b4eaa2174a7d88a3251513f5fc279d49c1b19dbca3c1c5470ae90049347370e94077aeda24c4db1e5e786