Blame SOURCES/copy-patches.sh

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