Fixed failing hunks.
[rsync/rsync-patches.git] / verify-patches
index 4b76220..64ae506 100755 (executable)
@@ -40,6 +40,8 @@ my($has_dependencies, @new, @rejects);
 END {
     &restore_cvsdir;
     system "rsync -a --del cvsdir/ workdir/" if -d 'cvsdir';
+    my $pid = readlink('lock') || 0;
+    unlink('lock') if $pid == $$;
 };
 
 my $root;
@@ -51,6 +53,8 @@ mkdir('tmp', 0777) unless -d 'tmp';
 chdir('tmp') or die "Unable to chdir to 'tmp'";
 symlink('..', 'patches') unless -d 'patches';
 
+symlink($$, 'lock') or die "Unable to create lock file: $!\n";
+
 mkdir('workdir') unless -d 'workdir';
 open(OUT, '>exclude') or die $!;
 print OUT join("\n", 'CVS', @generated_files), "\n";
@@ -59,6 +63,15 @@ close OUT;
 unless ($no_cvs) {
     print "Using CVS to update the tmp/cvsdir copy of the source.\n";
     system qq|cvs -qd "$root" co -P -d cvsdir rsync|;
+    @_ = qw( configure configure.in config.h.in configure.in
+            rsync.1 rsync.yo rsyncd.conf.5 rsyncd.conf.yo );
+    while (@_) {
+       my $gen = 'cvsdir/' . shift(@_);
+       my $src = 'cvsdir/' . shift(@_);
+       if ((-M $gen) > (-M $src)) {
+           system "touch $gen";
+       }
+    }
 }
 
 @ARGV = glob('patches/*.diff') unless @ARGV;
@@ -77,13 +90,13 @@ foreach my $diff (@ARGV) {
            my $dep = $1;
            $has_dependencies = 1;
            print "\nApplying dependency patch $dep...\n";
-           if (system("patch -d cvsdir -p1 -b -Vt <patches/$dep") != 0) {
+           if (system("patch -f -d cvsdir -p1 -b -Vt <patches/$dep") != 0) {
                print "Unable to cleanly apply dependency patch -- skipping $diff\n";
                system "rm -f cvsdir/*.rej cvsdir/*/*.rej";
                &restore_cvsdir;
                next DIFF;
            }
-           sleep(1) if $prepare_source; # Ensure later diffs get later times.
+           sleep(1); # Ensure later diffs get later times.
        }
        if (!defined($conf_opts) && s#^\s+\./configure\s+##) {
            chomp($conf_opts = $_);
@@ -197,11 +210,11 @@ sub apply_patch
     my($diff) = @_;
 
     undef @new;
-    system "rsync -a --delete --exclude='*~' cvsdir/ workdir/";
+    system "rsync -a --del --exclude='*~' cvsdir/ workdir/";
     print "\nApplying patch $diff...\n";
     undef @rejects;
     my($saw_offset, $saw_fuzz);
-    open(IN, "patch -d workdir -p1 --no-backup-if-mismatch <patches/$diff |") or die $!;
+    open(IN, "patch -f -d workdir -p1 --no-backup-if-mismatch <patches/$diff |") or die $!;
     while (<IN>) {
        print $_;
        chomp;
@@ -209,6 +222,8 @@ sub apply_patch
            push(@new, $_) unless -f "cvsdir/$_";
        } elsif (s/.* saving rejects to file //) {
            push(@rejects, $_);
+       } elsif (/No file to patch\.\s+Skipping patch/) {
+           push(@rejects, 'skipped.file');
        } elsif (/^Hunk #\d+ succeeded at \d+( with fuzz $interesting_fuzz)?/o) {
            $saw_fuzz ||= defined $1;
            $saw_offset = 1;