[erlang] otp-get-patches.sh: Auto-update git index and spec file

Hans Ulrich Niedermann ndim at fedoraproject.org
Sun Jan 30 18:41:58 UTC 2011


commit ebfa23f7b338826283251f4133c335a4b10c16f4
Author: Hans Ulrich Niedermann <hun at n-dimensional.de>
Date:   Thu Dec 16 16:42:39 2010 +0100

    otp-get-patches.sh: Auto-update git index and spec file

 erlang.spec                                        |    6 ++
 ...ound-for-java-1.5.0-gcj-which-doesn-t-sup.patch |    7 ++-
 otp-get-patches.sh                                 |   70 ++++++++++++++-----
 3 files changed, 63 insertions(+), 20 deletions(-)
---
diff --git a/erlang.spec b/erlang.spec
index 2f2ba4f..363de72 100644
--- a/erlang.spec
+++ b/erlang.spec
@@ -42,6 +42,7 @@ Source2:	http://erlang.org/download/otp_doc_man_%{upstream_ver}%{upstream_rel}.t
 #    $ ./otp-get-patches.sh /path/to/otp OTP_R14B01 lemenkov/fedora-R14B01
 # for some semi-automatic patch update assistance.
 #
+# start of autogenerated patch tag list
 # Fedora specific patch
 Patch1: otp-0001-Do-not-format-man-pages-and-do-not-install-miscellan.patch
 # Fedora specific patch
@@ -64,6 +65,7 @@ Patch9: otp-0009-Do-not-install-VxWorks-specific-docs.patch
 Patch10: otp-0010-Do-not-install-erlang-sources.patch
 # Required only for el5, el6 on PowerPC
 Patch11: otp-0011-Ugly-workaround-for-java-1.5.0-gcj-which-doesn-t-sup.patch
+# end of autogenerated patch tag list
 
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -946,6 +948,8 @@ Erlang mode for XEmacs (source lisp files).
 
 %prep
 %setup -q -n otp_src_%{upstream_ver}%{upstream_rel}
+
+# start of autogenerated prep patch list
 %patch1 -p1 -b .Do_not_format_man_pages_and_do_not_install_miscellan
 %patch2 -p1 -b .Remove_rpath
 %patch3 -p1 -b .Fix_for_dlopening_libGL_and_libGLU
@@ -961,6 +965,8 @@ Erlang mode for XEmacs (source lisp files).
 %patch11 -p1 -b .Ugly_workaround_for_java_1_5_0_gcj_which_doesn_t_sup
 %endif
 %endif
+# end of autogenerated prep patch list
+
 # remove shipped zlib sources
 rm -f erts/emulator/zlib/*.[ch]
 
diff --git a/otp-0011-Ugly-workaround-for-java-1.5.0-gcj-which-doesn-t-sup.patch b/otp-0011-Ugly-workaround-for-java-1.5.0-gcj-which-doesn-t-sup.patch
index d30fd18..38535d4 100644
--- a/otp-0011-Ugly-workaround-for-java-1.5.0-gcj-which-doesn-t-sup.patch
+++ b/otp-0011-Ugly-workaround-for-java-1.5.0-gcj-which-doesn-t-sup.patch
@@ -1,9 +1,14 @@
-From 611a24a8d1f497582cd2deb3a57b9e16cc0f66db Mon Sep 17 00:00:00 2001
+From 4c2e07124ebe2f7a47beed5a54c4cb044b7ec1fb Mon Sep 17 00:00:00 2001
 From: Peter Lemenkov <lemenkov at gmail.com>
 Date: Sun, 21 Nov 2010 00:17:49 +0300
 Subject: [PATCH 11/11] Ugly workaround for java-1.5.0-gcj which doesn't support UNICODE fully
 
 Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>
+Fedora-Spec-Comment: Required only for el5, el6 on PowerPC
+Fedora-Spec-Before: %if 0%{?el4}%{?el5}%{?el6}
+Fedora-Spec-Before: %ifnarch %{ix86} x86_64
+Fedora-Spec-After: %endif
+Fedora-Spec-After: %endif
 ---
  .../com/ericsson/otp/erlang/OtpErlangList.java     |   14 +-------------
  .../com/ericsson/otp/erlang/OtpInputStream.java    |   13 ++-----------
diff --git a/otp-get-patches.sh b/otp-get-patches.sh
index 076752b..98797c3 100755
--- a/otp-get-patches.sh
+++ b/otp-get-patches.sh
@@ -2,35 +2,51 @@
 # Usage:
 #    ./otp-get-patches.sh /path/to/otp OTP_R14B01 fedora-R14B01
 #
-# Note:
-#    We do NOT update erlang.spec or the git index at all.
-#    For now, take a look at the patch-list-*.txt files
-#    generated in the tmpdir manually copy and adapt them
-#    to erlang.spec. Then handle the otp-*.patch files:
+# otp-get-patches.sh - update erlang.spec and otp-00*.patch files
 #
-#        git rm -f otp-00*.patch
-#        mv tmp.foobar/otp-00*.patch .
-#        git add otp-00*.patch
+# 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
+# will need to review the stage git changes, possibly adapt the
+# Release: and %changelog parts of erlang spec, and can then
+# "git commit" everything.
 #
-#    We could only automate this if we added the required patch
-#    specific spec file conditionals to the commit message somehow,
-#    and then had this script transfer the conditionals into erlang.spec.
+# Caution: Leave the four special comment lines untouched in the
+# spec file, as otp-get-patches.sh requires them and will only
+# touch erlang.spec between the respective start/end pair:
+#
+# # start of autogenerated patch tag list
+# # end of autogenerated patch tag list
+# # start of autogenerated prep patch list
+# # end of autogenerated prep patch list
+#
+# The following special comment lines in the git commit messages
+# will be interpreted:
+#
+#    Fedora-Spec-Comment: This patch only applies to EL6 builds
+#    Fedora-Spec-Before: %if 0%?el6}
+#    Fedora-Spec-After: %endif
+#
+# If there is no "Fedora-Spec-Comment:" line, we will use
+# "Fedora specific patch".
 
+# 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"
 git format-patch -o "$tmpdir" "${otp_upstream}..${otp_fedora}" > "$tmpdir/patch-list.txt"
 popd
 
 test -s "$tmpdir/patch-list.txt"
 
+# Process patch files
 echo "# start of autogenerated patch tag list" > "$tmpdir/patch-list-tags.txt"
 echo "# start of autogenerated prep patch list" > "$tmpdir/patch-list-prep.txt"
 n=1
@@ -38,21 +54,37 @@ while read patch
 do
 	otppatch="$(dirname "$patch")/otp-$(basename "$patch")"
 	mv -f "$patch" "$otppatch"
+	comment="$(sed -n 's/^Fedora-Spec-Comment:\s*//p' "$otppatch")"
+	if test "x$comment" = "x"; then comment="Fedora specific patch"; fi
+	echo "# ${comment}" >> "$tmpdir/patch-list-tags.txt"
 	echo "Patch$n: $(basename "$otppatch")" >> "$tmpdir/patch-list-tags.txt"
 	base="$(basename "$patch" ".patch" | sed 's/^00[0-9][0-9]-//')"
 	backupext=".$(echo -n "$base" | tr -c -s '[:alnum:]' '_')"
+	sed -n 's/^Fedora-Spec-Before:\s*//p' "$otppatch" >> "$tmpdir/patch-list-prep.txt"
 	echo "%patch$n -p1 -b ${backupext}" >> "$tmpdir/patch-list-prep.txt"
+	sed -n 's/^Fedora-Spec-After:\s*//p' "$otppatch" >> "$tmpdir/patch-list-prep.txt"
 	n=$(($n + 1))
 done < "$tmpdir/patch-list.txt"
 echo "# end of autogenerated patch tag list" >> "$tmpdir/patch-list-tags.txt"
 echo "# end of autogenerated prep patch list" >> "$tmpdir/patch-list-prep.txt"
 
-echo "Results in tmp dir \`$tmpdir':"
-echo
-cat "$tmpdir/patch-list-tags.txt"
-echo
-cat "$tmpdir/patch-list-prep.txt"
+# Create updated spec file
+specfile="erlang.spec"
+newspec1="${tmpdir}/${specfile}.new1"
+newspec2="${tmpdir}/${specfile}.new2"
+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"
+sed '/^# start of autogenerated prep patch list$/,$d' "$newspec1" > "$newspec2"
+cat "$tmpdir/patch-list-prep.txt" >> "$newspec2"
+sed '1,/^# end of autogenerated prep patch list/d' "$newspec1" >> "$newspec2"
+
+# Actually put all changes into git index
+git rm -f otp-00*.patch
+mv "$tmpdir/otp-00"*.patch .
+git add otp-00*.patch
+mv -f "$newspec2" "$specfile"
+git add "$specfile"
 
-echo
-echo "Run \`rm -rf \"$(basename "$tmpdir")\"' when you are finished with the files."
+rm -rf "$tmpdir"
 # End of file.


More information about the scm-commits mailing list