summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-06-30 13:22:09 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2014-06-30 13:22:09 +0000
commit91c0d2401bc30f404dafb0c07e35f3d6750d1474 (patch)
treef23271cb53a4ecde0eb97829e6b5c02f725c646f /tools
parent83c1dac837d777db8e54d3343fceffa0df314df8 (diff)
downloadmpfr-91c0d2401bc30f404dafb0c07e35f3d6750d1474.tar.gz
Added tools/build-patch zsh script to transform a raw patch into a patch
to be put on the MPFR www server. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9115 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tools')
-rwxr-xr-xtools/build-patch74
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/build-patch b/tools/build-patch
new file mode 100755
index 000000000..3b52a5de0
--- /dev/null
+++ b/tools/build-patch
@@ -0,0 +1,74 @@
+#!/usr/bin/env zsh
+
+# Utility to transform a raw patch into a patch to be put on the MPFR
+# www server. Assume that update-version is in the same directory.
+# MPFR_CURRENT_DIR should contain a path to a directory corresponding
+# to /misc/www/mpfr-current in the MPFR repository; if not set, it is
+# assumed to be "$HOME/mpfr-misc/www/mpfr-current".
+
+set -e
+prg="$0"
+upv="$prg:h/update-version"
+
+if [[ $# -gt 3 || $1 == -* ]] then
+ echo "Usage: $prg [ <patch> [ <patchlevel> [ <patchname> ] ] ]" >&2
+ exit 1
+fi
+
+: ${MPFR_CURRENT_DIR:=$(realpath ~/mpfr-misc/www/mpfr-current)}
+base=$MPFR_CURRENT_DIR:t
+version=${base#mpfr-}
+
+if [[ -z "$version" ]] then
+ echo "${prg}: bad version" >&2
+ exit 2
+fi
+
+checkobj()
+{
+ if [[ -e "$1" ]] then
+ echo "${prg}: $1 is in the way" >&2
+ exit 3
+ fi
+}
+checkobj "$base"
+checkobj "$base-a"
+checkobj "$base-b"
+checkobj "base-patch"
+
+atool -eqx -- "$MPFR_CURRENT_DIR/$base.tar.xz"
+pushd "$base"
+touch -a "$MPFR_CURRENT_DIR/allpatches"
+patch -N -Z -p1 < "$MPFR_CURRENT_DIR/allpatches"
+: > PATCHES
+popd
+mv -T "$base" "$base-a"
+cp -aT "$base-a" "$base-b"
+
+if [[ $# -ge 1 ]] then
+ patchfile=$(realpath "$1")
+ pushd "$base-b"
+ echo "Applying patch $1"
+ if grep -q '^--- mpfr.*/' "$patchfile"; then
+ p=1
+ else
+ p=0
+ fi
+ patch --no-backup-if-mismatch -p$p < "$patchfile"
+ if [[ $# -ge 2 ]] then
+ ~/wd/mpfr/tools/update-version ${(s:.:)version} "p$2" -
+ if [[ $# -ge 3 ]] then
+ echo "$3" >> PATCHES
+ fi
+ fi
+ popd
+ set +e
+ TZ=UTC diff -Naurd "$base-a" "$base-b" > "$base-patch"
+ if [[ $? -ne 1 ]] then
+ echo "${prg}: something has gone wrong with diff" >&2
+ exit 4
+ fi
+ set -e
+ rm -r "$base-a" "$base-b"
+ echo "OK, patch in $base-patch"
+fi