--- pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2000/08/17 03:09:26 1.2 +++ pkgsrc/pkgtools/pkgdiff/files/patchdiff.pl 2010/07/04 22:20:04 1.12 @@ -1,37 +1,33 @@ -#!@PREFIX@/bin/perl +#!@PERL5@ # -# $NetBSD: patchdiff.pl,v 1.2 2000/08/17 03:09:26 wiz Exp $ +# $NetBSD: patchdiff.pl,v 1.12 2010/07/04 22:20:04 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; use Cwd; +use File::Spec; my $oldpatchdir, $newpatchdir; -my $wrkdir; +my $wrkdir, $thisdir; my %orig, %new; -# change to WRKDIR - -sub goto_wrkdir { - chdir $wrkdir or die ("can't cd to WRKDIR ($wrkdir)"); -} - sub getfilename { my $fname=shift; local $_; local *handle; open(handle, $fname); while () { - next unless m/^\+\+\+[ ]([^ ]*)/; + next unless m/^\+\+\+[ ]([^ ]*)/; close(handle); $_ = $1; chomp(); + s/^\.\///; # ignore leading "./", if any. return $_; } close(handle); @@ -47,8 +43,7 @@ sub putinhash { while() { chomp; $temp=getfilename($_); - $$hash{$temp}=$_; -# print "put in hash: $temp // $_\n"; + $$hash{$temp}=File::Spec->abs2rel($_, $thisdir); } close(handle); } @@ -67,11 +62,13 @@ EOF %orig=(); %new=(); -$oldpatchdir=cwd(); +$thisdir=cwd(); +chomp($thisdir); +$oldpatchdir=`@MAKE@ show-var VARNAME=PATCHDIR` or + die ("can't find PATCHDIR -- wrong dir?"); chomp($oldpatchdir); -$oldpatchdir=$oldpatchdir."/patches"; -$wrkdir=`make show-var VARNAME=WRKDIR` or +$wrkdir=`@MAKE@ show-var VARNAME=WRKDIR` or die ("can't find WRKDIR -- wrong dir?"); chomp($wrkdir); @@ -99,8 +96,24 @@ 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; + # . 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) + # . 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; + # . 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"; }