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