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.diff -r1.72 -r1.73 pkgsrc/pkgtools/pkgdiff/Makefile
(wiz)
@@ -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 | |||
4 | DISTNAME= pkgdiff-1.0 | 4 | DISTNAME= pkgdiff-1.1 | |
5 | CATEGORIES= pkgtools devel | 5 | CATEGORIES= pkgtools devel | |
6 | MASTER_SITES= # empty | 6 | MASTER_SITES= # empty | |
7 | DISTFILES= # empty | 7 | DISTFILES= # empty | |
8 | 8 | |||
9 | MAINTAINER= wiz@NetBSD.org | 9 | MAINTAINER= wiz@NetBSD.org | |
10 | HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html | 10 | HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html | |
11 | COMMENT= Tools to create, maintain, and send back patches for pkgsrc | 11 | COMMENT= Tools to create, maintain, and send back patches for pkgsrc | |
12 | LICENSE= 2-clause-bsd AND original-bsd | 12 | LICENSE= 2-clause-bsd AND original-bsd | |
13 | 13 | |||
14 | PKG_INSTALLATION_TYPES= overwrite pkgviews | 14 | PKG_INSTALLATION_TYPES= overwrite pkgviews | |
15 | PKG_DESTDIR_SUPPORT= user-destdir | 15 | PKG_DESTDIR_SUPPORT= user-destdir | |
16 | 16 | |||
17 | NO_CONFIGURE= yes | 17 | NO_CONFIGURE= yes |
@@ -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 | |
39 | is a perl script that simplifies creating patches from a changed work | 40 | is a perl script that simplifies creating patches from a changed work | |
40 | tree if for each changed file the original was kept with an added | 41 | tree if for each changed file the original was kept with an added | |
41 | extension | 42 | extension | |
42 | .Dq .orig . | 43 | .Dq .orig . | |
43 | .Pp | 44 | .Pp | |
44 | .Nm | 45 | .Nm | |
45 | must be called from the package's main directory, that is | 46 | must be called from the package's main directory, that is | |
46 | .Pa ${PKGSRC}/category/program . | 47 | .Pa ${PKGSRC}/category/program . | |
47 | It then proceeds to find all files that | 48 | It then proceeds to find all files that | |
48 | match the pattern | 49 | match 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/ ) | |
59 | and can be easily compared to the currently existing set using | 60 | and can be easily compared to the currently existing set using | |
60 | .Xr patchdiff 1 | 61 | .Xr patchdiff 1 | |
61 | or | 62 | or | |
62 | .Ic "cvs diff" . | 63 | .Ic "cvs diff" . | |
63 | .Pp | 64 | .Pp | |
64 | Supported options are: | 65 | Supported options are: | |
65 | .Bl -tag -width 3n | 66 | .Bl -tag -width 3n | |
66 | .It Fl c | 67 | .It Fl c | |
67 | Clean up backup patches of previous runs. | 68 | Clean up backup patches of previous runs. | |
68 | Use this after you're finished working on the patch set and committed | 69 | Use this after you're finished working on the patch set and committed | |
69 | it. | 70 | it. | |
71 | .It Fl D | |||
72 | Use | |||
73 | .Pa $WRKDIR/.newpatches | |||
74 | for patches. | |||
75 | See | |||
76 | .Fl d | |||
77 | for more details. | |||
78 | .It Fl d Ar dir | |||
79 | Use | |||
80 | .Ar dir | |||
81 | for patches. | |||
82 | Copies any existing patches there on the first run and then | |||
83 | creates or updates patches only there. | |||
84 | Use this e.g. if you have a read-only pkgsrc. | |||
70 | .It Fl h | 85 | .It Fl h | |
71 | Show a short usage. | 86 | Show a short usage. | |
72 | .It Fl r | 87 | .It Fl r | |
73 | Revert the changes. | 88 | Revert the changes. | |
74 | Removes the new patches and puts the original patches back. | 89 | Removes the new patches and puts the original patches back. | |
75 | .It Fl v | 90 | .It Fl v | |
76 | More verbose output. | 91 | More 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 |
@@ -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 | |
37 | is a perl script that simplifies comparing a set of previously | 38 | is a perl script that simplifies comparing a set of previously | |
38 | existing patches with a new one created with | 39 | existing patches with a new one created with | |
39 | .Xr mkpatches 1 . | 40 | .Xr mkpatches 1 . | |
40 | .Pp | 41 | .Pp | |
41 | .Nm | 42 | .Nm | |
42 | must be called from the package's main directory, that is | 43 | must be called from the package's main directory, that is | |
43 | .Pa ${PKGSRC}/category/program . | 44 | .Pa ${PKGSRC}/category/program . | |
44 | For each patch existing in either the | 45 | For each patch existing in either the | |
45 | .Pa patches | 46 | .Pa patches | |
46 | directory, it is compared with its backup file | 47 | directory, it is compared with its backup file | |
47 | .Pq Pa patch-foo.orig | 48 | .Pq Pa patch-foo.orig | |
48 | using | 49 | using | |
49 | .Xr diff 1 . | 50 | .Xr diff 1 . | |
50 | If no relevant differences are found, the original patch is restored. | 51 | If no relevant differences are found, the original patch is restored. | |
52 | .Pp | |||
53 | If the | |||
54 | .Fl d | |||
55 | option is used, | |||
56 | .Nm | |||
57 | looks for patches in | |||
58 | .Ar dir | |||
59 | instead of the default | |||
60 | .Pa patches | |||
61 | directory. | |||
62 | If the | |||
63 | .Fl D | |||
64 | option is used, | |||
65 | .Nm | |||
66 | looks 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 |
@@ -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 | |||
42 | use Getopt::Std; | 42 | use Getopt::Std; | |
43 | use Cwd; | 43 | use Cwd; | |
44 | use File::Spec; | 44 | use File::Spec; | |
45 | 45 | |||
46 | my $patchdir; | 46 | my $patchdir; | |
47 | my $old_patchdir; | 47 | my $old_patchdir; | |
48 | my $wrkdir; | 48 | my $wrkdir; | |
49 | my $wrksrc; | |||
49 | my %old_filename; | 50 | my %old_filename; | |
50 | my %old_header; | 51 | my %old_header; | |
51 | 52 | |||
52 | # create patchdir, or empty it if already existing | 53 | # create patchdir, or empty it if already existing | |
53 | 54 | |||
54 | sub create_patchdir { | 55 | sub 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 | |||
62 | undef($opt_c); | 66 | undef($opt_c); | |
67 | undef($opt_D); | |||
68 | undef($opt_d); | |||
63 | undef($opt_h); | 69 | undef($opt_h); | |
64 | undef($opt_r); | 70 | undef($opt_r); | |
65 | undef($opt_v); | 71 | undef($opt_v); | |
66 | 72 | |||
67 | getopts('chrv'); | 73 | getopts('cDd:hrv'); | |
68 | 74 | |||
69 | if ($opt_h) { | 75 | if ($opt_h) { | |
70 | ($prog) = ($0 =~ /([^\/]+)$/); | 76 | ($prog) = ($0 =~ /([^\/]+)$/); | |
71 | print STDERR <<EOF; | 77 | print STDERR <<EOF; | |
72 | usage: $prog [-chv] | 78 | usage: $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 | |
77 | EOF | 85 | EOF | |
78 | exit 0; | 86 | exit 0; | |
79 | }; | 87 | }; | |
80 | 88 | |||
81 | # get WRKDIR | 89 | if ($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?"); | |||
98 | chomp($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?"); | |
85 | chomp($wrkdir); | 101 | chomp($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?"); | |
88 | chomp($patchdir); | 104 | chomp($origpatchdir); | |
105 | ||||
106 | if ($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 | |||
90 | if ($opt_c) { | 120 | if ($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 | |||
99 | if ($opt_r) { | 129 | if ($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 | |||
114 | create_patchdir(); | 144 | create_patchdir(); | |
115 | 145 | |||
116 | # get WRKSRC | |||
117 | ||||
118 | $wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or | |||
119 | die ("can't find WRKSRC -- wrong dir?"); | |||
120 | chomp($wrksrc); | |||
121 | 146 | |||
122 | move_away_old_patches(); | 147 | move_away_old_patches(); | |
123 | 148 | |||
124 | analyze_old_patches(); | 149 | analyze_old_patches(); | |
125 | 150 | |||
126 | chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); | 151 | chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); | |
127 | 152 | |||
128 | # find files | 153 | # find files | |
129 | 154 | |||
130 | open(HANDLE, "find ${wrkdir} -type f -name \\\*.orig |"); | 155 | open(HANDLE, "find ${wrksrc} -type f -name \\\*.orig |"); | |
131 | 156 | |||
132 | # create patches | 157 | # create patches | |
133 | 158 | |||
134 | foreach (sort <HANDLE>) { | 159 | foreach (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) { |
@@ -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 | |||
72 | getopts('h'); | 72 | getopts('Dd:h'); | |
73 | 73 | |||
74 | if ($opt_h) { | 74 | if ($opt_h) { | |
75 | ($prog) = ($0 =~ /([^\/]+)$/); | 75 | ($prog) = ($0 =~ /([^\/]+)$/); | |
76 | print STDERR <<EOF; | 76 | print STDERR <<EOF; | |
77 | usage: $prog | 77 | usage: $prog [-D | -d dir] | |
78 | -D look at patches in \$WRKDIR/.newpatches | |||
79 | -d dir look at patches in this directory | |||
78 | EOF | 80 | EOF | |
79 | exit 0; | 81 | exit 0; | |
80 | }; | 82 | }; | |
81 | 83 | |||
82 | %orig=(); | 84 | %orig=(); | |
83 | %new=(); | 85 | %new=(); | |
84 | $thisdir=cwd(); | 86 | $thisdir=cwd(); | |
85 | chomp($thisdir); | 87 | chomp($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?"); | |||
90 | chomp($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?"); | |
88 | chomp($patchdir); | 93 | chomp($origpatchdir); | |
94 | ||||
95 | if ($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 | |||
90 | if ( ! -d $patchdir) { | 107 | if ( ! -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 | |||
95 | open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); | 112 | open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); | |
96 | 113 | |||
97 | foreach (sort <HANDLE>) { | 114 | foreach (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$//; |