diff options
-rw-r--r-- | pkgtools/pkgdiff/Makefile | 52 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/mkpatches.1 | 36 | ||||
-rwxr-xr-x | pkgtools/pkgdiff/files/mkpatches.pl | 95 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/patchdiff.1 | 35 | ||||
-rwxr-xr-x | pkgtools/pkgdiff/files/patchdiff.pl | 108 | ||||
-rwxr-xr-x | pkgtools/pkgdiff/files/pkgdiff | 29 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/pkgdiff.1 | 31 | ||||
-rw-r--r-- | pkgtools/pkgdiff/pkg/COMMENT | 1 | ||||
-rw-r--r-- | pkgtools/pkgdiff/pkg/DESCR | 11 | ||||
-rw-r--r-- | pkgtools/pkgdiff/pkg/PLIST | 10 |
10 files changed, 408 insertions, 0 deletions
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 <wiz@netbsd.org> +.\" 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 <wiz@netbsd.org> +# 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 <<EOF; +usage: $prog [-d output-directory] + -d dirname directory to put the resulting patches into; + defaults to \$WRKDIR/.newpatches +EOF + exit 0; +}; + +# get WRKDIR + +$wrkdir=`make show-var VARNAME=WRKDIR` or + die ("can't find WRKDIR -- wrong dir?"); +chomp($wrkdir); + +if ($opt_d) { + $patchdir = cwd()."/$opt_d"; +} +else { + $patchdir="$wrkdir"."/.newpatches"; +} + +goto_wrksrcdir(); +create_patchdir(); + +# find files + +open(handle, "find . -type f -name \\\*.orig |"); + +# create patches + +while(<handle>) { + 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 <wiz@netbsd.org> +.\" 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 <dillo@giga.or.at> and +# Thomas Klausner <wiz@netbsd.org> +# 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 (<handle>) { + 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(<handle>) { + chomp; + $temp=getfilename($_); + $$hash{$temp}=$_; +# print "put in hash: $temp // $_"; + } + close(handle); +} + +getopts('d:h'); + +if ($opt_h) { + ($prog) = ($0 =~ /([^\/]+)$/); + print STDERR <<EOF; +usage: $prog [-d output-directory] + -d dirname directory to compare the patches in patches/ to; + defaults to \$WRKDIR/.newpatches +EOF + exit 0; +}; + +%orig=(); +%new=(); +$oldpatchdir=cwd(); +chomp($oldpatchdir); +$oldpatchdir=$oldpatchdir."/patches"; + +$wrkdir=`make show-var VARNAME=WRKDIR` or + die ("can't find WRKDIR -- wrong dir?"); +chomp($wrkdir); + +if ($opt_d) { + $newpatchdir = cwd()."/$opt_d"; +} +else { + $newpatchdir="$wrkdir"."/.newpatches"; +} + +if ( ! -d $oldpatchdir) { + print "No old patches found (directory $oldpatchdir not found)\n"; + exit(0); +} +if ( ! -d $newpatchdir ) { + print "No new patches found (directory $newpatchdir not found)\n"; + exit(0); +} +putinhash(\%orig,"$oldpatchdir/patch-*"); +putinhash(\%new,"$newpatchdir/patch-*"); +foreach $patch (keys%orig) { + print "Only in old: $orig{$patch} ($patch)\n" unless defined($new{$patch}); +} +foreach $patch (keys%new) { + if (defined($orig{$patch})) { +# system("diff",$orig{$patch},$new{$patch}); + $diff=`diff $orig{$patch} $new{$patch}`; + $diff=~s/^\dc\d\n..\$NetBSD.*\$\n---\n..\$NetBSD.*\$\n//m; + $diff=~s/^\dc\d\n..\+\+\+.*\n---\n..\+\+\+.*\n//m; + if ($diff) { + print "Comparing $orig{$patch} to $new{$patch}\n$diff"; + } + } else { + print "Only in new: $new{$patch} ($patch)\n" + } +} diff --git a/pkgtools/pkgdiff/files/pkgdiff b/pkgtools/pkgdiff/files/pkgdiff new file mode 100755 index 00000000000..22f08f9b420 --- /dev/null +++ b/pkgtools/pkgdiff/files/pkgdiff @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $NetBSD: pkgdiff,v 1.1.1.1 2000/06/28 01:42:42 wiz Exp $ +# +# Id: pkgdiff,v 1.4 2000/05/14 01:04:54 feyrer Exp feyrer +# +# Usage: pkgdiff oldfile newfile +# +# Will output a patch ready for the NetBSD Pkgs Collection (unified +# diff, plus no RCS IDs if possible). +# +# Copyright (c) 2000 by Hubert Feyrer <hubertf@netbsd.org> +# 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 <hubertf@netbsd.org> +.\" 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 |