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