|
|
a0fe45 |
#!/bin/bash
|
|
|
a0fe45 |
# Usage:
|
|
|
a0fe45 |
# ./otp-get-patches.sh /path/to/otp OTP_R14B02 fedora-R14B02
|
|
|
a0fe45 |
#
|
|
|
a0fe45 |
# otp-get-patches.sh - update erlang.spec and otp-00*.patch files
|
|
|
a0fe45 |
#
|
|
|
a0fe45 |
# otp-get-patches.sh updates the erlang.spec and otp-00*.patch
|
|
|
a0fe45 |
# files in the git index. After an otp-get-patches.sh run, you
|
|
Hans Ulrich Niedermann |
e7421b |
# will need to review the staged git changes, possibly adapt the
|
|
Hans Ulrich Niedermann |
e7421b |
# 'Release:' and '%changelog' parts of erlang.spec, and can then
|
|
|
a0fe45 |
# "git commit" everything.
|
|
|
a0fe45 |
#
|
|
|
a0fe45 |
# Caution: Leave the four special comment lines untouched in the
|
|
|
a0fe45 |
# spec file, as otp-get-patches.sh requires them and will only
|
|
Hans Ulrich Niedermann |
e7421b |
# touch the parts of erlang.spec between the respective start/end
|
|
Hans Ulrich Niedermann |
e7421b |
# comment pair:
|
|
|
a0fe45 |
#
|
|
|
a0fe45 |
# # start of autogenerated patch tag list
|
|
|
a0fe45 |
# # end of autogenerated patch tag list
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Command line parsing
|
|
|
a0fe45 |
otp_dir="${1:?'Fatal: otp git repo dir required'}"
|
|
|
a0fe45 |
otp_upstream="${2:?'Fatal: git ref to upstream release required'}"
|
|
|
a0fe45 |
otp_fedora="${3:?'Fatal: git ref to branch with fedora patches required'}"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Setup
|
|
|
a0fe45 |
set -e
|
|
|
a0fe45 |
# set -x
|
|
|
a0fe45 |
tmpdir="$(mktemp -d --tmpdir="$PWD")"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Generate patch files
|
|
|
a0fe45 |
pushd "$otp_dir"
|
|
|
2845f9 |
git format-patch -N --no-signature --no-stat -o "$tmpdir" "${otp_upstream}..${otp_fedora}" > "$tmpdir/patch-list.txt"
|
|
|
a0fe45 |
popd
|
|
|
a0fe45 |
|
|
|
a0fe45 |
test -s "$tmpdir/patch-list.txt"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Process patch files
|
|
|
a0fe45 |
echo "# start of autogenerated patch tag list" > "$tmpdir/patch-list-tags.txt"
|
|
|
a0fe45 |
n=1
|
|
|
a0fe45 |
while read patch
|
|
|
a0fe45 |
do
|
|
|
a0fe45 |
otppatch="$(dirname "$patch")/otp-$(basename "$patch")"
|
|
|
a0fe45 |
${SED-sed} -e '1d' -e '/^-- $/,$d' "$patch" > "$otppatch"
|
|
|
a0fe45 |
rm -f "$patch"
|
|
|
a0fe45 |
echo "Patch$n: $(basename "$otppatch")" >> "$tmpdir/patch-list-tags.txt"
|
|
|
a0fe45 |
n=$(($n + 1))
|
|
|
a0fe45 |
done < "$tmpdir/patch-list.txt"
|
|
|
a0fe45 |
echo "# end of autogenerated patch tag list" >> "$tmpdir/patch-list-tags.txt"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Create updated spec file
|
|
|
a0fe45 |
specfile="erlang.spec"
|
|
|
a0fe45 |
newspec1="${tmpdir}/${specfile}.new1"
|
|
|
a0fe45 |
sed '/^# start of autogenerated patch tag list$/,$d' "$specfile" > "$newspec1"
|
|
|
a0fe45 |
cat "$tmpdir/patch-list-tags.txt" >> "$newspec1"
|
|
|
a0fe45 |
sed '1,/^# end of autogenerated patch tag list/d' "$specfile" >> "$newspec1"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
# Actually put all changes into git index
|
|
|
a0fe45 |
git rm -f otp-00*.patch
|
|
|
a0fe45 |
mv "$tmpdir/otp-00"*.patch .
|
|
|
a0fe45 |
git add otp-00*.patch
|
|
|
2ee53c |
mv -f "$newspec1" "$specfile"
|
|
|
a0fe45 |
git add "$specfile"
|
|
|
a0fe45 |
|
|
|
a0fe45 |
rm -rf "$tmpdir"
|
|
|
a0fe45 |
# End of file.
|