diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 16 | ||||
-rwxr-xr-x | undopatch | 26 |
3 files changed, 38 insertions, 6 deletions
@@ -1,2 +1,2 @@ install: - install conv /usr/local/bin + install conv undopatch /usr/local/bin @@ -30,15 +30,21 @@ they are formatted correctly and placed in the correct directory. = Undoing patches = -I haven't tried it yet, but the following command should work: +In order to undo all patches, you need to extract the original +files from the downloaded archive. - cd /usr/pkgsrc/path-to/package/work/ + cd /usr/pkgsrc/path-to/package + w=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo) + cd $(dirname $w) + tar xf $w + cd - find . -name '*.orig' | while read f; do - mv "$f" "${f%.orig}" + f=${f%.orig} + cp $w/${f#work/} $f done -It probably won't work if you've tried to apply patches twice, as -each do-patch theoretically presumably creates new .orig files. +It is not reliable to restore the original files using the .orig +files, as multiple patches may have been applied to the same file. = Rebuilding with new patch = diff --git a/undopatch b/undopatch new file mode 100755 index 0000000..0112101 --- /dev/null +++ b/undopatch @@ -0,0 +1,26 @@ +#!/bin/sh + +case "$PWD" in +/usr/pkgsrc/*/*) ;; +*) echo not in package directory 1>&2; exit 1 ;; +esac + +w=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo) + +done=$(dirname $w)/.$(basename $w).done + +if [ ! -e "$done" ]; then + echo extracting archive... 1>&2 + cd $(dirname $w) + tar xf $w + touch $done + cd - +fi + +echo undoing patches... 1>&2 +cmd=echo\ cp +[ x"$1" = x"-x" ] && cmd=cp || echo '(preview, no -x)' 1>&2 +find . -name '*.orig' | while read f; do + f=${f%.orig} + $cmd $w/${f#work/} $f +done |