Got rid of two compiler warnings.
[rsync/rsync-patches.git] / verify-patches
index e215b0d..28d37b9 100755 (executable)
@@ -1,6 +1,18 @@
 #!/usr/bin/perl
 
 use strict;
+use Getopt::Long;
+
+my($no_cvs, $failures_only, $minor_updates);
+
+&Getopt::Long::Configure('bundling');
+GetOptions(
+    'no-cvs|n' => \$no_cvs,
+    'failures-only|f' => \$failures_only,
+    'minor-updates|u' => \$minor_updates,
+) or &usage;
+
+my $interesting_fuzz = $minor_updates ? '\d' : '[2-9]';
 
 chdir('patches') if -d 'patches';
 
@@ -42,15 +54,17 @@ rsyncd.conf.5
 EOT
 close OUT;
 
-print "Using CVS to update the tmp/cvsdir copy of the source.\n";
-system qq|cvs -d "$root" co -d cvsdir rsync|;
+unless ($no_cvs) {
+    print "Using CVS to update the tmp/cvsdir copy of the source.\n";
+    system qq|cvs -d "$root" co -d cvsdir rsync|;
+}
 
 @ARGV = glob('../*.diff') unless @ARGV;
 
 DIFF:
 foreach my $diff (@ARGV) {
     next unless $diff =~ /\.diff$/;
-    next if $diff =~ /gzip-rsyncable\.diff$/;
+    next if $diff =~ /gzip-rsyncable[-_a-z]*\.diff$/;
     $diff =~ s#^(patches|\.\.)/##;
 
     open(IN, "../$diff") or die $!;
@@ -74,6 +88,7 @@ foreach my $diff (@ARGV) {
     if ($default =~ s/^D,// || $default eq 'N') {
        my $def = generate_new_patch($diff);
        $default = 'U,N' if $default eq 'N' && $def eq 'E';
+       $default = 'N' if !$minor_updates && $default eq 'U,N';
     }
 
     PROMPT:
@@ -114,8 +129,25 @@ foreach my $diff (@ARGV) {
                    close IN;
                    close OUT;
                }
+               my $need_autoconf;
+               my $conf_opts;
+               open(IN, "../$diff") or die $!;
+               while (<IN>) {
+                   if (!defined $conf_opts) {
+                       $conf_opts = '' if /^---/;
+                       if (m#^\s*\./configure( .+)#) {
+                           $conf_opts = $1;
+                       }
+                   }
+                   if (m#^--- orig/(configure\.in|/aclocal\.m4)#) {
+                       $need_autoconf = 1;
+                       last;
+                   }
+               }
+               close IN;
                chdir('workdir') or die $!;
-               system "make gen; ./configure $CONF_OPTS; make";
+               system "autoconf; autoheader" if $need_autoconf;
+               system "make proto; ./configure $CONF_OPTS $conf_opts; make";
                chdir('..') or die $!;
                $default = '!make test';
                next;
@@ -178,15 +210,15 @@ sub apply_patch
            push(@rejects, $_);
        } elsif (/^Hunk #\d+ FAILED/) {
            $saw_failure = 1;
-       } elsif (/^Hunk #\d+ succeeded at \d+( with fuzz )?/) {
+       } elsif (/^Hunk #\d+ succeeded at \d+( with fuzz $interesting_fuzz)?/o) {
            $saw_fuzz ||= defined $1;
            $saw_offset = 1;
        }
     }
     close IN;
     return 'F,D,E' if $saw_failure;
-    return 'D,E' if $saw_fuzz;
-    return 'D,U,N' if $saw_offset;
+    return 'D,E' if $saw_fuzz && !$failures_only;
+    return 'D,U,N' if $saw_offset && !$failures_only;
     'N';
 }
 
@@ -209,7 +241,7 @@ sub generate_new_patch
        next if /^(diff -|Index: |Only in )/;
        s#^\Q--- cvsdir/\E#--- orig/#;
        s#^\Q+++ workdir/\E#+++ #;
-       s#(\.000000000)? \+0000$##;
+       s#(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)(\.\d\d\d\d\d\d\d\d\d)? \+0000$#$1#;
        print OUT $_;
     }
     close IN;
@@ -231,16 +263,27 @@ sub restore_cvsdir
     return unless $has_dependencies;
     $has_dependencies = 0;
 
+    chdir('cvsdir') or die $!;
     foreach (glob('*.~[1-9]~'), glob('*/*.~[1-9]~')) {
        my $fn;
        ($fn = $_) =~ s/\.~1~$//;
        if ($fn eq $_) {
            unlink($_);
-       } elsif (-r $fn) {
-           rename($_,  $fn);
+       } elsif (-r $_) {
+           rename($_, $fn);
        } else {
            unlink($_);
            unlink($fn);
        }
     }
+    chdir('..') or die $!;
+}
+
+sub usage
+{
+    die <<EOT;
+Usage: $0 [OPTS] [DIFF-FILE...]
+ -n, --no-cvs          Don't update tmp/cvsdir at the start of the run
+ -u, --minor-updates   Suggest 'U' for even minor changes in the diff
+EOT
 }