Blame SOURCES/copy-patches.sh

62f9b7
#!/bin/bash -
62f9b7
62f9b7
set -e
62f9b7
62f9b7
# Maintainer script to copy patches from the git repo to the current
62f9b7
# directory.  Use it like this:
62f9b7
#   ./copy-patches.sh
62f9b7
15d06e
rhel_version=8.8.0
62f9b7
62f9b7
# Check we're in the right directory.
62f9b7
if [ ! -f virt-v2v.spec ]; then
62f9b7
    echo "$0: run this from the directory containing 'virt-v2v.spec'"
62f9b7
    exit 1
62f9b7
fi
62f9b7
62f9b7
git_checkout=$HOME/d/virt-v2v-rhel-$rhel_version
62f9b7
if [ ! -d $git_checkout ]; then
62f9b7
    echo "$0: $git_checkout does not exist"
62f9b7
    echo "This script is only for use by the maintainer when preparing a"
62f9b7
    echo "virt-v2v release on RHEL."
62f9b7
    exit 1
62f9b7
fi
62f9b7
62f9b7
# Get the base version of virt-v2v.
62f9b7
version=`grep '^Version:' virt-v2v.spec | awk '{print $2}'`
62f9b7
tag="v$version"
62f9b7
62f9b7
# Remove any existing patches.
62f9b7
git rm -f [0-9]*.patch ||:
62f9b7
rm -f [0-9]*.patch
62f9b7
62f9b7
# Get the patches.
15d06e
(
15d06e
  cd $git_checkout
15d06e
  rm -f [0-9]*.patch
15d06e
15d06e
  # Ignore some directories in common/ which are not in the virt-v2v tarball.
15d06e
  ignoredirs="edit mlvisit parallel progress structs visit windows"
15d06e
  rm -f common/.gitattributes
15d06e
  for i in $ignoredirs; do
15d06e
      echo "$i/* -diff" >> common/.gitattributes
15d06e
  done
15d06e
15d06e
  git -c core.abbrev=8 format-patch -O/dev/null --subject-prefix=PATCH -N \
15d06e
      --submodule=diff --no-signature --patience $tag
15d06e
15d06e
  # However the .gitattributes doesn't completely ignore them but produces
15d06e
  # Binary files a/... and b/... differ
15d06e
  # which prevents the patches from being applied so we must remove that too.
15d06e
  for i in $ignoredirs; do
15d06e
      sed -i "/^diff --git a\/common\/$i/,/^Binary files a\/common\/$i/{d;}" [0-9]*.patch
15d06e
  done
15d06e
  rm common/.gitattributes
15d06e
)
62f9b7
mv $git_checkout/[0-9]*.patch .
62f9b7
62f9b7
# Remove any not to be applied.
62f9b7
rm -f *NOT-FOR-RPM*.patch
62f9b7
62f9b7
# Add the patches.
62f9b7
git add [0-9]*.patch
62f9b7
62f9b7
# Print out the patch lines.
62f9b7
echo
62f9b7
echo "--- Copy the following text into virt-v2v.spec file"
62f9b7
echo
62f9b7
62f9b7
echo "# Patches."
62f9b7
for f in [0-9]*.patch; do
62f9b7
    n=`echo $f | awk -F- '{print $1}'`
62f9b7
    echo "Patch$n:     $f"
62f9b7
done
62f9b7
62f9b7
echo
62f9b7
echo "--- End of text"