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