From 02f205dc6aec27ec6c28977f9fc2c30d7b4618f9 Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Mon, 8 Dec 2014 16:27:31 +0200 Subject: [PATCH] ofed_scripts: Added ofed_format_patch.sh This script should be used to refresh backport patches Signed-off-by: Vladimir Sokolovsky --- ofed_scripts/ofed_format_patch.sh | 30 ++++++++++++++++++++++++++++++ ofed_scripts/strip.sh | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 ofed_scripts/ofed_format_patch.sh create mode 100755 ofed_scripts/strip.sh diff --git a/ofed_scripts/ofed_format_patch.sh b/ofed_scripts/ofed_format_patch.sh new file mode 100755 index 0000000..6ce1d1e --- /dev/null +++ b/ofed_scripts/ofed_format_patch.sh @@ -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 index 0000000..f9d15c8 --- /dev/null +++ b/ofed_scripts/strip.sh @@ -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 + -- 2.41.0