sleef/get_source.sh
2023-01-23 16:43:49 -05:00

52 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
set -o nounset
set -o errexit
FORGEURL='https://github.com/shibatch/sleef'
print_help()
{
cat <<EOF
Usage: $1 VERSION
Generate a source archive for sleef with src/gencoef/ removed, since the code
therein is licensed CC-BY-4.0, but this license is not approved for code in
Fedora. The result will be named sleef-\${VERSION}-filtered.tar.xz and will be
written into the current working directory.
EOF
}
if [ "$#" != '1' ]
then
exec 1>&2
print_help "${0}"
exit 1
elif [ "${1-}" = '-h' ] || [ "${1-}" = '--help' ]
then
print_help "${0}"
exit 0
fi
VERSION="${1}"
SOURCE0="${FORGEURL}/archive/${VERSION}/sleef-${VERSION}.tar.gz"
TARNAME="$(basename "${SOURCE0}")"
TARDIR="$(basename "${SOURCE0}" '.tar.gz')"
NEWTAR="${TARDIR}-filtered.tar.xz"
SAVEDIR="${PWD}"
XDIR="$(mktemp -d)"
trap "rm -rvf '${XDIR}'" INT TERM EXIT
cd "${XDIR}"
curl -L -O "${SOURCE0}"
tar -xzvf "${TARNAME}"
rm -rvf "${TARDIR}/src/gencoef/"
if grep -ErinI 'Attribution 4\.0' .
then
echo 'ERROR: did not properly remove problematic content' 1>&2
exit 1
fi
tar -cv "${TARDIR}/" | xz -9e > "${NEWTAR}"
cd "${SAVEDIR}"
mv -v "${XDIR}/${NEWTAR}" .