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