]> git.openfabrics.org - ~emulex/for-vlad/compat-rdma.git/commitdiff
ofed_scripts: Added ofed_format_patch.sh
authorVladimir Sokolovsky <vlad@mellanox.com>
Mon, 8 Dec 2014 14:27:31 +0000 (16:27 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Mon, 8 Dec 2014 14:27:31 +0000 (16:27 +0200)
This script should be used to refresh backport patches

Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
ofed_scripts/ofed_format_patch.sh [new file with mode: 0755]
ofed_scripts/strip.sh [new file with mode: 0755]

diff --git a/ofed_scripts/ofed_format_patch.sh b/ofed_scripts/ofed_format_patch.sh
new file mode 100755 (executable)
index 0000000..6ce1d1e
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+cwd=`dirname $0`
+out=patches_new
+
+if [ -d $out ]; then 
+       if [ "$(ls -A $out)" ]; then
+               echo "output directory $out is not empty. Should delete all files in it?"
+               read -p "Are you sure? " -n 1
+               echo
+               if [[ $REPLY =~ ^[Yy]$ ]]; then
+                       echo "Removing $out"
+                       rm -fr $out
+               else
+                       echo "Aborting"
+                       exit
+               fi
+       fi
+fi
+
+echo "Preparing patches"
+
+git format-patch -o $out --subject-prefix="PATCH" --no-numbered $1
+
+echo "Stripping id's from patches"
+for f in $out/*.patch; do
+       $cwd/strip.sh $f;
+done
+
+rm -f $out/*orig
diff --git a/ofed_scripts/strip.sh b/ofed_scripts/strip.sh
new file mode 100755 (executable)
index 0000000..f9d15c8
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+tmpfile='mktemp' || exit 1
+
+first=`head -1 $1`
+if [ ! "${first:0:5}" == "From " ]; then
+       echo Missing From at first line, abort
+       exit 1
+fi
+last=`tail -3 $1 | head -1`
+if [ ! "$last" == "-- " ]; then
+       echo Missing -- at 3rd last line, abort
+       exit 1
+fi
+
+head -n -3 $1 | \
+       sed -e "s/^index [[:xdigit:]]\{7\}\.\.[[:xdigit:]]\{7\} [[:digit:]]\{6\}$/index xxxxxxx..xxxxxxx xxxxxx/" | \
+       grep -v "^From " | \
+       grep -v "^Date: " > $tmpfile && mv $1 $1.orig && mv $tmpfile $1
+