Blame otp-get-patches.sh

Hans Ulrich Niedermann 757e49
#!/bin/bash
Hans Ulrich Niedermann 757e49
# Usage:
Hans Ulrich Niedermann 757e49
#    ./otp-get-patches.sh /path/to/otp OTP_R14B01 fedora-R14B01
Hans Ulrich Niedermann 757e49
#
Hans Ulrich Niedermann 757e49
# Note:
Hans Ulrich Niedermann 757e49
#    We do NOT update erlang.spec or the git index at all.
Hans Ulrich Niedermann 757e49
#    For now, take a look at the patch-list-*.txt files
Hans Ulrich Niedermann 757e49
#    generated in the tmpdir manually copy and adapt them
Hans Ulrich Niedermann 757e49
#    to erlang.spec. Then handle the otp-*.patch files:
Hans Ulrich Niedermann 757e49
#
Hans Ulrich Niedermann 757e49
#        git rm -f otp-00*.patch
Hans Ulrich Niedermann 757e49
#        mv tmp.foobar/otp-00*.patch .
Hans Ulrich Niedermann 757e49
#        git add otp-00*.patch
Hans Ulrich Niedermann 757e49
#
Hans Ulrich Niedermann 757e49
#    We could only automate this if we added the required patch
Hans Ulrich Niedermann 757e49
#    specific spec file conditionals to the commit message somehow,
Hans Ulrich Niedermann 757e49
#    and then had this script transfer the conditionals into erlang.spec.
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
otp_dir="${1:?'Fatal: otp git repo dir required'}"
Hans Ulrich Niedermann 757e49
otp_upstream="${2:?'Fatal: git ref to upstream release required'}"
Hans Ulrich Niedermann 757e49
otp_fedora="${3:?'Fatal: git ref to branch with fedora patches required'}"
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
set -e
Hans Ulrich Niedermann 757e49
# set -x
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
tmpdir="$(mktemp -d --tmpdir="$PWD")"
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
pushd "$otp_dir"
Hans Ulrich Niedermann 757e49
git format-patch -o "$tmpdir" "${otp_upstream}..${otp_fedora}" > "$tmpdir/patch-list.txt"
Hans Ulrich Niedermann 757e49
popd
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
test -s "$tmpdir/patch-list.txt"
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
echo "# start of autogenerated patch tag list" > "$tmpdir/patch-list-tags.txt"
Hans Ulrich Niedermann 757e49
echo "# start of autogenerated prep patch list" > "$tmpdir/patch-list-prep.txt"
Hans Ulrich Niedermann 757e49
n=1
Hans Ulrich Niedermann 757e49
while read patch
Hans Ulrich Niedermann 757e49
do
Hans Ulrich Niedermann 757e49
	otppatch="$(dirname "$patch")/otp-$(basename "$patch")"
Hans Ulrich Niedermann 757e49
	mv -f "$patch" "$otppatch"
Hans Ulrich Niedermann 757e49
	echo "Patch$n: $(basename "$otppatch")" >> "$tmpdir/patch-list-tags.txt"
Hans Ulrich Niedermann 757e49
	base="$(basename "$patch" ".patch" | sed 's/^00[0-9][0-9]-//')"
Hans Ulrich Niedermann 757e49
	backupext=".$(echo -n "$base" | tr -c -s '[:alnum:]' '_')"
Hans Ulrich Niedermann 757e49
	echo "%patch$n -p1 -b ${backupext}" >> "$tmpdir/patch-list-prep.txt"
Hans Ulrich Niedermann 757e49
	n=$(($n + 1))
Hans Ulrich Niedermann 757e49
done < "$tmpdir/patch-list.txt"
Hans Ulrich Niedermann 757e49
echo "# end of autogenerated patch tag list" >> "$tmpdir/patch-list-tags.txt"
Hans Ulrich Niedermann 757e49
echo "# end of autogenerated prep patch list" >> "$tmpdir/patch-list-prep.txt"
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
echo "Results in tmp dir \`$tmpdir':"
Hans Ulrich Niedermann 757e49
echo
Hans Ulrich Niedermann 757e49
cat "$tmpdir/patch-list-tags.txt"
Hans Ulrich Niedermann 757e49
echo
Hans Ulrich Niedermann 757e49
cat "$tmpdir/patch-list-prep.txt"
Hans Ulrich Niedermann 757e49
Hans Ulrich Niedermann 757e49
echo
Hans Ulrich Niedermann 757e49
echo "Run \`rm -rf \"$(basename "$tmpdir")\"' when you are finished with the files."
Hans Ulrich Niedermann 757e49
# End of file.