Blame SOURCES/copy-patches.sh

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