Blame SOURCES/copy-patches.sh

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