5 chdir('patches') if -d 'patches';
7 if (!-f 'verify-patches') {
9 Please run this script from the root of the rsync dir or
10 from inside the patches subdir.
18 my($has_dependencies, @new, @rejects);
22 system "rsync -a --delete cvsdir/ workdir/" if -d 'cvsdir';
26 open(IN, '../CVS/Root') or die $!;
30 mkdir('tmp', 0777) unless -d 'tmp';
31 chdir('tmp') or die "Unable to chdir to 'tmp'";
33 mkdir('workdir') unless -d 'workdir';
34 open(OUT, '>exclude') or die $!;
45 print "Using CVS to update the tmp/cvsdir copy of the source.\n";
46 system qq|cvs -d "$root" co -d cvsdir rsync|;
48 @ARGV = glob('../*.diff') unless @ARGV;
51 foreach my $diff (@ARGV) {
52 next unless $diff =~ /\.diff$/;
53 next if $diff =~ /gzip-rsyncable\.diff$/;
54 $diff =~ s#^(patches|\.\.)/##;
56 open(IN, "../$diff") or die $!;
59 if (/^Depends-On-Patch: (\S+.diff)$/) {
61 $has_dependencies = 1;
62 print "\nApplying dependency patch $dep...\n";
63 if (system("patch -d cvsdir -p0 -b -Vt -Zf <../$dep") != 0) {
64 print "Unable to cleanly apply dependency patch -- skipping $diff\n";
65 system "rm -f cvsdir/*.rej cvsdir/*/*.rej";
73 my $default = apply_patch($diff);
74 if ($default =~ s/^D,// || $default eq 'N') {
75 my $def = generate_new_patch($diff);
76 $default = 'U,N' if $default eq 'N' && $def eq 'E';
81 print "\n----------- $diff ------------\n",
82 "\nFix rejects, Diff create, Edit both diffs, Update patch,\n",
83 "Apply patch again, !(CMD), Build rsync, Next, Quit: [$default] ";
86 $ans = $default if $ans eq '';
87 while ($ans =~ s/^\s*(!|\w)((?<!!)[^;,]*|[^;]*)[;,]?//) {
90 $cmd = $2 || $ENV{'SHELL'};
91 chdir('workdir') or die $!;
93 chdir('..') or die $!;
98 $default = apply_patch($diff);
102 if (!-f 'workdir/Makefile') {
103 open(IN, '../../Makefile') or die $!;
104 open(OUT, '>workdir/Makefile') or die $!;
105 print OUT "srcdir=.\n\n";
117 chdir('workdir') or die $!;
118 system "make gen; ./configure $CONF_OPTS; make";
119 chdir('..') or die $!;
120 $default = '!make test';
124 $default = generate_new_patch($diff);
128 chdir('workdir') or die $!;
129 system "vim -d ../../$diff ../new.patch";
130 chdir('..') or die $!;
135 chdir('workdir') or die $!;
136 system "vim @rejects";
137 chdir('..') or die $!;
148 system "cp -p new.patch ../$diff";
149 print "\nUpdated $diff from new.patch\n";
167 system "rsync -a --delete --exclude='*~' cvsdir/ workdir/";
168 print "\nApplying patch $diff...\n";
170 my($saw_failure, $saw_offset, $saw_fuzz);
171 open(IN, "patch -d workdir -p0 --no-backup-if-mismatch -Zf <../$diff |") or die $!;
175 if (s/^patching file //) {
176 push(@new, $_) unless -f "cvsdir/$_";
177 } elsif (s/.* saving rejects to file //) {
179 } elsif (/^Hunk #\d+ FAILED/) {
181 } elsif (/^Hunk #\d+ succeeded at \d+( with fuzz )?/) {
182 $saw_fuzz ||= defined $1;
187 return 'F,D,E' if $saw_failure;
188 return 'D,E' if $saw_fuzz;
189 return 'D,U,N' if $saw_offset;
193 sub generate_new_patch
198 system "touch -r workdir/$_ cvsdir/$_";
200 open(IN, "../$diff") or die $!;
201 open(OUT, '>new.patch') or die $!;
207 open(IN, 'diff --exclude-from=exclude -upr cvsdir workdir |') or die $!;
209 next if /^(diff -|Index: |Only in )/;
210 s#^\Q--- cvsdir/\E#--- orig/#;
211 s#^\Q+++ workdir/\E#+++ #;
212 s#(\.000000000)? \+0000$##;
220 print "\nDiffing... ";
221 if (system("diff ../$diff new.patch >/dev/null") == 0) {
222 print "new patch is identical to old.\n";
225 print "New patch DIFFERS from old.\n";
231 return unless $has_dependencies;
232 $has_dependencies = 0;
234 foreach (glob('*.~[1-9]~'), glob('*/*.~[1-9]~')) {
236 ($fn = $_) =~ s/\.~1~$//;