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