- https://pagure.io/neuro-sig/NeuroFedora/issue/576 - https://github.com/G-Node/nixpy/issues/545
50 lines
1.5 KiB
Bash
Executable file
50 lines
1.5 KiB
Bash
Executable file
#!/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 didn’t.)
|
||
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
|