--- pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2001/03/31 20:19:04 1.3 +++ pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2010/07/04 22:18:28 1.11 @@ -1,12 +1,12 @@ -#!@PREFIX@/bin/perl +#!@PERL5@ # -# $NetBSD: patchdiff.pl,v 1.3 2001/03/31 20:19:04 skrll Exp $ +# $NetBSD: patchdiff.pl,v 1.11 2010/07/04 22:18:28 sbd 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 and -# Thomas Klausner +# Thomas Klausner # All Rights Reserved. Absolutely no warranty. use Getopt::Std; @@ -23,10 +23,11 @@ sub getfilename { local *handle; open(handle, $fname); while () { - next unless m/^\+\+\+[ ]([^ ]*)/; + next unless m/^\+\+\+[ ]([^ ]*)/; close(handle); $_ = $1; chomp(); + s/^\.\///; # ignore leading "./", if any. return $_; } close(handle); @@ -63,9 +64,11 @@ EOF %new=(); $thisdir=cwd(); chomp($thisdir); -$oldpatchdir=$thisdir."/patches"; +$oldpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or + die ("can't find PATCHDIR -- wrong dir?"); +chomp($oldpatchdir); -$wrkdir=`make show-var VARNAME=WRKDIR` or +$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or die ("can't find WRKDIR -- wrong dir?"); chomp($wrkdir); @@ -93,8 +96,23 @@ 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; + # the following regex try to eliminate uninteresting differences + # The general structure of the diffs-to-be-removed is: + # 25c25 + # < --- something.orig 2008-08-08 08:08 + # --- + # > --- something.orig 2008-08-08 18:08 + # + # In particular, remove hunks with: + # . NetBSD RCS Id tag differences + $diff=~s/^[\d,]+c[\d,]+\n..\$[N]etBSD.*\$\n---\n..\$[N]etBSD.*\$\n//m; + # . only the name or date of the output file changed + $diff=~s/^[\d,]+c[\d,]+\n..\+\+\+.*\n---\n..\+\+\+.*\n//m; + # . only the name or date of the input file changed + $diff=~s/^[\d,]+c[\d,]+\n.\s---\s.*\.orig\s.*\n---\n.\s---\s.*\n//m; + $diff=~s/^[\d,]+c[\d,]+\n.\s---\s.*\n---\n.\s---\s.*\.orig\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"; }