]> git.ipfire.org Git - pakfire.git/commitdiff
patch: Add support for reverting patches.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Jan 2012 14:16:20 +0000 (15:16 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Jan 2012 14:16:20 +0000 (15:16 +0100)
tools/patch

index 927b8803aeccf86b6e59382e04b23a5bf948a8be..4d4c2ae5776b3562b069358c395602474d267f40 100755 (executable)
@@ -46,10 +46,24 @@ for patch in ${patches}; do
 
        # Get right -p1 option.
        case "${patch}" in
-               *.patch[0-9])
+               *.patch[0-9]|*.patch[0-9]R)
+                       _patch="${patch}"
                        # Get patch level from file name.
-                       level=${patch:$(( ${#patch} - 1))}
-                       options="${options} -p${level}"
+                       while [ ${#_patch} -gt 0 ]; do
+                               last_pos=$(( ${#_patch} - 1 ))
+                               last_char=${_patch:${last_pos}}
+                               _patch=${_patch:0:${last_pos}}
+
+                               case "${last_char}" in
+                                       [0-9])
+                                               options="${options} -p${last_char}"
+                                               break
+                                               ;;
+                                       R)
+                                               options="${options} -R"
+                                               ;;
+                               esac
+                       done
                        ;;
                *.patch|*.diff)
                        # Default is -p1.