Improved the rsyncsums script to have a --check mode.
[rsync/rsync-patches.git] / verify-patches
index 6c77581..d6d7c3a 100755 (executable)
@@ -2,6 +2,7 @@
 
 use strict;
 use Getopt::Long;
+use Cwd;
 
 my @generated_files = qw( proto.h configure config.h.in rsync.1 rsyncd.conf.5 );
 
@@ -31,6 +32,8 @@ from inside the patches subdir.
 EOT
 }
 
+my $patches_dir = Cwd::cwd();
+
 $ENV{'LC_COLLATE'} = 'C';
 $| = 1;
 my $CONF_OPTS = '--cache-file=../config.cache';
@@ -51,7 +54,8 @@ close IN;
 
 mkdir('tmp', 0777) unless -d 'tmp';
 chdir('tmp') or die "Unable to chdir to 'tmp'";
-symlink('..', 'patches') unless -d 'patches';
+unlink('patches');
+symlink($patches_dir, 'patches');
 
 symlink($$, 'lock') or die "Unable to create lock file: $!\n";
 
@@ -90,7 +94,7 @@ 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;
@@ -214,7 +218,7 @@ sub apply_patch
     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;
@@ -222,6 +226,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;
@@ -266,7 +272,7 @@ sub generate_new_patch
        # These are not included in the diff above so that patch will give
        # generated files a later timestamp than the source files.
        foreach my $fn (@generated_files) {
-           &filter_diff("diff -dup cvsdir/$fn workdir");
+           &filter_diff("diff -dupW128 cvsdir/$fn workdir");
        }
     }
     close OUT;