Blame SOURCES/copy-patches.sh

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