Blame SOURCES/copy-patches.sh

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