From 649e5521a6f48cd896a0179fb1a386852f61734a Mon Sep 17 00:00:00 2001 From: wiz Date: Wed, 28 Jun 2000 01:42:42 +0000 Subject: Import of pkgdiff & friends, some tools for easier patch creation and maintenance. --- pkgtools/pkgdiff/Makefile | 52 +++++++++++++++++ pkgtools/pkgdiff/files/mkpatches.1 | 36 ++++++++++++ pkgtools/pkgdiff/files/mkpatches.pl | 95 +++++++++++++++++++++++++++++++ pkgtools/pkgdiff/files/patchdiff.1 | 35 ++++++++++++ pkgtools/pkgdiff/files/patchdiff.pl | 108 ++++++++++++++++++++++++++++++++++++ pkgtools/pkgdiff/files/pkgdiff | 29 ++++++++++ pkgtools/pkgdiff/files/pkgdiff.1 | 31 +++++++++++ pkgtools/pkgdiff/pkg/COMMENT | 1 + pkgtools/pkgdiff/pkg/DESCR | 11 ++++ pkgtools/pkgdiff/pkg/PLIST | 10 ++++ 10 files changed, 408 insertions(+) create mode 100644 pkgtools/pkgdiff/Makefile create mode 100644 pkgtools/pkgdiff/files/mkpatches.1 create mode 100755 pkgtools/pkgdiff/files/mkpatches.pl create mode 100644 pkgtools/pkgdiff/files/patchdiff.1 create mode 100755 pkgtools/pkgdiff/files/patchdiff.pl create mode 100755 pkgtools/pkgdiff/files/pkgdiff create mode 100644 pkgtools/pkgdiff/files/pkgdiff.1 create mode 100644 pkgtools/pkgdiff/pkg/COMMENT create mode 100644 pkgtools/pkgdiff/pkg/DESCR create mode 100644 pkgtools/pkgdiff/pkg/PLIST (limited to 'pkgtools') diff --git a/pkgtools/pkgdiff/Makefile b/pkgtools/pkgdiff/Makefile new file mode 100644 index 00000000000..6ec3b378c2c --- /dev/null +++ b/pkgtools/pkgdiff/Makefile @@ -0,0 +1,52 @@ +# $NetBSD: Makefile,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $ +# + +DISTNAME= pkgdiff-0.90 +CATEGORIES= pkgtools devel +MASTER_SITES= # empty +DISTFILES= # empty + +MAINTAINER= wiz@netbsd.org +HOMEPAGE= http://www.netbsd.org/Documentation/netbsd/Packages.txt + +USE_PERL5= YES + +EXTRACT_ONLY= # empty +NO_WRKSUBDIR= yes +NO_CHECKSUM= yes +NO_PATCH= yes +NO_CONFIGURE= yes + +PKGSRCDIR?= ${.CURDIR}/../.. +MAKE_ENV= PKGSRCDIR=${PKGSRCDIR} + +.include "../../mk/bsd.prefs.mk" + +.if ${OPSYS} == "SunOS" +NROFF= gnroff +.else +NROFF= nroff +.endif + +do-build: +.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 + ${SED} -e 's|@PREFIX@|${PREFIX}|g' \ + < ${FILESDIR}/${FILE}.1 \ + > ${WRKSRC}/${FILE}.1 + ${NROFF} -mandoc ${WRKSRC}/${FILE}.1 >${WRKSRC}/${FILE}.0 +.endfor + +do-install: +.for FILE in mkpatches patchdiff pkgdiff + ${INSTALL_SCRIPT} ${WRKSRC}/${FILE} ${PREFIX}/bin + ${INSTALL_MAN} ${WRKSRC}/${FILE}.0 ${PREFIX}/man/cat1 + ${INSTALL_MAN} ${WRKSRC}/${FILE}.1 ${PREFIX}/man/man1 +.endfor + +.include "../../mk/bsd.pkg.mk" diff --git a/pkgtools/pkgdiff/files/mkpatches.1 b/pkgtools/pkgdiff/files/mkpatches.1 new file mode 100644 index 00000000000..24f87af8b2a --- /dev/null +++ b/pkgtools/pkgdiff/files/mkpatches.1 @@ -0,0 +1,36 @@ +.\" $NetBSD: mkpatches.1,v 1.1.1.1 2000/06/28 01:42:43 wiz Exp $ +.\" +.\" Copyright (c) 2000 by Thomas Klausner +.\" All Rights Reserved. Absolutely no warranty. +.\" +.Dd June 25, 2000 +.Dt mkpatches +.Os +.Sh NAME +.Nm mkpatches +.Nd create patch files appropriate for pkgsrc +.Sh SYNOPSIS +.Nm +.Op Fl d Ar output-directory +.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 '.orig'. + +.Nm +must be called from the package's main directory, that is +$PKGSRC/category/program. 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 +.Xr pkgdiff 1 . + +The resulting patches are saved in the directory $WRKDIR/.newpatches +or the directory specified after +.Fl d , +and can be easily compared to the currently existing set using +.Xr patchdiff 1 . +.Pp +.Sh SEE ALSO +.Xr patchdiff 1 , +.Xr pkgdiff 1 diff --git a/pkgtools/pkgdiff/files/mkpatches.pl b/pkgtools/pkgdiff/files/mkpatches.pl new file mode 100755 index 00000000000..ac5118c2d06 --- /dev/null +++ b/pkgtools/pkgdiff/files/mkpatches.pl @@ -0,0 +1,95 @@ +#!@PREFIX@/bin/perl +# +# $NetBSD: mkpatches.pl,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $ +# +# mkpatches: creates a set of patches patch-aa, patch-ab, ... +# in work/.newpatches by looking for *.orig files in and below +# WRKSRC and comparing them to the corresponding changed file. It +# should be called from the packages directory, +# e.g. /usr/pkgsrc/example/test +# +# Copyright (c) 2000 by Thomas Klausner +# All Rights Reserved. Absolutely no warranty. +# + +use Getopt::Std; +use Cwd; + +my $patchdir; +my $wrkdir; +my $l=0; + +# change to WRKSRC + +sub goto_wrksrcdir { + my $wrksrc; + + $wrksrc=`make show-var VARNAME=WRKSRC` or + die ("can't find WRKSRC -- wrong dir?"); + chomp($wrksrc); + + chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); +} + +# create patchdir, or empty it if already existing + +sub create_patchdir { + if ( -d $patchdir ) { + unlink "$patchdir/*"; + } else { + mkdir($patchdir, 0755); + } +} + +# read command line arguments + +getopts('d:h'); + +if ($opt_h) { + ($prog) = ($0 =~ /([^\/]+)$/); + print STDERR <) { + my $path, $complete; + chomp(); + $path = $_; + $path =~ s/^..//; + $complete = $path; + $complete =~ s/.orig$//; + if ( -f $complete ) { + $patchfile = ("aa".."zz")[$l]; + $patchfile =~ s/^/patch-/; + system("pkgdiff $path $complete > $patchdir/$patchfile"); + } else { + print ("$complete doesn't exist, though $path does"); + } + $l++; +} diff --git a/pkgtools/pkgdiff/files/patchdiff.1 b/pkgtools/pkgdiff/files/patchdiff.1 new file mode 100644 index 00000000000..c12db91e81d --- /dev/null +++ b/pkgtools/pkgdiff/files/patchdiff.1 @@ -0,0 +1,35 @@ +.\" $NetBSD: patchdiff.1,v 1.1.1.1 2000/06/28 01:42:43 wiz Exp $ +.\" +.\" Copyright (c) 2000 by Thomas Klausner +.\" All Rights Reserved. Absolutely no warranty. +.\" +.Dd June 25, 2000 +.Dt patchdiff +.Os +.Sh NAME +.Nm patchdiff +.Nd compare sets of patches +.Sh SYNOPSIS +.Nm +.Op Fl d Ar output-directory +.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 . + +.Nm +must be called from the package's main directory, that is +$PKGSRC/category/program. For each patch existing in either the +patches or the $WRKDIR/.newpatches directory (the second of which can +be overridden by the argument of the +.Fl d +option), a matching patch is +looked for in the other directory, and, if one is found, the two are +compared with +.Xr diff 1 . +.Pp +.Sh SEE ALSO +.Xr diff 1 , +.Xr patchdiff 1 , +.Xr pkgdiff 1 diff --git a/pkgtools/pkgdiff/files/patchdiff.pl b/pkgtools/pkgdiff/files/patchdiff.pl new file mode 100755 index 00000000000..21e39b996a4 --- /dev/null +++ b/pkgtools/pkgdiff/files/patchdiff.pl @@ -0,0 +1,108 @@ +#!@PREFIX@/bin/perl +# +# $NetBSD: patchdiff.pl,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $ +# +# patchdiff: compares a set of patches patch-aa, patch-ab, ... in +# $WRKDIR/.newpatches in the with another set in patches. +# +# Copyright (c) 2000 by Dieter Baron and +# Thomas Klausner +# All Rights Reserved. Absolutely no warranty. + +use Getopt::Std; +use Cwd; + +my $oldpatchdir, $newpatchdir; +my $wrkdir; +my %orig, %new; + +# change to WRKDIR + +sub goto_wrkdir { + chdir $wrkdir or die ("can't cd to WRKDIR ($wrkdir)"); +} + +sub getfilename { + my $fname=shift; + local $_; + local *handle; + open(handle, $fname); + while () { + next unless m/^\+\+\+ ([^ ]*)/; + close(handle); + return $1; + } + close(handle); + return undef; +} + +sub putinhash { + my $hash=shift; + my $files=shift; + my $temp; + local *handle; + open(handle, "ls $files|"); + while() { + chomp; + $temp=getfilename($_); + $$hash{$temp}=$_; +# print "put in hash: $temp // $_"; + } + close(handle); +} + +getopts('d:h'); + +if ($opt_h) { + ($prog) = ($0 =~ /([^\/]+)$/); + print STDERR < +# All Rights Reserved. Absolutely no warranty. +# + +echo '$'NetBSD'$' +echo '' + +lines=3 +while [ `diff -u -$lines $@ | egrep -c '\\$(NetBSD|Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State)'` != 0 ] +do + lines=`expr $lines - 1` + if [ $lines = 0 ]; then + echo "Cannot strip away RCS IDs, please handle manually!" + exit 1 + fi +done + +diff -u -$lines $@ diff --git a/pkgtools/pkgdiff/files/pkgdiff.1 b/pkgtools/pkgdiff/files/pkgdiff.1 new file mode 100644 index 00000000000..0a772e9f1c3 --- /dev/null +++ b/pkgtools/pkgdiff/files/pkgdiff.1 @@ -0,0 +1,31 @@ +.\" $NetBSD: pkgdiff.1,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $ +.\" +.\" Copyright (c) 2000 by Hubert Feyrer +.\" All Rights Reserved. Absolutely no warranty. +.\" +.Dd May 14, 2000 +.Dt pkgdiff +.Os +.Sh NAME +.Nm pkgdiff +.Nd diff files in a way appropriate for pkgsrc +.Sh SYNOPSIS +.Nm +.Op Ar diff(1) 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 NetBSD RCS ID is output +first, and some effort is made to ensure that the generated patch does +not include any RCS IDs. +.Pp +.Sh SEE ALSO +.Xr cvs 1 , +.Xr diff 1 , +.Xr mkpatches 1 , +.Xr patch 1 diff --git a/pkgtools/pkgdiff/pkg/COMMENT b/pkgtools/pkgdiff/pkg/COMMENT new file mode 100644 index 00000000000..34ab28474ca --- /dev/null +++ b/pkgtools/pkgdiff/pkg/COMMENT @@ -0,0 +1 @@ +tools to ease creating and maintaining patches for pkgsrc diff --git a/pkgtools/pkgdiff/pkg/DESCR b/pkgtools/pkgdiff/pkg/DESCR new file mode 100644 index 00000000000..af98c238b37 --- /dev/null +++ b/pkgtools/pkgdiff/pkg/DESCR @@ -0,0 +1,11 @@ +This package contains three tools to ease creating and maintaining +patches for pkgsrc: mkpatches, patchdiff, and pkgdiff. + +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. diff --git a/pkgtools/pkgdiff/pkg/PLIST b/pkgtools/pkgdiff/pkg/PLIST new file mode 100644 index 00000000000..bae5c2448bf --- /dev/null +++ b/pkgtools/pkgdiff/pkg/PLIST @@ -0,0 +1,10 @@ +@comment $NetBSD: PLIST,v 1.1.1.1 2000/06/28 01:42:43 wiz Exp $ +bin/mkpatches +bin/patchdiff +bin/pkgdiff +man/cat1/mkpatches.0 +man/cat1/patchdiff.0 +man/cat1/pkgdiff.0 +man/man1/mkpatches.1 +man/man1/patchdiff.1 +man/man1/pkgdiff.1 -- cgit v1.2.3