7bddab
#!/bin/bash -
7bddab
7bddab
set -e
7bddab
7bddab
# Maintainer script to copy patches from the git repo to the current
7bddab
# directory.  Use it like this:
7bddab
#   ./copy-patches.sh
7bddab
7bddab
project=virt-v2v
c659c5
rhel_version=9.2
7bddab
7bddab
# Check we're in the right directory.
7bddab
if [ ! -f $project.spec ]; then
7bddab
    echo "$0: run this from the directory containing '$project.spec'"
7bddab
    exit 1
7bddab
fi
7bddab
7bddab
case `id -un` in
7bddab
    rjones) git_checkout=$HOME/d/$project-rhel-$rhel_version ;;
7bddab
    lacos)  git_checkout=$HOME/src/v2v/$project ;;
7bddab
    *)      git_checkout=$HOME/d/$project-rhel-$rhel_version ;;
7bddab
esac
7bddab
if [ ! -d $git_checkout ]; then
7bddab
    echo "$0: $git_checkout does not exist"
7bddab
    echo "This script is only for use by the maintainer when preparing a"
7bddab
    echo "$project release on RHEL."
7bddab
    exit 1
7bddab
fi
7bddab
7bddab
# Get the base version of the project.
7bddab
version=`grep '^Version:' $project.spec | awk '{print $2}'`
7bddab
tag="v$version"
7bddab
7bddab
# Remove any existing patches.
7bddab
git rm -f [0-9]*.patch ||:
7bddab
rm -f [0-9]*.patch
7bddab
7bddab
# Get the patches.
c1a9fa
(
c1a9fa
  cd $git_checkout
c1a9fa
  rm -f [0-9]*.patch
c1a9fa
  git -c core.abbrev=8 format-patch -O/dev/null --subject-prefix=PATCH -N \
c1a9fa
      --submodule=diff --no-signature --patience $tag
c1a9fa
)
7bddab
mv $git_checkout/[0-9]*.patch .
7bddab
7bddab
# Remove any not to be applied.
7bddab
rm -f *NOT-FOR-RPM*.patch
7bddab
7bddab
# Add the patches.
7bddab
git add [0-9]*.patch
7bddab
7bddab
# Print out the patch lines.
7bddab
echo
7bddab
echo "--- Copy the following text into $project.spec file"
7bddab
echo
7bddab
7bddab
echo "# Patches."
7bddab
for f in [0-9]*.patch; do
7bddab
    n=`echo $f | awk -F- '{print $1}'`
7bddab
    echo "Patch$n:     $f"
7bddab
done
7bddab
7bddab
echo
7bddab
echo "--- End of text"