aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/pkgdiffex47
-rwxr-xr-xbin/pkgwcp36
2 files changed, 58 insertions, 25 deletions
diff --git a/bin/pkgdiffex b/bin/pkgdiffex
index 9cc1116..2e180fa 100755
--- a/bin/pkgdiffex
+++ b/bin/pkgdiffex
@@ -1,35 +1,32 @@
-#!/bin/sh
+#!/bin/sh -ef
# pkgdiffex -- diff files against existing patches
-if [ $# -eq 0 ]; then
- echo "usage: ${0##*/} file ..." 1>&2
- exit 1
-fi
-
-i=0
-while [ $((++i)) -le $# ]; do
- o=${1%.orig}.orig
- if [ ! -f "$o" ]; then
- echo "${0##*/}: file $o does not exist" 1>&2
- exit 1
- fi
- shift
- set -- "$@" "$o"
-done
+IFS='
+'
+[ x"$1" = x"-q" ] && q=1 || q=
+wc=$(pkgwcp pkgdiffex)
+cd $wc
+
+trap 'echo "${0##*/}: aborted, working copy saved in $wc" 1>&2;
+ trap -' INT QUIT EXIT
-for o in "$@"; do
- mv "${o%.orig}" "${o%.orig}".new # f -> f.new
- cp "$o" "$o"inal # f.orig +> f.original
- cp "$o" "${o%.orig}" # f.orig +> f
+origs=$(find . -name '*.orig' -type f)
+
+for o in $origs; do
+ mv ${o%.orig} ${o%.orig}.new # f -> f.new
+ cp $o ${o%.orig} # f.orig -> f (copy)
done
pkgpatchex
echo '$NetBSD$'
-for o in "$@"; do
- mv "${o%.orig}" "$o" # f -> f.orig
- mv "${o%.orig}".new "${o%.orig}" # f.new -> f
- pkgdiff "${o%.orig}" | sed -n '2,$p'
- mv "$o"inal "$o" # f.original -> f.orig
+for o in $origs; do
+ mv ${o%.orig} $o # f -> f.orig
+ mv ${o%.orig}.new ${o%.orig} # f.new -> f
+ pkgdiff ${o%.orig} | sed -n '2,$p'
done
+
+trap -
+cd -
+rm -r $wc
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
+}