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