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