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