From 830afa08f95e2026f97b62d22484c27d42c104b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 18 Jul 2021 12:47:23 +0200 Subject: Add pkgundo script --- Makefile | 2 +- conv | 1 + pkgpatch | 18 ++++++++++-------- pkgundo | 12 ++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100755 pkgundo diff --git a/Makefile b/Makefile index b70a1bd..f58e034 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ install: - install conv pkgdiffs pkgpatch undopatch /usr/local/bin + install conv pkgdiffs pkgpatch pkgundo undopatch /usr/local/bin diff --git a/conv b/conv index c277760..39781d7 100755 --- a/conv +++ b/conv @@ -2,6 +2,7 @@ # conv -- convert git diff -p output to pkgsrc patch +set -f IFS=' ' diff --git a/pkgpatch b/pkgpatch index 8d68c20..17af25c 100755 --- a/pkgpatch +++ b/pkgpatch @@ -2,12 +2,14 @@ # pkgpatch -- patch but don't overwrite original files -for orig in *.orig; do - mv -i "$orig" "${orig%.orig}".~1~ -done - +move() +{ + echo "${0##*/}: Renaming *.$1 to *.$2..." 1>&2 + for orig in *.$1; do + mv -i "$orig" "${orig%.$1}".$2 + done +} + +move orig ~1~ +trap 'move ~1~ orig; trap -' INT QUIT TERM EXIT patch -Vt -F3 "$@" - -for orig in *.~1~; do - mv -i "$orig" "${orig%.~1~}".orig -done diff --git a/pkgundo b/pkgundo new file mode 100755 index 0000000..2513bf1 --- /dev/null +++ b/pkgundo @@ -0,0 +1,12 @@ +#!/bin/sh + +# pkgundo -- restore original files + +[ $# -eq 0 ] && { echo "usage: ${0##*/} orig ..." 2>&1; exit 1; } + +n= +for orig in "$@"; do + : $((n++)) + mv "$orig" "${orig%.orig}" +done +echo "${0##*/}: Moved $n files." 2>&1 -- cgit v1.2.3