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