1854f36
#!/bin/bash -
1854f36
1854f36
set -e
1854f36
1854f36
# Maintainer script to copy patches from the git repo to the current
1854f36
# directory.  Use it like this:
1854f36
#   ./copy-patches.sh
1854f36
1854f36
rhel_version=8.3
1854f36
1854f36
# Check we're in the right directory.
1854f36
if [ ! -f nbdkit.spec ]; then
1854f36
    echo "$0: run this from the directory containing 'nbdkit.spec'"
1854f36
    exit 1
1854f36
fi
1854f36
1854f36
git_checkout=$HOME/d/nbdkit-rhel-$rhel_version
1854f36
if [ ! -d $git_checkout ]; then
1854f36
    echo "$0: $git_checkout does not exist"
1854f36
    echo "This script is only for use by the maintainer when preparing a"
1854f36
    echo "nbdkit release on RHEL."
1854f36
    exit 1
1854f36
fi
1854f36
1854f36
# Get the base version of nbdkit.
1854f36
version=`grep '^Version:' nbdkit.spec | awk '{print $2}'`
1854f36
tag="v$version"
1854f36
1854f36
# Remove any existing patches.
1854f36
git rm -f [0-9]*.patch ||:
1854f36
rm -f [0-9]*.patch
1854f36
1854f36
# Get the patches.
1854f36
(cd $git_checkout; rm -f [0-9]*.patch; git format-patch -N $tag)
1854f36
mv $git_checkout/[0-9]*.patch .
1854f36
1854f36
# Remove any not to be applied.
1854f36
rm -f *NOT-FOR-RPM*.patch
1854f36
1854f36
# Add the patches.
1854f36
git add [0-9]*.patch
1854f36
1854f36
# Print out the patch lines.
1854f36
echo
1854f36
echo "--- Copy the following text into nbdkit.spec file"
1854f36
echo
1854f36
1854f36
echo "# Patches."
1854f36
for f in [0-9]*.patch; do
1854f36
    n=`echo $f | awk -F- '{print $1}'`
1854f36
    echo "Patch$n:     $f"
1854f36
done
1854f36
1854f36
echo
1854f36
echo "--- End of text"