aboutsummaryrefslogtreecommitdiff
path: root/undopatch
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-15 08:42:18 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-15 08:42:18 +0200
commit71a90d55f7797d504970c691213f2fd48bb8ab54 (patch)
tree7e2fbbe687063cd8b414e41752f1d4322d3ac50d /undopatch
parentc3e44d48fb5d67904561bd99daa3b4e4ee6619dd (diff)
downloadpatches-71a90d55f7797d504970c691213f2fd48bb8ab54.tar.gz
Add undopatch script
Diffstat (limited to 'undopatch')
-rwxr-xr-xundopatch26
1 files changed, 26 insertions, 0 deletions
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