Blame SOURCES/copy-patches.sh

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