Blame SOURCES/copy-patches.sh

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