aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rwxr-xr-xconv84
-rwxr-xr-xconvpatch44
-rwxr-xr-xpkgpatch2
-rwxr-xr-xpkgundo2
-rwxr-xr-xsavepatch35
-rwxr-xr-xsum18
-rwxr-xr-xundopatch32
-rwxr-xr-xxpkg26
9 files changed, 119 insertions, 128 deletions
diff --git a/Makefile b/Makefile
index f58e034..e6af53a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,4 @@
+BIN != find . -type f -perm -111 -maxdepth 1
+
install:
- install conv pkgdiffs pkgpatch pkgundo undopatch /usr/local/bin
+ install $(BIN) /usr/local/bin
diff --git a/conv b/conv
deleted file mode 100755
index 39781d7..0000000
--- a/conv
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/sh
-
-# conv -- convert git diff -p output to pkgsrc patch
-
-set -f
-IFS='
-'
-
-{
- echo '$NetBSD$'
- echo
-
- # get patch description
- if [ x"$1" = x"-i" ]; then
- f=`mktemp -t ${0##*/}` || exit 1
- echo 'Edit patch description...' > $f
- </dev/tty >/dev/tty vi $f
- c=`cat $f`
- if [ x"$c" != x"Edit patch description..." ]; then
- printf '%s\n\n' "$c"
- fi
- rm $f
- fi
-
- sed '
- /^diff/d;
- /^index/d;
- s/^--- .*/&/;
- '
-} |
-while read -r line; do
- case "$line" in
- diff*) ;;
- index*) ;;
- '--- a/'*)
- file=${line#--- a/}
- echo -n "--- $file.orig "
- file=$(git rev-parse --show-toplevel)/$file
- echo "$(stat -x "$file")" | sed -n 's/^Access: //p' ;;
- '+++ b/'*)
- echo "+++ ${line#+++ b/}" ;;
- *)
- echo "$line" ;;
- esac
-done | {
-if [ x"$1" = x"-i" ]; then
- # read patch before proceeding
- patch=`cat`
-
- # get patch directory
- dir=$2
- if [ -z "$2" ]; then
- echo -n 'Package name: ' >/dev/tty
- read dir </dev/tty
- fi
- dir=~/patches/$dir
- mkdir -p $dir
-
- # get patch name
- name=$3
- if [ -z "$3" ]; then
- echo -n 'Patch name: ' >/dev/tty
- read name </dev/tty
- fi
-
- case $name in
- patch-*) ;;
- *) name=patch-$name ;;
- esac
-
- # write patch if it doesn't already exist
- if [ -e $dir/$name ]; then
- f=`mktemp -t ${0##*/}` || exit 1
- printf '%s\n' "$patch" > $f
- echo "error: $dir/$name already exists; saving to $f" 1>&2
- exit 1
- else
- printf '%s\n' "$patch" > $dir/$name
- echo $dir/$name 1>&2
- fi
-else
- cat
-fi
-}
diff --git a/convpatch b/convpatch
new file mode 100755
index 0000000..2ebbcd8
--- /dev/null
+++ b/convpatch
@@ -0,0 +1,44 @@
+#!/bin/sh -f
+
+# convpatch -- convert git diff -p output to pkgsrc patch
+
+IFS='
+'
+
+{
+ echo '$NetBSD$'
+ echo
+
+ # get patch description
+ if [ x"$1" = x"-i" ]; then
+ f=`mktemp -t ${0##*/}` || exit 1
+ echo 'Edit patch description...' > $f
+ </dev/tty >/dev/tty vi $f
+ c=`cat $f`
+ if [ x"$c" != x"Edit patch description..." ]; then
+ printf '%s\n\n' "$c"
+ fi
+ rm $f
+ fi
+
+ sed '
+ /^diff/d;
+ /^index/d;
+ s/^--- .*/&/;
+ '
+} |
+while read -r line; do
+ case "$line" in
+ diff*) ;;
+ index*) ;;
+ '--- a/'*)
+ file=${line#--- a/}
+ echo -n "--- $file.orig "
+ file=$(git rev-parse --show-toplevel)/$file
+ echo "$(stat -x "$file")" | sed -n 's/^Access: //p' ;;
+ '+++ b/'*)
+ echo "+++ ${line#+++ b/}" ;;
+ *)
+ echo "$line" ;;
+ esac
+done
diff --git a/pkgpatch b/pkgpatch
index 17af25c..408edc4 100755
--- a/pkgpatch
+++ b/pkgpatch
@@ -4,7 +4,7 @@
move()
{
- echo "${0##*/}: Renaming *.$1 to *.$2..." 1>&2
+ echo "${0##*/}: renaming *.$1 to *.$2..." 1>&2
for orig in *.$1; do
mv -i "$orig" "${orig%.$1}".$2
done
diff --git a/pkgundo b/pkgundo
index 2513bf1..9f3ad25 100755
--- a/pkgundo
+++ b/pkgundo
@@ -9,4 +9,4 @@ for orig in "$@"; do
: $((n++))
mv "$orig" "${orig%.orig}"
done
-echo "${0##*/}: Moved $n files." 2>&1
+echo "${0##*/}: moved $n files" 2>&1
diff --git a/savepatch b/savepatch
new file mode 100755
index 0000000..ae0984f
--- /dev/null
+++ b/savepatch
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# savepatch -- save patch on standard in to ~/patches
+
+root=/home/john/patches
+
+if [ -z "$1" ]; then
+ echo "usage: ${0##*/} patch-name" 1>&2
+ exit 1
+fi
+
+case "$PWD" in
+/usr/pkgsrc/*) dir=$(pwd | cut -d/ -f4,5) || dir= ;;
+/usr/*src/*) dir=${PWD#/usr/} ;;
+*) dir=
+esac
+
+if [ -z "$dir" ]; then
+ echo "${0##*/}: could not determine package" 1>&2
+ printf "package: " 1>&2
+ read dir </dev/tty
+fi
+
+mkdir -p "$root/$dir"
+
+if [ -e "$root/$dir/$1" ]; then
+ printf "%s: %s already exists; overwrite? " "${0##*/}" "$dir/$1" 1>&2
+ read ans </dev/tty
+ case $ans in
+ y*) ;;
+ *) exit 1 ;;
+ esac
+fi
+
+cat > "$root/$dir/$1"
diff --git a/sum b/sum
deleted file mode 100755
index 9469302..0000000
--- a/sum
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# checksum -- create checksum for local patch
-
-#
-# Note that checksums are optional for local patches.
-#
-
-[ -z "$1" ] && { echo usage: $0 patch 1>&2; exit 1; }
-
-localpath=`readlink -f "$1"`
-globalpath=/usr/pkgsrc/${localpath#/home/john/patches/}
-
-[ -e "$globalpath" ] && { echo error: "$globalpath" exists 1>&2; exit 1; }
-doas cp "$localpath" "$globalpath"
-cd "$(dirname "$globalpath")"
-doas make makepatchsum
-doas rm "$globalpath"
diff --git a/undopatch b/undopatch
index e46bc54..82a6ae8 100755
--- a/undopatch
+++ b/undopatch
@@ -1,26 +1,12 @@
-#!/bin/sh
+#!/bin/sh -e
-case "$PWD" in
-/usr/pkgsrc/*/*) ;;
-*) echo not in package directory 1>&2; exit 1 ;;
-esac
+# undopatch -- undo patches applied to pkgsrc build
-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 $(dirname $w)/${f#./work/} $f
+d=$(xpkg)
+echo=echo
+echo "${0##*/}: undoing patches..." 1>&2
+[ x"$1" = x"-x" ] && echo= || echo '(preview, no -x)' 1>&2
+find work -name '*.orig' | while read -r f; do
+ $echo cp "$d/${f#work/}" "${f%.orig}"
+ $echo rm "$f"
done
diff --git a/xpkg b/xpkg
new file mode 100755
index 0000000..c63962b
--- /dev/null
+++ b/xpkg
@@ -0,0 +1,26 @@
+#!/bin/sh -e
+
+# xpkg -- fetch and extract pkgsrc archive
+
+case "$PWD" in
+/usr/pkgsrc/*/*) ;;
+*) echo "${0##*/}: not in package directory" 1>&2; exit 1 ;;
+esac
+
+make fetch
+f=/usr/pkgsrc/distfiles/$(sed -n '/.*(\(.*\)).*/{s//\1/;p;q}' distinfo)
+d=$(tar -tf "$f" | head -1)
+
+opt=
+if [ -e "$d" ]; then
+ printf "%s: $d already exists; overwrite? " "${0##*/}"
+ read ans
+ case $ans in
+ y*) opt=-U ;;
+ *) exit 1 ;;
+ esac
+fi
+
+echo extracting archive... 1>&2
+tar -x $opt -f "$f"
+echo "$d"