From f48e9f0cf7b367ce045d34efebb74e9af6af156a Mon Sep 17 00:00:00 2001 From: wiz Date: Wed, 2 Feb 2011 10:23:02 +0000 Subject: Update to 1.0. Smarter pkgdiff, doesn't create chunks that are added automatically by the pkgsrc infrastructure (configure:exit instead of regenerate, Makefile: localedir). mkpatches: patch file names now contain the path to the file and its name per discussion on tech-pkg June 2010. Also, the files are created directly in the patches/ directory; backups are saved as patches/patch-foo.orig. patchdiff: now compares patches/patch-foo with patches/patch-foo.orig; if they only differ in non-essential parts, patchdiff reinstates the original patch to keep commits less noisy. --- pkgtools/pkgdiff/Makefile | 6 +- pkgtools/pkgdiff/files/feedback-patches.0 | 4 +- pkgtools/pkgdiff/files/mkpatches.0 | 26 +++++-- pkgtools/pkgdiff/files/mkpatches.1 | 36 ++++++--- pkgtools/pkgdiff/files/mkpatches.pl | 121 ++++++++++++++++++++---------- pkgtools/pkgdiff/files/patchdiff.0 | 13 ++-- pkgtools/pkgdiff/files/patchdiff.1 | 19 ++--- pkgtools/pkgdiff/files/patchdiff.pl | 80 +++++++++----------- pkgtools/pkgdiff/files/pkgdiff | 8 +- pkgtools/pkgdiff/files/pkgdiff.0 | 4 +- pkgtools/pkgdiff/files/pkgvi.0 | 2 +- 11 files changed, 193 insertions(+), 126 deletions(-) (limited to 'pkgtools') diff --git a/pkgtools/pkgdiff/Makefile b/pkgtools/pkgdiff/Makefile index 8d6c84ed54b..f166983e126 100644 --- a/pkgtools/pkgdiff/Makefile +++ b/pkgtools/pkgdiff/Makefile @@ -1,14 +1,14 @@ -# $NetBSD: Makefile,v 1.70 2010/07/04 22:20:04 sbd Exp $ +# $NetBSD: Makefile,v 1.71 2011/02/02 10:23:02 wiz Exp $ # -DISTNAME= pkgdiff-0.123 +DISTNAME= pkgdiff-1.0 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty MAINTAINER= wiz@NetBSD.org HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html -COMMENT= Tools to create, maintain and send back patches for pkgsrc +COMMENT= Tools to create, maintain, and send back patches for pkgsrc PKG_INSTALLATION_TYPES= overwrite pkgviews PKG_DESTDIR_SUPPORT= user-destdir diff --git a/pkgtools/pkgdiff/files/feedback-patches.0 b/pkgtools/pkgdiff/files/feedback-patches.0 index 949955aa3b0..3786ed191e8 100644 --- a/pkgtools/pkgdiff/files/feedback-patches.0 +++ b/pkgtools/pkgdiff/files/feedback-patches.0 @@ -1,7 +1,7 @@ FEEDBACK-PATCHES(1) NetBSD General Commands Manual FEEDBACK-PATCHES(1) NNAAMMEE - ffeeeeddbbaacckk--ppaattcchheess - help sending pkgsrc patches back + ffeeeeddbbaacckk--ppaattcchheess -- help sending pkgsrc patches back SSYYNNOOPPSSIISS ffeeeeddbbaacckk--ppaattcchheess _c_a_t_e_g_o_r_y_/_p_k_g [maintainer@software.org] @@ -56,4 +56,4 @@ AAUUTTHHOORRSS BBUUGGSS Currently the pkgsrc base directory is hardcoded to _/_u_s_r_/_p_k_g_s_r_c. -NetBSD 2.0_BETA Sep 29, 2003 NetBSD 2.0_BETA +NetBSD 5.0 Sep 29, 2003 NetBSD 5.0 diff --git a/pkgtools/pkgdiff/files/mkpatches.0 b/pkgtools/pkgdiff/files/mkpatches.0 index 1b4fe532c03..5b23ae33135 100644 --- a/pkgtools/pkgdiff/files/mkpatches.0 +++ b/pkgtools/pkgdiff/files/mkpatches.0 @@ -1,10 +1,10 @@ MKPATCHES(1) NetBSD General Commands Manual MKPATCHES(1) NNAAMMEE - mmkkppaattcchheess - create patch files appropriate for pkgsrc + mmkkppaattcchheess -- create patch files appropriate for pkgsrc SSYYNNOOPPSSIISS - mmkkppaattcchheess [--dd _o_u_t_p_u_t_-_d_i_r_e_c_t_o_r_y] + mmkkppaattcchheess [--cc | --rr] [--hhvv] DDEESSCCRRIIPPTTIIOONN mmkkppaattcchheess is a perl script that simplifies creating patches from a @@ -17,11 +17,23 @@ DDEESSCCRRIIPPTTIIOONN changed file of the same name (with no ``.orig'' extension) using pkgdiff(1). - The resulting patches are saved in the directory _$_{_W_R_K_D_I_R_}_/_._n_e_w_p_a_t_c_h_e_s or - the directory specified after --dd, and can be easily compared to the cur- - rently existing set using patchdiff(1). + The resulting patches are saved in the package's patches directory (usu- + ally _p_a_t_c_h_e_s_/) and can be easily compared to the currently existing set + using patchdiff(1) or ccvvss ddiiffff. + + Supported options are: + + --cc Clean up backup patches of previous runs. Use this after you're + finished working on the patch set and committed it. + + --hh Show a short usage. + + --rr Revert the changes. Removes the new patches and puts the original + patches back. + + --vv More verbose output. SSEEEE AALLSSOO - patchdiff(1), pkgdiff(1) + cvs(1), patchdiff(1), pkgdiff(1) -NetBSD 1.6 June 25, 2000 NetBSD 1.6 +NetBSD 5.0 January 31, 2011 NetBSD 5.0 diff --git a/pkgtools/pkgdiff/files/mkpatches.1 b/pkgtools/pkgdiff/files/mkpatches.1 index 691aeca6da0..4333cdb4ff1 100644 --- a/pkgtools/pkgdiff/files/mkpatches.1 +++ b/pkgtools/pkgdiff/files/mkpatches.1 @@ -1,9 +1,9 @@ -.\" $NetBSD: mkpatches.1,v 1.3 2005/12/13 12:05:08 wiz Exp $ +.\" $NetBSD: mkpatches.1,v 1.4 2011/02/02 10:23:02 wiz Exp $ .\" -.\" Copyright (c) 2000 by Thomas Klausner +.\" Copyright (c) 2000-2011 by Thomas Klausner .\" All Rights Reserved. Absolutely no warranty. .\" -.Dd June 25, 2000 +.Dd January 31, 2011 .Dt MKPATCHES 1 .Os .Sh NAME @@ -11,7 +11,8 @@ .Nd create patch files appropriate for pkgsrc .Sh SYNOPSIS .Nm -.Op Fl d Ar output-directory +.Oo Fl c | Fl r Oc +.Op Fl hv .Sh DESCRIPTION .Nm is a perl script that simplifies creating patches from a changed work @@ -31,12 +32,29 @@ changed file of the same name (with no extension) using .Xr pkgdiff 1 . .Pp -The resulting patches are saved in the directory -.Pa ${WRKDIR}/.newpatches -or the directory specified after -.Fl d , +The resulting patches are saved in the package's patches directory +(usually +.Pa patches/ ) and can be easily compared to the currently existing set using -.Xr patchdiff 1 . +.Xr patchdiff 1 +or +.Ic "cvs diff" . +.Pp +Supported options are: +.Bl -tag -width 3n +.It Fl c +Clean up backup patches of previous runs. +Use this after you're finished working on the patch set and committed +it. +.It Fl h +Show a short usage. +.It Fl r +Revert the changes. +Removes the new patches and puts the original patches back. +.It Fl v +More verbose output. +.El .Sh SEE ALSO +.Xr cvs 1 , .Xr patchdiff 1 , .Xr pkgdiff 1 diff --git a/pkgtools/pkgdiff/files/mkpatches.pl b/pkgtools/pkgdiff/files/mkpatches.pl index 6a62d5d09e2..a1625673b29 100755 --- a/pkgtools/pkgdiff/files/mkpatches.pl +++ b/pkgtools/pkgdiff/files/mkpatches.pl @@ -1,6 +1,6 @@ #!@PERL5@ # -# $NetBSD: mkpatches.pl,v 1.13 2008/02/16 22:21:35 apb Exp $ +# $NetBSD: mkpatches.pl,v 1.14 2011/02/02 10:23:02 wiz Exp $ # # mkpatches: creates a set of patches patch-aa, patch-ab, ... # in work/.newpatches by looking for *.orig files in and below @@ -13,7 +13,7 @@ # It retains the naming and header (RCS Id and comment) from the # patches directory. # -# Copyright (c) 2000 by Thomas Klausner +# Copyright (c) 2000, 2011 by Thomas Klausner # 2004 by Dieter Baron # All Rights Reserved. Absolutely no warranty. # @@ -31,27 +31,27 @@ my %old_header; # create patchdir, or empty it if already existing sub create_patchdir { - if ( -d $patchdir ) { - unlink "$patchdir/*"; - } else { + if (! -d $patchdir) { mkdir($patchdir, 0755); } } # read command line arguments -undef($opt_d); +undef($opt_c); undef($opt_h); +undef($opt_r); undef($opt_v); -getopts('d:hv'); +getopts('chrv'); if ($opt_h) { ($prog) = ($0 =~ /([^\/]+)$/); print STDERR <) { + chomp; + unlink $_; + } + exit 0; +} -if ($opt_d) { - $patchdir = cwd()."/$opt_d"; -} -else { - $patchdir="$wrkdir"."/.newpatches"; +if ($opt_r) { + open(HANDLE, "find ${patchdir} -type f -name \\\*.orig |"); + foreach () { + chomp; + my $orig = $_; + my $new = $_; + $new =~ s/.orig$//; + rename $orig, $new; + if (! -s $new) { + unlink $new; + } + } + exit 0; } create_patchdir(); @@ -81,6 +98,8 @@ $wrksrc=`@MAKE@ show-var VARNAME=WRKSRC` or die ("can't find WRKSRC -- wrong dir?"); chomp($wrksrc); +move_away_old_patches(); + analyze_old_patches(); chdir $wrksrc or die ("can't cd to WRKSRC ($wrksrc)"); @@ -98,22 +117,18 @@ foreach (sort ) { $path = $_; $complete = $path; $complete =~ s/.orig$//; - $new = File::Spec->abs2rel( $complete, $wrksrc ); - $old = File::Spec->abs2rel( $path, $wrksrc ); - if ( -f $complete ) { + $new = File::Spec->abs2rel($complete, $wrksrc); + $old = File::Spec->abs2rel($path, $wrksrc); + if (-f $complete) { $patchfile = patch_name($new); if ($opt_v) { print "$patchfile -> $complete\n"; } - $diff=`pkgdiff $old $new`; - if ( $? ) { + $diff=`pkgdiff $old $new 2>&1`; + if ($?) { print "$old: $diff"; } - if ( "$diff" eq "" ) { - print ("$new and $old don't differ\n"); - } else { - make_patch($old, $new, $patchfile, $diff); - } + make_patch($old, $new, $patchfile, $diff); } else { print ("$new doesn't exist, though $old does\n"); } @@ -122,19 +137,28 @@ foreach (sort ) { sub analyze_old_patches { my $filename; + my $origfilename; my $patch; my $name; + my $checkname; %old_header = (); %old_filename = (); - open(HANDLE, "ls $old_patchdir/patch-* 2>/dev/null |"); + open(HANDLE, "ls $patchdir/patch-* 2>/dev/null |"); - while ($filename = ) { - chomp $filename; - $patch = `sed '/^\+\+\+/ q' $filename`; + while ($origfilename = ) { + chomp $origfilename; + next if not $origfilename =~ m/.orig$/; + $filename = $origfilename; + $filename =~ s/.orig$//; + $checkname = $origfilename; + if (! -s $checkname) { + $checkname = $filename; + } + $patch = `sed '/^\+\+\+/ q' $checkname`; if (!($patch =~ m/^\+\+\+ ([^\t\n]*)(\n$|\t)/m)) { - warn "cannot extract filename from patch $filename"; + warn "cannot extract filename from patch $checkname"; next; } $name = $1; @@ -148,6 +172,19 @@ sub analyze_old_patches close(HANDLE); } +sub move_away_old_patches +{ + open(HANDLE, "ls $patchdir/patch-* 2>/dev/null |"); + + while ($filename = ) { + chomp $filename; + next if $filename =~ m/.orig$/; + if (-f "$filename" and not -f "$filename.orig") { + rename "$filename", "$filename.orig"; + } + } + +} sub patch_name # filename { @@ -158,12 +195,11 @@ sub patch_name # filename return $old_filename{$name}; } - for ($l=0; ; $l++) { - $pname = 'patch-' . ("aa" .. "zz")[$l]; - if (! -f "$old_patchdir/$pname" and ! -f "$patchdir/$pname") { - return $pname; - } - } + $name =~ s,_,__,g; + $name =~ s,/,_,g; + $name = "patch-$name"; + + return $name; } @@ -171,6 +207,15 @@ sub make_patch # new old patchfile diff { my ($old, $new, $patchfile, $diff) = @_; + if ("$diff" eq "") { + print "$old and $new don't differ\n"; + if (-f "$patchdir/$patchfile.orig") { + rename "$patchdir/$patchfile.orig", "$patchdir/$patchfile"; + } + } + if (not -f "$patchdir/$patchfile.orig") { + system("touch", "$patchdir/$patchfile.orig"); + } if (defined($old_header{$new})) { $diff =~ s/^.*\n(--- )/$1/s; $diff = $old_header{$new} . $diff; diff --git a/pkgtools/pkgdiff/files/patchdiff.0 b/pkgtools/pkgdiff/files/patchdiff.0 index 3e22cf780f9..7ae42530b4f 100644 --- a/pkgtools/pkgdiff/files/patchdiff.0 +++ b/pkgtools/pkgdiff/files/patchdiff.0 @@ -1,10 +1,10 @@ PATCHDIFF(1) NetBSD General Commands Manual PATCHDIFF(1) NNAAMMEE - ppaattcchhddiiffff - compare sets of patches + ppaattcchhddiiffff -- compare sets of patches SSYYNNOOPPSSIISS - ppaattcchhddiiffff [--dd _o_u_t_p_u_t_-_d_i_r_e_c_t_o_r_y] + ppaattcchhddiiffff DDEESSCCRRIIPPTTIIOONN ppaattcchhddiiffff is a perl script that simplifies comparing a set of previously @@ -12,12 +12,11 @@ DDEESSCCRRIIPPTTIIOONN ppaattcchhddiiffff must be called from the package's main directory, that is _$_{_P_K_G_S_R_C_}_/_c_a_t_e_g_o_r_y_/_p_r_o_g_r_a_m. For each patch existing in either the - patches or the _$_{_W_R_K_D_I_R_}_/_._n_e_w_p_a_t_c_h_e_s directory (the second of which can - be overridden by the argument of the --dd option), a matching patch is - looked for in the other directory, and, if one is found, the two are com- - pared with diff(1). + _p_a_t_c_h_e_s directory, it is compared with its backup file (_p_a_t_c_h_-_f_o_o_._o_r_i_g) + using diff(1). If no relevant differences are found, the original patch + is restored. SSEEEE AALLSSOO diff(1), patchdiff(1), pkgdiff(1) -NetBSD 1.6 June 25, 2000 NetBSD 1.6 +NetBSD 5.0 January 31, 2011 NetBSD 5.0 diff --git a/pkgtools/pkgdiff/files/patchdiff.1 b/pkgtools/pkgdiff/files/patchdiff.1 index 9f24f844f92..a5a7793d095 100644 --- a/pkgtools/pkgdiff/files/patchdiff.1 +++ b/pkgtools/pkgdiff/files/patchdiff.1 @@ -1,9 +1,9 @@ -.\" $NetBSD: patchdiff.1,v 1.3 2005/12/13 12:05:08 wiz Exp $ +.\" $NetBSD: patchdiff.1,v 1.4 2011/02/02 10:23:02 wiz Exp $ .\" -.\" Copyright (c) 2000 by Thomas Klausner +.\" Copyright (c) 2000-2011 by Thomas Klausner .\" All Rights Reserved. Absolutely no warranty. .\" -.Dd June 25, 2000 +.Dd January 31, 2011 .Dt PATCHDIFF 1 .Os .Sh NAME @@ -11,7 +11,6 @@ .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 @@ -22,14 +21,12 @@ existing patches with a new one created with must be called from the package's main directory, that is .Pa ${PKGSRC}/category/program . For each patch existing in either the -patches or the -.Pa ${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 +.Pa patches +directory, it is compared with its backup file +.Pq Pa patch-foo.orig +using .Xr diff 1 . +If no relevant differences are found, the original patch is restored. .Sh SEE ALSO .Xr diff 1 , .Xr patchdiff 1 , diff --git a/pkgtools/pkgdiff/files/patchdiff.pl b/pkgtools/pkgdiff/files/patchdiff.pl index 68d80560f91..84c724cea77 100755 --- a/pkgtools/pkgdiff/files/patchdiff.pl +++ b/pkgtools/pkgdiff/files/patchdiff.pl @@ -1,19 +1,18 @@ #!@PERL5@ # -# $NetBSD: patchdiff.pl,v 1.12 2010/07/04 22:20:04 sbd Exp $ +# $NetBSD: patchdiff.pl,v 1.13 2011/02/02 10:23:02 wiz Exp $ # -# patchdiff: compares a set of patches patch-aa, patch-ab, ... in -# $WRKDIR/.newpatches in the with another set in patches. +# patchdiff: compares a set of patches in the patch dir with their predecessors # -# Copyright (c) 2000 by Dieter Baron and -# Thomas Klausner +# Copyright (c) 2000, 2011 by Dieter Baron and +# Thomas Klausner # All Rights Reserved. Absolutely no warranty. use Getopt::Std; use Cwd; use File::Spec; -my $oldpatchdir, $newpatchdir; +my $patchdir, $patchdir; my $wrkdir, $thisdir; my %orig, %new; @@ -48,14 +47,12 @@ sub putinhash { close(handle); } -getopts('d:h'); +getopts('h'); if ($opt_h) { ($prog) = ($0 =~ /([^\/]+)$/); print STDERR <) { + $orig = $_; + chomp($orig); + $new = $orig; + $new =~ s/.orig$//; + + if (! -f "$new") { + print "File $new removed\n"; + } else { # system("diff",$orig{$patch},$new{$patch}); - $diff=`diff $orig{$patch} $new{$patch}`; + $diff=`diff $orig $new`; # the following regex try to eliminate uninteresting differences # The general structure of the diffs-to-be-removed is: # 25c25 @@ -107,17 +94,22 @@ foreach $patch (keys%new) { # . NetBSD RCS Id tag differences $diff=~s/^[\d,]+c[\d,]+\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m; # . the name of the input file changed - # (if the name of the output file has changed values in $orig{$patch} - # and $new{$patch} won't match so the files don't get compared) + # (if the name of the output file has changed, patches + # won't get matched up anyway) # . time of the input and/or output file changed # . line numbers changed - $diff=~s/^[\d,]+c[\d,]+\n(?:.\s---\s(:?\S*).*\n)?(?:.\s\+\+\+\s(\S*).*\n)?(?:.\s@@\s(?:.*)\s@@.*\n)?---\n(?:.\s---\s.*\n)?(?:.\s\+\+\+\s\1.*\n)?(?:.\s@@\s.*\s@@.*\n)?//m; + $diff=~s/^[\d,]+c[\d,]+\n(?:.\s---\s(:?\S+).*\n)?(?:.\s\+\+\+\s(\S+).*\n)?(?:.\s@@\s(?:.*)\s@@.*\n)?---\n(?:.\s---\s\S+.*\n)?(?:.\s\+\+\+\s\S+.*\n)?(?:.\s@@\s.*\s@@.*\n)?//m; # . only line numbers changed $diff=~s/^[\d,]+c[\d,]+\n.\s@@\s.*\s@@.*\n---\n.\s@@\s.*\s@@.*\n//mg; if ($diff) { - print "Comparing $orig{$patch} to $new{$patch}\n$diff"; + if (! -s $orig) { + print "New file $new\n"; + } else { + print "Comparing $orig to $new\n$diff"; + } + } else { + # restore previous version to get rid of uninteresting diffs + rename "$orig", "$new"; } - } else { - print "Only in new: $new{$patch} ($patch)\n" - } + } } diff --git a/pkgtools/pkgdiff/files/pkgdiff b/pkgtools/pkgdiff/files/pkgdiff index f8b55f15192..cf1a8da423f 100755 --- a/pkgtools/pkgdiff/files/pkgdiff +++ b/pkgtools/pkgdiff/files/pkgdiff @@ -1,6 +1,6 @@ #!@SH@ # -# $NetBSD: pkgdiff,v 1.17 2009/12/10 20:26:33 abs Exp $ +# $NetBSD: pkgdiff,v 1.18 2011/02/02 10:23:02 wiz Exp $ # # Usage: pkgdiff newfile # pkgdiff oldfile newfile @@ -10,6 +10,7 @@ # oldfile is assumed as newfile.orig. # # Copyright (c) 2000 by Hubert Feyrer +# Copyright (c) 2011 by Thomas Klausner # All Rights Reserved. Absolutely no warranty. # @@ -34,7 +35,10 @@ basename_new="`basename $new`" dodiff() { case x"$basename_new" in xconfigure) - @DIFF@ -I '\(echo .*as_me:[0-9][0-9]*:\|echo .*configure:[0-9][0-9]*:\|line [0-9][0-9]* "configure\)' $* + @DIFF@ -I '\(echo .*as_me:[0-9][0-9]*:\|echo .*configure:[0-9][0-9]*:\|line [0-9][0-9]* "configure\)' -I '\(Avoid regenerating within pkgsrc\|exit 0\)' $* + ;; + xMakefile*) + @DIFF@ -I '\(localedir.*=.*localedir\|localedir.*=.*share/locale\)' $* ;; *) @DIFF@ $* diff --git a/pkgtools/pkgdiff/files/pkgdiff.0 b/pkgtools/pkgdiff/files/pkgdiff.0 index 67fad329896..94c363dafbc 100644 --- a/pkgtools/pkgdiff/files/pkgdiff.0 +++ b/pkgtools/pkgdiff/files/pkgdiff.0 @@ -1,7 +1,7 @@ PKGDIFF(1) NetBSD General Commands Manual PKGDIFF(1) NNAAMMEE - ppkkggddiiffff - diff files in a way appropriate for pkgsrc + ppkkggddiiffff -- diff files in a way appropriate for pkgsrc SSYYNNOOPPSSIISS ppkkggddiiffff [_o_p_t_i_o_n_s] _o_l_d_f_i_l_e _n_e_w_f_i_l_e @@ -24,4 +24,4 @@ EENNVVIIRROONNMMEENNTT SSEEEE AALLSSOO cvs(1), diff(1), mkpatches(1), patch(1), pkgvi(1) -NetBSD 1.6 Jun 14, 2003 NetBSD 1.6 +NetBSD 5.0 Jun 14, 2003 NetBSD 5.0 diff --git a/pkgtools/pkgdiff/files/pkgvi.0 b/pkgtools/pkgdiff/files/pkgvi.0 index 6383d541bff..dd4cf3dbfa9 100644 --- a/pkgtools/pkgdiff/files/pkgvi.0 +++ b/pkgtools/pkgdiff/files/pkgvi.0 @@ -30,4 +30,4 @@ SSEEEE AALLSSOO AAUUTTHHOORRSS The pkgvi utility was written by Tomasz Luchowski . -NetBSD 3.0_STABLE Aug 1, 2006 NetBSD 3.0_STABLE +NetBSD 5.0 Aug 1, 2006 NetBSD 5.0 -- cgit v1.2.3