Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions

14
pkgtools/pkgdiff/DESCR Normal file
View File

@@ -0,0 +1,14 @@
This package contains four tools to ease creating and maintaining
patches for pkgsrc: mkpatches, patchdiff, pkgdiff, and pkgvi.
pkgdiff compares two files (like diff) and produces an output file
that can be used in pkgsrc.
mkpatches automatically generates a set of patches, if the original
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.

78
pkgtools/pkgdiff/Makefile Normal file
View File

@@ -0,0 +1,78 @@
# $NetBSD: Makefile,v 1.80 2013/05/31 12:41:46 wiz Exp $
#
DISTNAME= pkgdiff-1.4
PKGREVISION= 2
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
MAINTAINER= wiz@NetBSD.org
HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html
COMMENT= Tools to create, maintain, and send back patches for pkgsrc
LICENSE= 2-clause-bsd AND original-bsd
PKG_INSTALLATION_TYPES= overwrite pkgviews
NO_CONFIGURE= yes
WRKSRC= ${WRKDIR}
USE_LANGUAGES= # empty
USE_TOOLS+= perl:run
MAKE_ENV+= PKGSRCDIR=${_PKGSRCDIR:Q}
.include "../../mk/bsd.prefs.mk"
BUILD_DEFS+= MANINSTALL
.if ${OPSYS} == "SunOS" || ${OPSYS} == "OSF1"
DEPENDS+= diffutils-[0-9]*:../../devel/diffutils
DIFF?= ${PREFIX}/bin/gdiff
.else
DIFF?= diff
.endif
.if ${OPSYS} == "SunOS"
MANINSTALL= catinstall
.endif
INSTALLATION_DIRS= bin
.if !empty(MANINSTALL:Mcatinstall)
INSTALLATION_DIRS+= ${PKGMANDIR}/cat1
.endif
.if !empty(MANINSTALL:Mmaninstall)
INSTALLATION_DIRS+= ${PKGMANDIR}/man1
.endif
do-build:
.for f in mkpatches patchdiff
${SED} -e 's|@PREFIX@|${PREFIX}|g' \
-e 's|@PERL5@|${PERL5}|g' \
-e 's|@MAKE@|${MAKE}|g' \
< ${FILESDIR}/${f}.pl \
> ${WRKSRC}/${f}
.endfor
${SED} -e 's|@DIFF@|${DIFF}|g' \
-e 's|@SH@|${SH}|g' \
< ${FILESDIR}/pkgdiff \
> ${WRKSRC}/pkgdiff
${CP} ${FILESDIR}/pkgvi ${WRKSRC}
${CP} ${FILESDIR}/feedback-patches ${WRKSRC}
.if !empty(MANINSTALL:Mcatinstall)
. for f in mkpatches patchdiff pkgdiff pkgvi feedback-patches
${CP} ${FILESDIR}/${f}.0 ${WRKSRC}/${f}.0
. endfor
.endif
do-install:
.for f in mkpatches patchdiff pkgdiff pkgvi feedback-patches
${INSTALL_SCRIPT} ${WRKSRC}/${f} ${DESTDIR}${PREFIX}/bin
. if !empty(MANINSTALL:Mcatinstall)
${INSTALL_MAN} ${WRKSRC}/${f}.0 ${DESTDIR}${PREFIX}/${PKGMANDIR}/cat1
. endif
. if !empty(MANINSTALL:Mmaninstall)
${INSTALL_MAN} ${FILESDIR}/${f}.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
. endif
.endfor
.include "../../mk/bsd.pkg.mk"

16
pkgtools/pkgdiff/PLIST Normal file
View File

@@ -0,0 +1,16 @@
@comment $NetBSD: PLIST,v 1.2 2004/11/23 22:00:48 hubertf Exp $
bin/feedback-patches
bin/mkpatches
bin/patchdiff
bin/pkgdiff
bin/pkgvi
man/cat1/feedback-patches.0
man/cat1/mkpatches.0
man/cat1/patchdiff.0
man/cat1/pkgdiff.0
man/cat1/pkgvi.0
man/man1/feedback-patches.1
man/man1/mkpatches.1
man/man1/patchdiff.1
man/man1/pkgdiff.1
man/man1/pkgvi.1

View File

@@ -0,0 +1,101 @@
#!/bin/sh
#
# Send back NetBSD patches
#
#
# Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Hubert Feyrer <hubertf@NetBSD.org>
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
#
PKGSRCBASE=/usr/pkgsrc
pkg_f=$1
to=$2
if [ "$pkg_f" = "." ]
then
pkg_f=`pwd`
fi
if [ "$pkg_f" = "" ]
then
echo "Usage: $0 category/pkg [maintainer@software.org]"
exit 1
fi
pkg=`echo $pkg_f | sed -e 's,.*/pkgsrc/,,' -e 's,/$,,'`
cd $PKGSRCBASE/$pkg
if [ ! -d patches -o `ls patches 2>/dev/null | grep -v orig | grep -v BAK | wc -l` -eq 0 ]
then
echo '***' Package $pkg has no patches, exiting.
exit 0
fi
pkgname=`make show-var VARNAME=PKGNAME | sed -e 's,nb.*$,,'`
tmp=`mktemp -t feedback-patches`
(
cat <<EOTXT
Hi!
below you will find some patches against $pkgname that are
currently part of the NetBSD Packages Collection, pkgsrc, to get your
software build properly on NetBSD and maybe some other platforms. We'd
be pleased if you could include as much of these patches into your next
release as possible, thanks!
FWIW, your software has a webpage at the NetBSD site, see
http://www.NetBSD.org/packages/$pkg/README.html
See http://www.NetBSD.org/docs/software/packages.html
to learn more about the NetBSD Packages Collection, to find out
more about the NetBSD operating system, see http://www.NetBSD.org/.
--- 8X --- 8X --- 8X --- 8X --- 8X --- 8X --- 8X --- 8X --- 8X --- 8X ---
EOTXT
find $PKGSRCBASE/$pkg/patches/. -type f -print \
| grep -v CVS | xargs cat
) >$tmp
if [ "$to" = "" ]
then
cat $tmp
rm $tmp
else
echo Mailing patches for $pkgname...
cat $tmp | mail -v -s "Patches for $pkgname" $to
rm $tmp
echo done.
fi

View File

@@ -0,0 +1,59 @@
FEEDBACK-PATCHES(1) NetBSD General Commands Manual FEEDBACK-PATCHES(1)
NNAAMMEE
ffeeeeddbbaacckk--ppaattcchheess -- help sending pkgsrc patches back
SSYYNNOOPPSSIISS
ffeeeeddbbaacckk--ppaattcchheess _c_a_t_e_g_o_r_y_/_p_k_g [maintainer@software.org]
DDEESSCCRRIIPPTTIIOONN
The ffeeeeddbbaacckk--ppaattcchheess script is intended to help sending back patches in
the NetBSD Packages Collection, pkgsrc, back to the maintainers of the
original package, for inclusion into future releases. The given
_c_a_t_e_g_o_r_y_/_p_k_g is either a path relative to the pkgsrc base directory, or
an absolute patch, which will be stripped the base directory. A pathname
of _. will be expanded to the current directory, which is useful when the
current working directory is in a package's directory in pkgsrc.
If an email address is given, the patches will be sent to that address,
with some nice words. If no email address is given, the mail will only be
displayed instead of sent.
EEXXAAMMPPLLEESS
The command:
feedback-patches audio/gqmpeg
will display a mail that can be sent to the gqmpeg people with patches to
include.
feedback-patches somecat/dunno whoever@foobar.baz
will invoke mail(1) to send the patches back immediately.
feedback-patches /usr/pkgsrc/somecat/dunno whoever@foobar.baz
works just as well, you can use either full path or path relative to
pkgsrc base when specifying a package. As you're usually already in the
pkg's directory for finding out the contact address (probably by looking
at the HOMEPAGE variable in the pkg's Makefile), you can also do:
cd .../category/pkg
feedback-patches `pwd` whoever@foobar.baz
or
cd .../category/pkg
feedback-patches . whoever@foobar.baz
SSEEEE AALLSSOO
pkgdiff(1), mkpatches(1)
AAUUTTHHOORRSS
The feedback-patches utility was written by Hubert Feyrer
<hubertf@NetBSD.org>.
BBUUGGSS
Currently the pkgsrc base directory is hardcoded to _/_u_s_r_/_p_k_g_s_r_c.
NetBSD 5.0 Sep 29, 2003 NetBSD 5.0

View File

@@ -0,0 +1,99 @@
.\" $NetBSD: feedback-patches.1,v 1.3 2011/02/16 11:58:30 wiz Exp $
.\"
.\" Copyright (c) 2003-2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Hubert Feyrer <hubertf@NetBSD.org>
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 September 29, 2003
.Dt FEEDBACK-PATCHES 1
.Os
.Sh NAME
.Nm feedback-patches
.Nd "help sending pkgsrc patches back"
.Sh SYNOPSIS
.Nm
.Ar category/pkg
.Op maintainer@software.org
.Sh DESCRIPTION
The
.Nm
script is intended to help sending back patches in the
.Nx
Packages Collection, pkgsrc, back to the maintainers
of the original package, for inclusion into future releases.
The given
.Pa category/pkg
is either a path relative to the pkgsrc base directory,
or an absolute patch, which will be stripped the base
directory.
A pathname of
.Pa \&.
will be expanded to the current directory, which is useful
when the current working directory is in a package's
directory in pkgsrc.
.Pp
If an email address is given, the patches will be sent to that
address, with some nice words.
If no email address is given, the mail will only be displayed instead
of sent.
.Sh EXAMPLES
The command:
.Pp
.Dl feedback-patches audio/gqmpeg
.Pp
will display a mail that can be sent to the gqmpeg people
with patches to include.
.Pp
.Dl feedback-patches somecat/dunno whoever@foobar.baz
.Pp
will invoke
.Xr mail 1
to send the patches back immediately.
.Pp
.Dl feedback-patches /usr/pkgsrc/somecat/dunno whoever@foobar.baz
.Pp
works just as well, you can use either full path or path relative
to pkgsrc base when specifying a package.
As you're usually already in the pkg's directory for finding out the
contact address (probably by looking at the HOMEPAGE variable in the
pkg's Makefile), you can also do:
.Pp
.Dl cd .../category/pkg
.Dl feedback-patches `pwd` whoever@foobar.baz
.Pp
or
.Pp
.Dl cd .../category/pkg
.Dl feedback-patches \ . whoever@foobar.baz
.Sh SEE ALSO
.Xr mkpatches 1 ,
.Xr pkgdiff 1
.Sh AUTHORS
The feedback-patches utility was written by
.An Hubert Feyrer Aq hubertf@NetBSD.org .
.Sh BUGS
Currently the pkgsrc base directory is hardcoded to
.Pa /usr/pkgsrc .

View File

@@ -0,0 +1,39 @@
MKPATCHES(1) NetBSD General Commands Manual MKPATCHES(1)
NNAAMMEE
mmkkppaattcchheess -- create patch files appropriate for pkgsrc
SSYYNNOOPPSSIISS
mmkkppaattcchheess [--cc | --rr] [--hhvv]
DDEESSCCRRIIPPTTIIOONN
mmkkppaattcchheess is a perl script that simplifies creating patches from a
changed work tree if for each changed file the original was kept with an
added extension ``.orig''.
mmkkppaattcchheess must be called from the package's main directory, that is
_$_{_P_K_G_S_R_C_}_/_c_a_t_e_g_o_r_y_/_p_r_o_g_r_a_m. It then proceeds to find all files that
match the pattern ``*.orig''. Each of these is then compared to the
changed file of the same name (with no ``.orig'' extension) using
pkgdiff(1).
The resulting patches are saved in the package's patches directory (usu-
ally _p_a_t_c_h_e_s_/) and can be easily compared to the currently existing set
using patchdiff(1) or ccvvss ddiiffff.
Supported options are:
--cc Clean up backup patches of previous runs. Use this after you're
finished working on the patch set and committed it.
--hh Show a short usage.
--rr Revert the changes. Removes the new patches and puts the original
patches back.
--vv More verbose output.
SSEEEE AALLSSOO
cvs(1), patchdiff(1), pkgdiff(1)
NetBSD 5.0 January 31, 2011 NetBSD 5.0

View File

@@ -0,0 +1,102 @@
.\" $NetBSD: mkpatches.1,v 1.8 2011/06/26 12:11:39 wiz Exp $
.\"
.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org>
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR
.\" ``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 AUTHOR
.\" 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 June 26, 2011
.Dt MKPATCHES 1
.Os
.Sh NAME
.Nm mkpatches
.Nd create patch files appropriate for pkgsrc
.Sh SYNOPSIS
.Nm
.Op Fl hvw
.Oo Fl c | Fl r Oc
.Op Fl D | Fl d Ar dir
.Sh DESCRIPTION
.Nm
is a perl script that simplifies creating patches from a changed work
tree if for each changed file the original was kept with an added
extension
.Dq .orig .
.Pp
.Nm
must be called from the package's main directory, that is
.Pa ${PKGSRC}/category/program .
It then proceeds to find all files that
match the pattern
.Dq *.orig .
Each of these is then compared to the
changed file of the same name (with no
.Dq .orig
extension) using
.Xr pkgdiff 1 .
.Pp
The resulting patches are saved in the package's patches directory
(usually
.Pa patches/ )
and can be easily compared to the currently existing set using
.Xr patchdiff 1
or
.Ic "cvs diff" .
.Pp
Supported options are:
.Bl -tag -width 3n
.It Fl c
Clean up backup patches of previous runs.
Use this after you're finished working on the patch set and committed
it.
.It Fl D
Use
.Pa $WRKDIR/.newpatches
for patches.
See
.Fl d
for more details.
.It Fl d Ar dir
Use
.Ar dir
for patches.
Copies any existing patches there on the first run and then
creates or updates patches only there.
Use this e.g. if you have a read-only pkgsrc.
.It Fl h
Show a short usage.
.It Fl r
Revert the changes.
Removes the new patches and puts the original patches back.
.It Fl v
More verbose output.
.It Fl w
Look for changes in
.Pa $WRKDIR
instead of the default
.Pa $WRKSRC .
Usually not needed and slower.
.El
.Sh SEE ALSO
.Xr cvs 1 ,
.Xr patchdiff 1 ,
.Xr pkgdiff 1

View File

@@ -0,0 +1,278 @@
#!@PERL5@
#
# $NetBSD: mkpatches.pl,v 1.17 2011/06/26 12:11:39 wiz Exp $
#
# mkpatches: creates a set of patches patch-aa, patch-ab, ...
# in work/.newpatches by looking for *.orig files in and below
# WRKDIR and comparing them to the corresponding changed file. All
# files are then referrenced relative to WRKSRC.
#
# It should be called from the packages directory,
# e.g. /usr/pkgsrc/example/test
#
# It retains the naming and header (RCS Id and comment) from the
# patches directory.
#
# Copyright (c) 2000, 2011 by Thomas Klausner <wiz@NetBSD.org>
# 2004 by Dieter Baron <dillo@NetBSD.org>
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS
# ``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 AUTHORS
# 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.
#
use Getopt::Std;
use Cwd;
use File::Spec;
my $patchdir;
my $old_patchdir;
my $wrkdir;
my $wrksrc;
my %old_filename;
my %old_header;
# create patchdir, or empty it if already existing
sub create_patchdir {
if (! -d $patchdir) {
mkdir($patchdir, 0755);
if (-d $origpatchdir && "$origpatchdir" != "$patchdir") {
system("cp", "$origpatchdir/p*", "$patchdir");
}
}
}
# read command line arguments
undef($opt_c);
undef($opt_D);
undef($opt_d);
undef($opt_h);
undef($opt_r);
undef($opt_v);
undef($opt_w);
getopts('cDd:hrvw');
if ($opt_h) {
($prog) = ($0 =~ /([^\/]+)$/);
print STDERR <<EOF;
usage: $prog [-hvw] [-c | -r] [-D | -d dir]
-c commit -- clean up old patches backups
-d dir create patches in this directory
-D create patches in \$WRKDIR/.newpatches
-h show this help
-r revert -- remove new patches, put old patches back
-v verbose - list .orig files as processed
-w look for changes in \$WRKDIR instead of \$WRKSRC
EOF
exit 0;
};
if ($opt_d && $opt_D) {
print STDERR "-D and -d conflict, choose one\n";
exit 1;
}
# get some pkgsrc variables
$wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or
die ("can't find WRKSRC -- wrong dir?");
chomp($wrksrc);
$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or
die ("can't find WRKDIR -- wrong dir?");
chomp($wrkdir);
$origpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or
die ("can't find PATCHDIR -- wrong dir?");
chomp($origpatchdir);
if ($opt_D) {
$patchdir = "$wrkdir/.newpatches";
} elsif ($opt_d) {
if (-d "/$opt_d") {
$patchdir = $opt_d;
} else {
my $pwd = cwd();
chomp($pwd);
$patchdir = "$pwd/$opt_d";
}
} else {
$patchdir = $origpatchdir;
}
if ($opt_c) {
open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
foreach (<HANDLE>) {
chomp;
unlink $_;
}
exit 0;
}
if ($opt_r) {
open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
foreach (<HANDLE>) {
chomp;
my $orig = $_;
my $new = $_;
$new =~ s/.orig$//;
rename $orig, $new;
if (! -s $new) {
unlink $new;
}
}
exit 0;
}
create_patchdir();
move_away_old_patches();
analyze_old_patches();
chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)");
# find files
if ($opt_w) {
open(HANDLE, "find ${wrkdir} -type f -name \\\*.orig |");
} else {
open(HANDLE, "find ${wrksrc} -type f -name \\\*.orig |");
}
# create patches
foreach (sort <HANDLE>) {
my ($path, $complete);
my ($new, $old);
chomp();
$path = $_;
$complete = $path;
$complete =~ s/.orig$//;
$new = File::Spec->abs2rel($complete, $wrksrc);
$old = File::Spec->abs2rel($path, $wrksrc);
if (-f $complete) {
$patchfile = patch_name($new);
if ($opt_v) {
print "$patchfile -> $complete\n";
}
$diff=`pkgdiff $old $new 2>&1`;
if ($?) {
print "$old: $diff";
}
make_patch($old, $new, $patchfile, $diff);
} else {
print ("$new doesn't exist, though $old does\n");
}
}
sub analyze_old_patches
{
my $filename;
my $origfilename;
my $patch;
my $name;
my $checkname;
%old_header = ();
%old_filename = ();
open(HANDLE, "ls $patchdir/patch-* 2>/dev/null |");
while ($origfilename = <HANDLE>) {
chomp $origfilename;
next if not $origfilename =~ m/.orig$/;
$filename = $origfilename;
$filename =~ s/.orig$//;
$checkname = $origfilename;
if (! -s $checkname) {
$checkname = $filename;
}
$patch = `sed '/^\+\+\+/ q' $checkname`;
if (!($patch =~ m/^\+\+\+ ([^\t\n]*)(\n$|\t)/m)) {
warn "cannot extract filename from patch $checkname";
next;
}
$name = $1;
$name =~ s/^\.\///; # ignore leading "./", if any.
$patch =~ s/\n--- .*/\n/s;
$old_header{$name} = $patch;
$filename =~ s!.*/!!;
$old_filename{$name} = $filename;
}
close(HANDLE);
}
sub move_away_old_patches
{
open(HANDLE, "ls $patchdir/patch-* 2>/dev/null |");
while ($filename = <HANDLE>) {
chomp $filename;
next if $filename =~ m/.orig$/;
if (-f "$filename" and not -f "$filename.orig") {
rename "$filename", "$filename.orig";
}
}
}
sub patch_name # filename
{
my $name = shift;
my ($pname, $l);
if (defined($old_filename{$name})) {
return $old_filename{$name};
}
$name =~ s,_,__,g;
$name =~ s,/,_,g;
$name = "patch-$name";
return $name;
}
sub make_patch # new old patchfile diff
{
my ($old, $new, $patchfile, $diff) = @_;
if ("$diff" eq "") {
print "$old and $new don't differ\n";
if (-f "$patchdir/$patchfile.orig") {
rename "$patchdir/$patchfile.orig", "$patchdir/$patchfile";
}
}
if (not -f "$patchdir/$patchfile.orig") {
system("touch", "$patchdir/$patchfile.orig");
}
if (defined($old_header{$new})) {
$diff =~ s/^.*\n(--- )/$1/s;
$diff = $old_header{$new} . $diff;
}
open(HANDLE, "> $patchdir/$patchfile");
print HANDLE $diff;
close(HANDLE);
}

View File

@@ -0,0 +1,22 @@
PATCHDIFF(1) NetBSD General Commands Manual PATCHDIFF(1)
NNAAMMEE
ppaattcchhddiiffff -- compare sets of patches
SSYYNNOOPPSSIISS
ppaattcchhddiiffff
DDEESSCCRRIIPPTTIIOONN
ppaattcchhddiiffff is a perl script that simplifies comparing a set of previously
existing patches with a new one created with mkpatches(1).
ppaattcchhddiiffff must be called from the package's main directory, that is
_$_{_P_K_G_S_R_C_}_/_c_a_t_e_g_o_r_y_/_p_r_o_g_r_a_m. For each patch existing in either the
_p_a_t_c_h_e_s directory, it is compared with its backup file (_p_a_t_c_h_-_f_o_o_._o_r_i_g)
using diff(1). If no relevant differences are found, the original patch
is restored.
SSEEEE AALLSSOO
diff(1), patchdiff(1), pkgdiff(1)
NetBSD 5.0 January 31, 2011 NetBSD 5.0

View File

@@ -0,0 +1,71 @@
.\" $NetBSD: patchdiff.1,v 1.7 2011/03/04 15:57:07 wiz Exp $
.\"
.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org>
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR
.\" ``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 AUTHOR
.\" 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 February 20, 2011
.Dt PATCHDIFF 1
.Os
.Sh NAME
.Nm patchdiff
.Nd compare sets of patches
.Sh SYNOPSIS
.Nm
.Op Fl D | Fl d Ar dir
.Sh DESCRIPTION
.Nm
is a perl script that simplifies comparing a set of previously
existing patches with a new one created with
.Xr mkpatches 1 .
.Pp
.Nm
must be called from the package's main directory, that is
.Pa ${PKGSRC}/category/program .
For each patch existing in either the
.Pa patches
directory, it is compared with its backup file
.Pq Pa patch-foo.orig
using
.Xr diff 1 .
If no relevant differences are found, the original patch is restored.
.Pp
If the
.Fl d
option is used,
.Nm
looks for patches in
.Ar dir
instead of the default
.Pa patches
directory.
If the
.Fl D
option is used,
.Nm
looks in
.Pa $WRKDIR/.newpatches .
.Sh SEE ALSO
.Xr diff 1 ,
.Xr mkpatches 1 ,
.Xr pkgdiff 1

View File

@@ -0,0 +1,154 @@
#!@PERL5@
#
# $NetBSD: patchdiff.pl,v 1.15 2011/03/04 15:57:07 wiz Exp $
#
# patchdiff: compares a set of patches in the patch dir with their predecessors
#
# Copyright (c) 2000, 2011 by Dieter Baron <dillo@giga.or.at> and
# Thomas Klausner <wiz@NetBSD.org>
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHORS
# ``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 AUTHORS
# 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.
#
use Getopt::Std;
use Cwd;
use File::Spec;
my $patchdir, $patchdir;
my $wrkdir, $thisdir;
my %orig, %new;
sub getfilename {
my $fname=shift;
local $_;
local *handle;
open(handle, $fname);
while (<handle>) {
next unless m/^\+\+\+[ ]([^ ]*)/;
close(handle);
$_ = $1;
chomp();
s/^\.\///; # ignore leading "./", if any.
return $_;
}
close(handle);
return undef;
}
sub putinhash {
my $hash=shift;
my $files=shift;
my $temp;
local *handle;
open(handle, "ls $files|");
while(<handle>) {
chomp;
$temp=getfilename($_);
$$hash{$temp}=File::Spec->abs2rel($_, $thisdir);
}
close(handle);
}
getopts('Dd:h');
if ($opt_h) {
($prog) = ($0 =~ /([^\/]+)$/);
print STDERR <<EOF;
usage: $prog [-D | -d dir]
-D look at patches in \$WRKDIR/.newpatches
-d dir look at patches in this directory
EOF
exit 0;
};
%orig=();
%new=();
$thisdir=cwd();
chomp($thisdir);
$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or
die ("can't find WRKDIR -- wrong dir?");
chomp($wrkdir);
$origpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or
die ("can't find PATCHDIR -- wrong dir?");
chomp($origpatchdir);
if ($opt_D) {
$patchdir = "$wrkdir/.newpatches";
} elsif ($opt_d) {
if (-d "/$opt_d") {
$patchdir = $opt_d;
} else {
$patchdir = "$thisdir/$opt_d";
}
} else {
$patchdir = $origpatchdir;
}
if ( ! -d $patchdir) {
print "No patches found (directory $patchdir not found)\n";
exit(0);
}
open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
foreach (sort <HANDLE>) {
$orig = $_;
chomp($orig);
$new = $orig;
$new =~ s/.orig$//;
if (! -f "$new") {
print "File $new removed\n";
} else {
# system("diff",$orig{$patch},$new{$patch});
$diff=`diff $orig $new`;
# the following regex try to eliminate uninteresting differences
# The general structure of the diffs-to-be-removed is:
# 25c25
# < --- something.orig 2008-08-08 08:08
# ---
# > --- something.orig 2008-08-08 18:08
#
# In particular, remove hunks with:
# . NetBSD RCS Id tag differences
$diff=~s/^[\d,]+c[\d,]+\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m;
# . the name of the input file changed
# (if the name of the output file has changed, patches
# won't get matched up anyway)
# . time of the input and/or output file changed
# . line numbers changed
$diff=~s/^[\d,]+c[\d,]+\n(?:.\s---\s(:?\S+).*\n)?(?:.\s\+\+\+\s(\S+).*\n)?(?:.\s@@\s(?:.*)\s@@.*\n)?---\n(?:.\s---\s\S+.*\n)?(?:.\s\+\+\+\s\S+.*\n)?(?:.\s@@\s.*\s@@.*\n)?//m;
# . only line numbers changed
$diff=~s/^[\d,]+c[\d,]+\n.\s@@\s.*\s@@.*\n---\n.\s@@\s.*\s@@.*\n//mg;
if ($diff) {
if (! -s $orig) {
print "New file $new\n";
} else {
print "Comparing $orig to $new\n$diff";
}
} else {
# restore previous version to get rid of uninteresting diffs
rename "$orig", "$new";
}
}
}

138
pkgtools/pkgdiff/files/pkgdiff Executable file
View File

@@ -0,0 +1,138 @@
#!@SH@
#
# $NetBSD: pkgdiff,v 1.22 2012/09/16 18:09:53 dholland Exp $
#
# Usage: pkgdiff newfile
# pkgdiff oldfile newfile
#
# Will output a patch ready for the NetBSD Pkgs Collection (unified
# diff, plus no RCS IDs if possible). If only newfile is given,
# oldfile is assumed as newfile.orig.
#
#
# Copyright (c) 2011 by Thomas Klausner <wiz@NetBSD.org>
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR
# ``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 AUTHOR
# 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.
#
#
# Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Hubert Feyrer <hubertf@NetBSD.org>
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
#
# Ensure we always use the same timezone to avoid spurious metadata diffs
export TZ=UTC
if [ $# -le 1 ]
then
if [ -f "$1.orig" ]; then
old="$1.orig"
new="$1"
else
echo $0: need at least one argument >&2
exit 1;
fi
else
old="$1"
new="$2"
fi
basename_new="`basename $new`"
dodiff() {
case x"$basename_new" in
xconfigure)
@DIFF@ -I '\(echo .*as_me:[0-9][0-9]*:\|echo .*configure:[0-9][0-9]*:\|line [0-9][0-9]* "configure\)' -I '\(Avoid regenerating within pkgsrc\|exit 0\)' $*
;;
xMakefile*)
@DIFF@ -I '\(localedir.*=.*localedir\|localedir.*=.*share/locale\)' $*
;;
*)
@DIFF@ $*
esac
}
dogrep() {
egrep $* '\$(NetBSD|Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State)(:.*)?\$'
}
case x"$PKGDIFF_FMT" in x)
lines=3
PKGDIFF_FMT="-p"
while [ `dodiff "$PKGDIFF_FMT" -U $lines "$old" "$new" | dogrep -c` != 0 ]
do
lines=`expr $lines - 1`
if [ $lines = 0x -a x"$PKGDIFF_FMT" = x-p ]; then
# Try without -p instead
lines=3
PKGDIFF_FMT=""
continue
fi
if [ $lines = 0 ]; then
echo "Cannot strip away RCS IDs, please handle manually!" >&2
echo "These are the matching lines:" >&2
dodiff "$PKGDIFF_FMT" -U $lines "$old" "$new" | dogrep |\
sed -e 's/^/ /' >&2
echo "Setting PKGDIFF_FMT might help." >&2
echo "Otherwise you may need to run diff by hand." >&2
exit 1
fi
done
PKGDIFF_FMT="${PKGDIFF_FMT} -U $lines"
;;
esac # PKGDIFF_FMT unset or null
if dodiff -q "$PKGDIFF_FMT" "$old" "$new" > /dev/null
then
:
else
echo '$'NetBSD'$'
echo ''
# Strip out the date on the +++ line to reduce needless
# differences in regenerated patches
dodiff "$PKGDIFF_FMT" "$old" "$new" | sed -e 's:^\(+++ [^ ]*\) .*:\1:'
fi

View File

@@ -0,0 +1,27 @@
PKGDIFF(1) NetBSD General Commands Manual PKGDIFF(1)
NNAAMMEE
ppkkggddiiffff -- diff files in a way appropriate for pkgsrc
SSYYNNOOPPSSIISS
ppkkggddiiffff [_o_p_t_i_o_n_s] _o_l_d_f_i_l_e _n_e_w_f_i_l_e
DDEESSCCRRIIPPTTIIOONN
The ppkkggddiiffff utility runs diff(1) on the named files, and generates output
on stdout that is appropriate to be put as patch file into pkgsrc. An
empty NetBSD RCS ID is output first, and some effort is made to ensure
that the generated patch does not include any RCS IDs.
_o_p_t_i_o_n_s can be any options that are allowed for diff(1).
EENNVVIIRROONNMMEENNTT
PPKKGGDDIIFFFF__FFMMTT
The flags passed to diff(1) when generating patches. If not set, the
flags --uu and --pp are used. Though only unified format patches are used in
pkgsrc as proper patches, sometimes it can be useful to have context or
plain diffs available.
SSEEEE AALLSSOO
cvs(1), diff(1), mkpatches(1), patch(1), pkgvi(1)
NetBSD 5.0 Jun 14, 2003 NetBSD 5.0

View File

@@ -0,0 +1,75 @@
.\" $NetBSD: pkgdiff.1,v 1.6 2011/02/16 11:58:30 wiz Exp $
.\"
.\" Copyright (c) 2000-2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Hubert Feyrer <hubertf@NetBSD.org>
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 June 14, 2003
.Dt PKGDIFF 1
.Os
.Sh NAME
.Nm pkgdiff
.Nd diff files in a way appropriate for pkgsrc
.Sh SYNOPSIS
.Nm
.Op Ar options
.Ar oldfile
.Ar newfile
.Sh DESCRIPTION
The
.Nm
utility runs
.Xr diff 1
on the named files, and generates output on stdout that is appropriate
to be put as patch file into pkgsrc.
An empty
.Nx
RCS ID is output
first, and some effort is made to ensure that the generated patch does
not include any RCS IDs.
.Pp
.Ar options
can be any options that are allowed for
.Xr diff 1 .
.Sh ENVIRONMENT
.Ss PKGDIFF_FMT
The flags passed to
.Xr diff 1
when generating patches.
If not set, the flags
.Fl u
and
.Fl p
are used.
Though only unified format patches are used in pkgsrc as proper
patches, sometimes it can be useful to have context or plain diffs
available.
.Sh SEE ALSO
.Xr cvs 1 ,
.Xr diff 1 ,
.Xr mkpatches 1 ,
.Xr patch 1 ,
.Xr pkgvi 1

110
pkgtools/pkgdiff/files/pkgvi Executable file
View File

@@ -0,0 +1,110 @@
#!/bin/sh
# $NetBSD: pkgvi,v 1.11 2011/08/23 21:47:18 abs 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.
#
if [ "$PKGEDITOR" != "" ]; then
editor="$PKGEDITOR"
elif [ "$EDITOR" != "" ]; then
editor="$EDITOR"
else
editor="vi"
fi
progname=`basename $0`
if [ $# -eq 0 ]
then
echo Usage: $progname file >&2
exit 1
fi
file="$1"
cmd=""
case x"$file" in
x+*) cmd="$1"; shift ; file="$1" ;;
esac
if [ ! -f "$file" ]
then
echo "$progname: $file: No such file"
exit 2
fi
if [ -f "$file.orig" ]
then
chmod u+w "$file"
$editor $cmd "$file"
echo "$progname: Backup already exists. For a diff type:"
echo "pkgdiff $file"
exit 0
fi
bfile=`basename "$file"`
dfile=`dirname "$file"`
ext=`echo $bfile | awk -F. '{ print $NF }'`
if [ "$bfile" != "$ext" ]; then
tmp="$dfile/$bfile.$$.$ext"
else
tmp="$file.$$"
fi
cp "$file" "$tmp"
chmod u+w "$tmp"
if [ $? -ne 0 ]; then
echo "$progname: unable to create temporary file"
exit 1
fi
$editor $cmd "$tmp"
if cmp "$file" "$tmp" >/dev/null 2>&1
then
echo "$progname: 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
if [ -f "$tmp~" ]
then
rm "$tmp~"
fi

View File

@@ -0,0 +1,33 @@
PKGVI(1) NetBSD General Commands Manual PKGVI(1)
NNAAMMEE
ppkkggvvii -- run editor and make backup of given file if necessary
SSYYNNOOPPSSIISS
ppkkggvvii [+command] _f_i_l_e
DDEESSCCRRIIPPTTIIOONN
The ppkkggvvii 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 _f_i_l_e_n_a_m_e_._o_r_i_g, and the modified file is saved as
_f_i_l_e_n_a_m_e. If ppkkggvvii finds _f_i_l_e_n_a_m_e_._o_r_i_g, it behaves as normal editor and
changes are only made to _f_i_l_e_n_a_m_e, not affecting _f_i_l_e_n_a_m_e_._o_r_i_g. In both
cases ppkkggvvii ensures that the file to be edited is writable by the user.
Available option:
++ccoommmmaanndd
This option is passed unmodified as first argument to the editor.
This is useful when the editor used is vi(1).
EENNVVIIRROONNMMEENNTT
ppkkggvvii uses $PKGEDITOR if defined, then it looks for $EDITOR, if neither
is defined, it uses vi(1).
SSEEEE AALLSSOO
pkgdiff(1)
AAUUTTHHOORRSS
The pkgvi utility was written by Tomasz Luchowski <zuntum@netbsd.org>.
NetBSD 5.0 Aug 1, 2006 NetBSD 5.0

View File

@@ -0,0 +1,81 @@
.\" $NetBSD: pkgvi.1,v 1.9 2011/02/16 11:58:30 wiz 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 August 1, 2006
.Dt PKGVI 1
.Os
.Sh NAME
.Nm pkgvi
.Nd "run editor and make backup of given file if necessary"
.Sh SYNOPSIS
.Nm
.Op +command
.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 ,
not affecting
.Pa filename.orig .
In both cases
.Nm
ensures that the file to be edited is writable by the user.
.Pp
Available option:
.Bl -tag -width indent
.It Cm +command
This option is passed unmodified as first argument to the editor.
This is useful when the editor used is
.Xr vi 1 .
.El
.Sh ENVIRONMENT
.Nm
uses $PKGEDITOR if defined, then it looks for $EDITOR,
if neither is defined, it uses
.Xr vi 1 .
.Sh SEE ALSO
.Xr pkgdiff 1
.Sh AUTHORS
The pkgvi utility was written by
.An Tomasz Luchowski Aq zuntum@netbsd.org .