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