Fri Mar 4 15:57:07 2011 UTC ()
Add "-D"/"-d dir" options to mkpatches and patchdiff.

-D provides the previous behaviour of creating patches in $WRKDIR/.newpatches
-d dir specifies the directory where the patches will be created.

Requested by Aleksey Cheusov for read-only pkgsrc checkouts.

Fix minor bugs while here.

Bump version.


(wiz)
diff -r1.72 -r1.73 pkgsrc/pkgtools/pkgdiff/Makefile
diff -r1.6 -r1.7 pkgsrc/pkgtools/pkgdiff/files/mkpatches.1
diff -r1.6 -r1.7 pkgsrc/pkgtools/pkgdiff/files/patchdiff.1
diff -r1.15 -r1.16 pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl
diff -r1.14 -r1.15 pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl

cvs diff -r1.72 -r1.73 pkgsrc/pkgtools/pkgdiff/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkgdiff/Makefile 2011/02/02 23:35:51 1.72
+++ pkgsrc/pkgtools/pkgdiff/Makefile 2011/03/04 15:57:07 1.73
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.72 2011/02/02 23:35:51 wiz Exp $ 1# $NetBSD: Makefile,v 1.73 2011/03/04 15:57:07 wiz Exp $
2# 2#
3 3
4DISTNAME= pkgdiff-1.0 4DISTNAME= pkgdiff-1.1
5CATEGORIES= pkgtools devel 5CATEGORIES= pkgtools devel
6MASTER_SITES= # empty 6MASTER_SITES= # empty
7DISTFILES= # empty 7DISTFILES= # empty
8 8
9MAINTAINER= wiz@NetBSD.org 9MAINTAINER= wiz@NetBSD.org
10HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html 10HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html
11COMMENT= Tools to create, maintain, and send back patches for pkgsrc 11COMMENT= Tools to create, maintain, and send back patches for pkgsrc
12LICENSE= 2-clause-bsd AND original-bsd 12LICENSE= 2-clause-bsd AND original-bsd
13 13
14PKG_INSTALLATION_TYPES= overwrite pkgviews 14PKG_INSTALLATION_TYPES= overwrite pkgviews
15PKG_DESTDIR_SUPPORT= user-destdir 15PKG_DESTDIR_SUPPORT= user-destdir
16 16
17NO_CONFIGURE= yes 17NO_CONFIGURE= yes

cvs diff -r1.6 -r1.7 pkgsrc/pkgtools/pkgdiff/files/mkpatches.1 (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkgdiff/files/mkpatches.1 2011/02/02 23:34:48 1.6
+++ pkgsrc/pkgtools/pkgdiff/files/mkpatches.1 2011/03/04 15:57:07 1.7
@@ -1,49 +1,50 @@ @@ -1,49 +1,50 @@
1.\" $NetBSD: mkpatches.1,v 1.6 2011/02/02 23:34:48 wiz Exp $ 1.\" $NetBSD: mkpatches.1,v 1.7 2011/03/04 15:57:07 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org> 3.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org>
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE. 25.\" POSSIBILITY OF SUCH DAMAGE.
26.\" 26.\"
27.Dd January 31, 2011 27.Dd February 20, 2011
28.Dt MKPATCHES 1 28.Dt MKPATCHES 1
29.Os 29.Os
30.Sh NAME 30.Sh NAME
31.Nm mkpatches 31.Nm mkpatches
32.Nd create patch files appropriate for pkgsrc 32.Nd create patch files appropriate for pkgsrc
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Nm 34.Nm
35.Oo Fl c | Fl r Oc 
36.Op Fl hv 35.Op Fl hv
 36.Oo Fl c | Fl r Oc
 37.Op Fl D | Fl d Ar dir
37.Sh DESCRIPTION 38.Sh DESCRIPTION
38.Nm 39.Nm
39is a perl script that simplifies creating patches from a changed work 40is a perl script that simplifies creating patches from a changed work
40tree if for each changed file the original was kept with an added 41tree if for each changed file the original was kept with an added
41extension 42extension
42.Dq .orig . 43.Dq .orig .
43.Pp 44.Pp
44.Nm 45.Nm
45must be called from the package's main directory, that is 46must be called from the package's main directory, that is
46.Pa ${PKGSRC}/category/program . 47.Pa ${PKGSRC}/category/program .
47It then proceeds to find all files that 48It then proceeds to find all files that
48match the pattern 49match the pattern
49.Dq *.orig . 50.Dq *.orig .
@@ -57,25 +58,39 @@ The resulting patches are saved in the p @@ -57,25 +58,39 @@ The resulting patches are saved in the p
57(usually 58(usually
58.Pa patches/ ) 59.Pa patches/ )
59and can be easily compared to the currently existing set using 60and can be easily compared to the currently existing set using
60.Xr patchdiff 1 61.Xr patchdiff 1
61or 62or
62.Ic "cvs diff" . 63.Ic "cvs diff" .
63.Pp 64.Pp
64Supported options are: 65Supported options are:
65.Bl -tag -width 3n 66.Bl -tag -width 3n
66.It Fl c 67.It Fl c
67Clean up backup patches of previous runs. 68Clean up backup patches of previous runs.
68Use this after you're finished working on the patch set and committed 69Use this after you're finished working on the patch set and committed
69it. 70it.
 71.It Fl D
 72Use
 73.Pa $WRKDIR/.newpatches
 74for patches.
 75See
 76.Fl d
 77for more details.
 78.It Fl d Ar dir
 79Use
 80.Ar dir
 81for patches.
 82Copies any existing patches there on the first run and then
 83creates or updates patches only there.
 84Use this e.g. if you have a read-only pkgsrc.
70.It Fl h 85.It Fl h
71Show a short usage. 86Show a short usage.
72.It Fl r 87.It Fl r
73Revert the changes. 88Revert the changes.
74Removes the new patches and puts the original patches back. 89Removes the new patches and puts the original patches back.
75.It Fl v 90.It Fl v
76More verbose output. 91More verbose output.
77.El 92.El
78.Sh SEE ALSO 93.Sh SEE ALSO
79.Xr cvs 1 , 94.Xr cvs 1 ,
80.Xr patchdiff 1 , 95.Xr patchdiff 1 ,
81.Xr pkgdiff 1 96.Xr pkgdiff 1

cvs diff -r1.6 -r1.7 pkgsrc/pkgtools/pkgdiff/files/patchdiff.1 (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkgdiff/files/patchdiff.1 2011/02/02 23:34:48 1.6
+++ pkgsrc/pkgtools/pkgdiff/files/patchdiff.1 2011/03/04 15:57:07 1.7
@@ -1,54 +1,71 @@ @@ -1,54 +1,71 @@
1.\" $NetBSD: patchdiff.1,v 1.6 2011/02/02 23:34:48 wiz Exp $ 1.\" $NetBSD: patchdiff.1,v 1.7 2011/03/04 15:57:07 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org> 3.\" Copyright (c) 2000-2011 by Thomas Klausner <wiz@NetBSD.org>
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE. 25.\" POSSIBILITY OF SUCH DAMAGE.
26.\" 26.\"
27.Dd January 31, 2011 27.Dd February 20, 2011
28.Dt PATCHDIFF 1 28.Dt PATCHDIFF 1
29.Os 29.Os
30.Sh NAME 30.Sh NAME
31.Nm patchdiff 31.Nm patchdiff
32.Nd compare sets of patches 32.Nd compare sets of patches
33.Sh SYNOPSIS 33.Sh SYNOPSIS
34.Nm 34.Nm
 35.Op Fl D | Fl d Ar dir
35.Sh DESCRIPTION 36.Sh DESCRIPTION
36.Nm 37.Nm
37is a perl script that simplifies comparing a set of previously 38is a perl script that simplifies comparing a set of previously
38existing patches with a new one created with 39existing patches with a new one created with
39.Xr mkpatches 1 . 40.Xr mkpatches 1 .
40.Pp 41.Pp
41.Nm 42.Nm
42must be called from the package's main directory, that is 43must be called from the package's main directory, that is
43.Pa ${PKGSRC}/category/program . 44.Pa ${PKGSRC}/category/program .
44For each patch existing in either the 45For each patch existing in either the
45.Pa patches 46.Pa patches
46directory, it is compared with its backup file 47directory, it is compared with its backup file
47.Pq Pa patch-foo.orig 48.Pq Pa patch-foo.orig
48using 49using
49.Xr diff 1 . 50.Xr diff 1 .
50If no relevant differences are found, the original patch is restored. 51If no relevant differences are found, the original patch is restored.
 52.Pp
 53If the
 54.Fl d
 55option is used,
 56.Nm
 57looks for patches in
 58.Ar dir
 59instead of the default
 60.Pa patches
 61directory.
 62If the
 63.Fl D
 64option is used,
 65.Nm
 66looks in
 67.Pa $WRKDIR/.newpatches .
51.Sh SEE ALSO 68.Sh SEE ALSO
52.Xr diff 1 , 69.Xr diff 1 ,
53.Xr patchdiff 1 , 70.Xr mkpatches 1 ,
54.Xr pkgdiff 1 71.Xr pkgdiff 1

cvs diff -r1.15 -r1.16 pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl 2011/02/02 23:35:11 1.15
+++ pkgsrc/pkgtools/pkgdiff/files/mkpatches.pl 2011/03/04 15:57:07 1.16
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!@PERL5@ 1#!@PERL5@
2# 2#
3# $NetBSD: mkpatches.pl,v 1.15 2011/02/02 23:35:11 wiz Exp $ 3# $NetBSD: mkpatches.pl,v 1.16 2011/03/04 15:57:07 wiz Exp $
4# 4#
5# mkpatches: creates a set of patches patch-aa, patch-ab, ... 5# mkpatches: creates a set of patches patch-aa, patch-ab, ...
6# in work/.newpatches by looking for *.orig files in and below 6# in work/.newpatches by looking for *.orig files in and below
7# WRKDIR and comparing them to the corresponding changed file. All 7# WRKDIR and comparing them to the corresponding changed file. All
8# files are then referrenced relative to WRKSRC. 8# files are then referrenced relative to WRKSRC.
9# 9#
10# It should be called from the packages directory, 10# It should be called from the packages directory,
11# e.g. /usr/pkgsrc/example/test 11# e.g. /usr/pkgsrc/example/test
12# 12#
13# It retains the naming and header (RCS Id and comment) from the 13# It retains the naming and header (RCS Id and comment) from the
14# patches directory. 14# patches directory.
15# 15#
16# Copyright (c) 2000, 2011 by Thomas Klausner <wiz@NetBSD.org> 16# Copyright (c) 2000, 2011 by Thomas Klausner <wiz@NetBSD.org>
@@ -36,66 +36,96 @@ @@ -36,66 +36,96 @@
36# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39# POSSIBILITY OF SUCH DAMAGE. 39# POSSIBILITY OF SUCH DAMAGE.
40# 40#
41 41
42use Getopt::Std; 42use Getopt::Std;
43use Cwd; 43use Cwd;
44use File::Spec; 44use File::Spec;
45 45
46my $patchdir; 46my $patchdir;
47my $old_patchdir; 47my $old_patchdir;
48my $wrkdir; 48my $wrkdir;
 49my $wrksrc;
49my %old_filename; 50my %old_filename;
50my %old_header; 51my %old_header;
51 52
52# create patchdir, or empty it if already existing 53# create patchdir, or empty it if already existing
53 54
54sub create_patchdir { 55sub create_patchdir {
55 if (! -d $patchdir) { 56 if (! -d $patchdir) {
56 mkdir($patchdir, 0755); 57 mkdir($patchdir, 0755);
 58 if (-d $origpatchdir && "$origpatchdir" != "$patchdir") {
 59 system("cp", "$origpatchdir/p*", "$patchdir");
 60 }
57 } 61 }
58} 62}
59 63
60# read command line arguments 64# read command line arguments
61 65
62undef($opt_c); 66undef($opt_c);
 67undef($opt_D);
 68undef($opt_d);
63undef($opt_h); 69undef($opt_h);
64undef($opt_r); 70undef($opt_r);
65undef($opt_v); 71undef($opt_v);
66 72
67getopts('chrv'); 73getopts('cDd:hrv');
68 74
69if ($opt_h) { 75if ($opt_h) {
70 ($prog) = ($0 =~ /([^\/]+)$/); 76 ($prog) = ($0 =~ /([^\/]+)$/);
71 print STDERR <<EOF; 77 print STDERR <<EOF;
72usage: $prog [-chv] 78usage: $prog [-hv] [-c | -r] [-D | -d dir]
73 -c commit -- clean up old patches backups 79 -c commit -- clean up old patches backups
 80 -d dir create patches in this directory
 81 -D create patches in \$WRKDIR/.newpatches
74 -h show this help 82 -h show this help
75 -r revert -- remove new patches, put old patches back 83 -r revert -- remove new patches, put old patches back
76 -v verbose - list .orig files as processed 84 -v verbose - list .orig files as processed
77EOF 85EOF
78 exit 0; 86 exit 0;
79}; 87};
80 88
81# get WRKDIR 89if ($opt_d && $opt_D) {
 90 print STDERR "-D and -d conflict, choose one\n";
 91 exit 1;
 92}
 93
 94# get some pkgsrc variables
82 95
 96$wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or
 97 die ("can't find WRKSRC -- wrong dir?");
 98chomp($wrksrc);
83$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or 99$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or
84 die ("can't find WRKDIR -- wrong dir?"); 100 die ("can't find WRKDIR -- wrong dir?");
85chomp($wrkdir); 101chomp($wrkdir);
86$patchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or 102$origpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or
87 die ("can't find PATCHDIR -- wrong dir?"); 103 die ("can't find PATCHDIR -- wrong dir?");
88chomp($patchdir); 104chomp($origpatchdir);
 105
 106if ($opt_D) {
 107 $patchdir = "$wrkdir/.newpatches";
 108} elsif ($opt_d) {
 109 if (-d "/$opt_d") {
 110 $patchdir = $opt_d;
 111 } else {
 112 my $pwd = cwd();
 113 chomp($pwd);
 114 $patchdir = "$pwd/$opt_d";
 115 }
 116} else {
 117 $patchdir = $origpatchdir;
 118}
89 119
90if ($opt_c) { 120if ($opt_c) {
91 open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); 121 open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
92 foreach (<HANDLE>) { 122 foreach (<HANDLE>) {
93 chomp; 123 chomp;
94 unlink $_; 124 unlink $_;
95 } 125 }
96 exit 0; 126 exit 0;
97} 127}
98 128
99if ($opt_r) { 129if ($opt_r) {
100 open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); 130 open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
101 foreach (<HANDLE>) { 131 foreach (<HANDLE>) {
@@ -103,41 +133,36 @@ if ($opt_r) { @@ -103,41 +133,36 @@ if ($opt_r) {
103 my $orig = $_; 133 my $orig = $_;
104 my $new = $_; 134 my $new = $_;
105 $new =~ s/.orig$//; 135 $new =~ s/.orig$//;
106 rename $orig, $new; 136 rename $orig, $new;
107 if (! -s $new) { 137 if (! -s $new) {
108 unlink $new; 138 unlink $new;
109 } 139 }
110 } 140 }
111 exit 0; 141 exit 0;
112} 142}
113 143
114create_patchdir(); 144create_patchdir();
115 145
116# get WRKSRC 
117 
118$wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or  
119 die ("can't find WRKSRC -- wrong dir?"); 
120chomp($wrksrc); 
121 146
122move_away_old_patches(); 147move_away_old_patches();
123 148
124analyze_old_patches(); 149analyze_old_patches();
125 150
126chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); 151chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)");
127 152
128# find files 153# find files
129 154
130open(HANDLE, "find ${wrkdir} -type f -name \\\*.orig |"); 155open(HANDLE, "find ${wrksrc} -type f -name \\\*.orig |");
131 156
132# create patches 157# create patches
133 158
134foreach (sort <HANDLE>) { 159foreach (sort <HANDLE>) {
135 my ($path, $complete); 160 my ($path, $complete);
136 my ($new, $old); 161 my ($new, $old);
137 chomp(); 162 chomp();
138 $path = $_; 163 $path = $_;
139 $complete = $path; 164 $complete = $path;
140 $complete =~ s/.orig$//; 165 $complete =~ s/.orig$//;
141 $new = File::Spec->abs2rel($complete, $wrksrc); 166 $new = File::Spec->abs2rel($complete, $wrksrc);
142 $old = File::Spec->abs2rel($path, $wrksrc); 167 $old = File::Spec->abs2rel($path, $wrksrc);
143 if (-f $complete) { 168 if (-f $complete) {

cvs diff -r1.14 -r1.15 pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2011/02/02 23:35:11 1.14
+++ pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2011/03/04 15:57:07 1.15
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1#!@PERL5@ 1#!@PERL5@
2# 2#
3# $NetBSD: patchdiff.pl,v 1.14 2011/02/02 23:35:11 wiz Exp $ 3# $NetBSD: patchdiff.pl,v 1.15 2011/03/04 15:57:07 wiz Exp $
4# 4#
5# patchdiff: compares a set of patches in the patch dir with their predecessors 5# patchdiff: compares a set of patches in the patch dir with their predecessors
6# 6#
7# Copyright (c) 2000, 2011 by Dieter Baron <dillo@giga.or.at> and 7# Copyright (c) 2000, 2011 by Dieter Baron <dillo@giga.or.at> and
8# Thomas Klausner <wiz@NetBSD.org>  8# Thomas Klausner <wiz@NetBSD.org>
9# All rights reserved. 9# All rights reserved.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
@@ -59,43 +59,60 @@ sub putinhash { @@ -59,43 +59,60 @@ sub putinhash {
59 my $hash=shift; 59 my $hash=shift;
60 my $files=shift; 60 my $files=shift;
61 my $temp; 61 my $temp;
62 local *handle; 62 local *handle;
63 open(handle, "ls $files|"); 63 open(handle, "ls $files|");
64 while(<handle>) { 64 while(<handle>) {
65 chomp; 65 chomp;
66 $temp=getfilename($_); 66 $temp=getfilename($_);
67 $$hash{$temp}=File::Spec->abs2rel($_, $thisdir); 67 $$hash{$temp}=File::Spec->abs2rel($_, $thisdir);
68 } 68 }
69 close(handle); 69 close(handle);
70} 70}
71 71
72getopts('h'); 72getopts('Dd:h');
73 73
74if ($opt_h) { 74if ($opt_h) {
75 ($prog) = ($0 =~ /([^\/]+)$/); 75 ($prog) = ($0 =~ /([^\/]+)$/);
76 print STDERR <<EOF; 76 print STDERR <<EOF;
77usage: $prog 77usage: $prog [-D | -d dir]
 78 -D look at patches in \$WRKDIR/.newpatches
 79 -d dir look at patches in this directory
78EOF 80EOF
79 exit 0; 81 exit 0;
80}; 82};
81 83
82%orig=(); 84%orig=();
83%new=(); 85%new=();
84$thisdir=cwd(); 86$thisdir=cwd();
85chomp($thisdir); 87chomp($thisdir);
86$patchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or 88$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or
 89 die ("can't find WRKDIR -- wrong dir?");
 90chomp($wrkdir);
 91$origpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or
87 die ("can't find PATCHDIR -- wrong dir?"); 92 die ("can't find PATCHDIR -- wrong dir?");
88chomp($patchdir); 93chomp($origpatchdir);
 94
 95if ($opt_D) {
 96 $patchdir = "$wrkdir/.newpatches";
 97} elsif ($opt_d) {
 98 if (-d "/$opt_d") {
 99 $patchdir = $opt_d;
 100 } else {
 101 $patchdir = "$thisdir/$opt_d";
 102 }
 103} else {
 104 $patchdir = $origpatchdir;
 105}
89 106
90if ( ! -d $patchdir) { 107if ( ! -d $patchdir) {
91 print "No patches found (directory $patchdir not found)\n"; 108 print "No patches found (directory $patchdir not found)\n";
92 exit(0); 109 exit(0);
93} 110}
94 111
95open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); 112open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |");
96 113
97foreach (sort <HANDLE>) { 114foreach (sort <HANDLE>) {
98 $orig = $_; 115 $orig = $_;
99 chomp($orig); 116 chomp($orig);
100 $new = $orig; 117 $new = $orig;
101 $new =~ s/.orig$//; 118 $new =~ s/.orig$//;