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