summaryrefslogtreecommitdiff
path: root/third-party/pjproject/apply_patches
diff options
context:
space:
mode:
Diffstat (limited to 'third-party/pjproject/apply_patches')
-rwxr-xr-xthird-party/pjproject/apply_patches39
1 files changed, 39 insertions, 0 deletions
diff --git a/third-party/pjproject/apply_patches b/third-party/pjproject/apply_patches
new file mode 100755
index 000000000..1b72d14b0
--- /dev/null
+++ b/third-party/pjproject/apply_patches
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+if [ "$1" = "-q" ] ; then
+ quiet=1
+ shift
+fi
+
+patchdir=${1:?You must supply a patches directory}
+sourcedir=${2?:You must supply a source directory}
+
+patchdir=`readlink -f $patchdir`
+sourcedir=`readlink -f $sourcedir`
+
+if [ ! -d "$patchdir" ] ; then
+ echo "$patchdir is not a directory" >&2
+ exit 1
+fi
+
+if [ ! -d "$sourcedir" ] ; then
+ echo "$sourcedir is not a directory" >&2
+ exit 1
+fi
+
+if [ ! "$(ls -A $patchdir/*.patch 2>/dev/null)" ] ; then
+ echo "No patches in $patchdir" >&2
+ exit 0
+fi
+
+for patchfile in $patchdir/*.patch ; do
+ patch -d $sourcedir -p1 -s -r- -f -N --dry-run -i "$patchfile" || (echo "Patchfile $(basename $patchfile) failed to apply >&2" ; exit 1) || exit 1
+done
+
+for patchfile in "$patchdir"/*.patch ; do
+ [ -z $quiet ] && echo "Applying patch $(basename $patchfile)"
+ patch -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
+done
+
+exit 0
+