Blame SOURCES/copy-patches.sh

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