Blame SOURCES/copy-patches.sh

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