diff options
author | wiz <wiz> | 2011-03-04 15:57:07 +0000 |
---|---|---|
committer | wiz <wiz> | 2011-03-04 15:57:07 +0000 |
commit | 44454d12d5f17909cf629c2be7e0ccbcb16a3e47 (patch) | |
tree | 22c00f7cd37e134cfcf584a40b6dac5b3f03557e /pkgtools | |
parent | 1e6a99b5dbd1d2762d250a461c23b2798b981649 (diff) | |
download | pkgsrc-44454d12d5f17909cf629c2be7e0ccbcb16a3e47.tar.gz |
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.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkgdiff/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/mkpatches.1 | 21 | ||||
-rwxr-xr-x | pkgtools/pkgdiff/files/mkpatches.pl | 49 | ||||
-rw-r--r-- | pkgtools/pkgdiff/files/patchdiff.1 | 23 | ||||
-rwxr-xr-x | pkgtools/pkgdiff/files/patchdiff.pl | 27 |
5 files changed, 99 insertions, 25 deletions
diff --git a/pkgtools/pkgdiff/Makefile b/pkgtools/pkgdiff/Makefile index 434704cb287..57f1f2dccdb 100644 --- a/pkgtools/pkgdiff/Makefile +++ b/pkgtools/pkgdiff/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.72 2011/02/02 23:35:51 wiz Exp $ +# $NetBSD: Makefile,v 1.73 2011/03/04 15:57:07 wiz Exp $ # -DISTNAME= pkgdiff-1.0 +DISTNAME= pkgdiff-1.1 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkgdiff/files/mkpatches.1 b/pkgtools/pkgdiff/files/mkpatches.1 index c534050c33c..53d515b7316 100644 --- a/pkgtools/pkgdiff/files/mkpatches.1 +++ b/pkgtools/pkgdiff/files/mkpatches.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: mkpatches.1,v 1.6 2011/02/02 23:34:48 wiz Exp $ +.\" $NetBSD: mkpatches.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. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 31, 2011 +.Dd February 20, 2011 .Dt MKPATCHES 1 .Os .Sh NAME @@ -32,8 +32,9 @@ .Nd create patch files appropriate for pkgsrc .Sh SYNOPSIS .Nm -.Oo Fl c | Fl r Oc .Op Fl hv +.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 @@ -67,6 +68,20 @@ Supported options are: 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 diff --git a/pkgtools/pkgdiff/files/mkpatches.pl b/pkgtools/pkgdiff/files/mkpatches.pl index 40a193f184a..b48af1fd51b 100755 --- a/pkgtools/pkgdiff/files/mkpatches.pl +++ b/pkgtools/pkgdiff/files/mkpatches.pl @@ -1,6 +1,6 @@ #!@PERL5@ # -# $NetBSD: mkpatches.pl,v 1.15 2011/02/02 23:35:11 wiz Exp $ +# $NetBSD: mkpatches.pl,v 1.16 2011/03/04 15:57:07 wiz Exp $ # # mkpatches: creates a set of patches patch-aa, patch-ab, ... # in work/.newpatches by looking for *.orig files in and below @@ -46,6 +46,7 @@ use File::Spec; my $patchdir; my $old_patchdir; my $wrkdir; +my $wrksrc; my %old_filename; my %old_header; @@ -54,23 +55,30 @@ my %old_header; 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); -getopts('chrv'); +getopts('cDd:hrv'); if ($opt_h) { ($prog) = ($0 =~ /([^\/]+)$/); print STDERR <<EOF; -usage: $prog [-chv] +usage: $prog [-hv] [-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 @@ -78,14 +86,36 @@ EOF exit 0; }; -# get WRKDIR +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); -$patchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or +$origpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or die ("can't find PATCHDIR -- wrong dir?"); -chomp($patchdir); +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 |"); @@ -113,11 +143,6 @@ if ($opt_r) { create_patchdir(); -# get WRKSRC - -$wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or - die ("can't find WRKSRC -- wrong dir?"); -chomp($wrksrc); move_away_old_patches(); @@ -127,7 +152,7 @@ chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); # find files -open(HANDLE, "find ${wrkdir} -type f -name \\\*.orig |"); +open(HANDLE, "find ${wrksrc} -type f -name \\\*.orig |"); # create patches diff --git a/pkgtools/pkgdiff/files/patchdiff.1 b/pkgtools/pkgdiff/files/patchdiff.1 index a6f8287885d..3ec61cf88a4 100644 --- a/pkgtools/pkgdiff/files/patchdiff.1 +++ b/pkgtools/pkgdiff/files/patchdiff.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: patchdiff.1,v 1.6 2011/02/02 23:34:48 wiz Exp $ +.\" $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. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 31, 2011 +.Dd February 20, 2011 .Dt PATCHDIFF 1 .Os .Sh NAME @@ -32,6 +32,7 @@ .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 @@ -48,7 +49,23 @@ directory, it is compared with its backup file 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 patchdiff 1 , +.Xr mkpatches 1 , .Xr pkgdiff 1 diff --git a/pkgtools/pkgdiff/files/patchdiff.pl b/pkgtools/pkgdiff/files/patchdiff.pl index 52e2f60b3c1..64bdee637b6 100755 --- a/pkgtools/pkgdiff/files/patchdiff.pl +++ b/pkgtools/pkgdiff/files/patchdiff.pl @@ -1,6 +1,6 @@ #!@PERL5@ # -# $NetBSD: patchdiff.pl,v 1.14 2011/02/02 23:35:11 wiz Exp $ +# $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 # @@ -69,12 +69,14 @@ sub putinhash { close(handle); } -getopts('h'); +getopts('Dd:h'); if ($opt_h) { ($prog) = ($0 =~ /([^\/]+)$/); print STDERR <<EOF; -usage: $prog +usage: $prog [-D | -d dir] + -D look at patches in \$WRKDIR/.newpatches + -d dir look at patches in this directory EOF exit 0; }; @@ -83,9 +85,24 @@ EOF %new=(); $thisdir=cwd(); chomp($thisdir); -$patchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or +$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($patchdir); +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"; |