Update to 0.96: Add pkgvi, a wrapper that cares to backup files before you

modify them (and that also handles unmodified files in a sane way by deleting
backup files that had no changes).

The pkgvi utility was contributed by Tomasz Luchowski <zuntum@eik.pl>
This commit is contained in:
hubertf 2001-01-17 23:16:44 +00:00
parent 53c8b8c46f
commit 9142ed6c05
6 changed files with 180 additions and 7 deletions

View file

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.6 2000/08/26 04:40:28 hubertf Exp $
# $NetBSD: Makefile,v 1.7 2001/01/17 23:16:44 hubertf Exp $
#
DISTNAME= pkgdiff-0.95
DISTNAME= pkgdiff-0.96
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
@ -29,13 +29,14 @@ NROFF= nroff
.endif
do-build:
.for FILE in mkpatches patchdiff
.for FILE in mkpatches patchdiff
${SED} -e 's|@PREFIX@|${PREFIX}|g' \
< ${FILESDIR}/${FILE}.pl \
> ${WRKSRC}/${FILE}
.endfor
${CP} ${FILESDIR}/pkgdiff ${WRKSRC}
.for FILE in mkpatches patchdiff pkgdiff
${CP} ${FILESDIR}/pkgvi ${WRKSRC}
.for FILE in mkpatches patchdiff pkgdiff pkgvi
${SED} -e 's|@PREFIX@|${PREFIX}|g' \
< ${FILESDIR}/${FILE}.1 \
> ${WRKSRC}/${FILE}.1
@ -43,7 +44,7 @@ do-build:
.endfor
do-install:
.for FILE in mkpatches patchdiff pkgdiff
.for FILE in mkpatches patchdiff pkgdiff pkgvi
${INSTALL_SCRIPT} ${WRKSRC}/${FILE} ${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/${FILE}.0 ${PREFIX}/man/cat1
${INSTALL_MAN} ${WRKSRC}/${FILE}.1 ${PREFIX}/man/man1

99
pkgtools/pkgdiff/files/pkgvi Executable file
View file

@ -0,0 +1,99 @@
#!/bin/sh
# $NetBSD: pkgvi,v 1.1 2001/01/17 23:16:46 hubertf Exp $
#
# Copyright (c) 2001 Tomasz Luchowski. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Tomasz Luchowski for
# the NetBSD Project
# 4. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Usage: pkgvi file
#
# The pkgvi utility runs user's favourite editor (it uses $PKG_EDITOR if
# defined, then it looks for $EDITOR, if none is defined, it uses vi) on
# copy of specified file. If no changes are made in the editor, nothing
# happens, else original file is stored as $filename.orig, and modified
# file is saved as $filename. If it founds $filename.orig, it behaves as
# normal editor.
#
# - Tomasz Luchowski <zuntum@eik.pl>
#
if [ "$PKGEDITOR" != "" ]; then
editor="$PKGEDITOR"
elif [ "$EDITOR" != "" ]; then
editor="$EDITOR"
else
editor="vi"
fi
progname=`basename $0`
if [ $# -eq 0 ]
then
echo echo Usage: $progname file >&2
exit 1
fi
file="$1"
tmp="$file.tmp"
if [ ! -f "$file" ]
then
echo "$progname: $file: No such file"
exit 2
fi
if [ -f $file.orig ]
then
$EDITOR $file
echo "$progname: Backup already exists, for a diff type:"
echo "pkgdiff $file"
exit 0
fi
tmp="$file.$$"
cp $file $tmp
$EDITOR $tmp
if cmp $file $tmp 2>&1 >/dev/null
then
echo File unchanged.
else
mv $file $file.orig
mv $tmp $file
echo $progname: File was modified. For a diff, type:
echo pkgdiff $file
fi
if [ -f $tmp ]
then
rm $tmp
fi

View file

@ -0,0 +1,68 @@
.\" $NetBSD: pkgvi.1,v 1.1 2001/01/17 23:16:46 hubertf Exp $
.\"
.\" Copyright (c) 2001 Tomasz Luchowski. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Tomasz Luchowski
.\" for the NetBSD Project
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Jan 17, 2001
.Dt pkgvi 1
.Os
.Sh NAME
.Nm pkgvi
.Nd run editor and make backup if file is modified
.Sh SYNOPSIS
.Nm
.Ar file
.Sh DESCRIPTION
The
.Nm
utility runs the user's favourite editor
on a copy of specified file.
If no changes are made in the editor, nothing happens.
Else the original file is kept as
.Pa filename.orig ,
and the modified file
is saved as
.Pa filename.
If
.Nm
finds
.Pa filename.orig ,
it behaves as normal editor and changes are only made to
.Pa filename .
.Sh ENVIRONMENT
.Nm
uses $PKG_EDITOR if defined, then it looks for $EDITOR,
and if none is defined, it uses
.Xr vi 1 .
.Pp
.Sh SEE ALSO
.Xr pkgdiff 1 ,
.Sh AUTHOR
The pkgvi utility was written by Tomasz Luchowski <zuntum@eik.pl>.

View file

@ -1 +1 @@
tools to ease creating and maintaining patches for pkgsrc
Tools to ease creating and maintaining patches for pkgsrc

View file

@ -9,3 +9,6 @@ versions of the files had been saved as filename.orig.
patchdiff compares a previously existing set of patches with another
one created by mkpatches, and outputs any changes.
pkgvi makes backup copies if a file is changed, so pkgdiff can be run
on it later, generating a patch for the changes made.

View file

@ -1,10 +1,12 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2000/06/28 01:42:43 wiz Exp $
@comment $NetBSD: PLIST,v 1.2 2001/01/17 23:16:48 hubertf Exp $
bin/mkpatches
bin/patchdiff
bin/pkgdiff
bin/pkgvi
man/cat1/mkpatches.0
man/cat1/patchdiff.0
man/cat1/pkgdiff.0
man/man1/mkpatches.1
man/man1/patchdiff.1
man/man1/pkgdiff.1
man/man1/pkgvi.1