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