aboutsummaryrefslogtreecommitdiff
path: root/bin/pkgwcp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pkgwcp')
-rwxr-xr-xbin/pkgwcp36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/pkgwcp b/bin/pkgwcp
new file mode 100755
index 0000000..164101c
--- /dev/null
+++ b/bin/pkgwcp
@@ -0,0 +1,36 @@
+#!/bin/sh -e
+
+# pkgwcp -- create a working copy of modified files
+
+if [ $# -eq 0 ]; then
+ echo "usage: ${0##*/} name" 1>&2
+ exit 1
+fi
+
+if [ -e "$1" ]; then
+ echo "${0##*/}: $1 already exists" 1>&2
+ exit 1
+fi
+
+wd=${1%.pkgwcp}.pkgwcp
+mkdir "$wd"
+
+find . -name '*.orig' -type f | {
+ i=0
+ trap '
+ echo "${0##*/}: $i pairs copied" 1>&2
+ [ $i -eq 0 ] && { rm -r "$wd"; exit 1; }
+ echo "$wd"
+ trap -
+ ' INT QUIT EXIT
+ while read -r o; do
+ o=${o#./}
+ o=${o%.orig}.orig
+ n=${o%.orig}
+ dir="$(dirname "$wd/$o")"
+ [ -d "$dir" ] || mkdir -p "$dir"
+ cp "$o" "$wd/$o"
+ cp "$n" "$wd/$n"
+ : $((i++))
+ done
+}