Whamcloud - gitweb
- bring in akpm's patch management scripts and a first cut at
[fs/lustre-release.git] / lustre / kernel_patches / scripts / rpatch
diff --git a/lustre/kernel_patches/scripts/rpatch b/lustre/kernel_patches/scripts/rpatch
new file mode 100755 (executable)
index 0000000..42e1533
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+. patchfns >/dev/null || . /usr/lib/patch-scripts/patchfns >/dev/null || { \
+       echo "Impossible to find my library 'patchfns'."
+       echo "Check your install, or go to the right directory"
+       exit 1
+}
+
+do_remove()
+{
+       if patch -R -p1 -s -i $P/patches/"$1".patch
+       then
+               true
+       else
+               echo SOMETHING WENT WRONG
+               exit 1
+       fi
+}
+
+kill_old_ones()
+{
+       FILES=$(cat $P/pc/$1.pc)
+       for file in $FILES
+       do
+               rm -f "$file"~"$1"
+       done
+}
+
+usage()
+{
+       echo "Usage: rpatch patchname"
+       exit 1
+}
+
+if [ $# == 0 ]
+then
+       usage
+fi
+
+PATCH_NAME=$(stripit $1)
+
+warn_top_current
+
+if is_applied "$PATCH_NAME"
+then
+       if can_remove "$PATCH_NAME"
+       then
+               do_remove "$PATCH_NAME"
+               kill_old_ones "$PATCH_NAME"
+               remove_from_db "$PATCH_NAME"
+       else
+               echo "$PATCH_NAME" does not remove cleanly
+               exit 1
+       fi
+else
+       echo "$PATCH_NAME" is not applied
+       exit 1
+fi
+
+top=$(top_patch)
+if [ x"$top" == x ]
+then
+       msg="no patches applied"
+else
+       msg="now at $top"
+fi
+
+echo Removed $PATCH_NAME, $msg
+