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";
119 open(IN, "../$diff") or die $!;
121 if (!defined $conf_opts) {
122 $conf_opts = '' if /^---/;
123 if (m#^\s*\./configure( .+)#) {
127 if (m#^--- orig/(configure\.in|/aclocal\.m4)#) {
133 chdir('workdir') or die $!;
134 system "autoconf; autoheader" if $need_autoconf;
135 system "make proto; ./configure $CONF_OPTS $conf_opts; make";
136 chdir('..') or die $!;
137 $default = '!make test';
141 $default = generate_new_patch($diff);
145 chdir('workdir') or die $!;
146 system "vim -d ../../$diff ../new.patch";
147 chdir('..') or die $!;
152 chdir('workdir') or die $!;
153 system "vim @rejects";
154 chdir('..') or die $!;
165 system "cp -p new.patch ../$diff";
166 print "\nUpdated $diff from new.patch\n";
184 system "rsync -a --delete --exclude='*~' cvsdir/ workdir/";
185 print "\nApplying patch $diff...\n";
187 my($saw_failure, $saw_offset, $saw_fuzz);
188 open(IN, "patch -d workdir -p0 --no-backup-if-mismatch -Zf <../$diff |") or die $!;
192 if (s/^patching file //) {
193 push(@new, $_) unless -f "cvsdir/$_";
194 } elsif (s/.* saving rejects to file //) {
196 } elsif (/^Hunk #\d+ FAILED/) {
198 } elsif (/^Hunk #\d+ succeeded at \d+( with fuzz )?/) {
199 $saw_fuzz ||= defined $1;
204 return 'F,D,E' if $saw_failure;
205 return 'D,E' if $saw_fuzz;
206 return 'D,U,N' if $saw_offset;
210 sub generate_new_patch
215 system "touch -r workdir/$_ cvsdir/$_";
217 open(IN, "../$diff") or die $!;
218 open(OUT, '>new.patch') or die $!;
224 open(IN, 'diff --exclude-from=exclude -upr cvsdir workdir |') or die $!;
226 next if /^(diff -|Index: |Only in )/;
227 s#^\Q--- cvsdir/\E#--- orig/#;
228 s#^\Q+++ workdir/\E#+++ #;
229 s#(\.000000000)? \+0000$##;
237 print "\nDiffing... ";
238 if (system("diff ../$diff new.patch >/dev/null") == 0) {
239 print "new patch is identical to old.\n";
242 print "New patch DIFFERS from old.\n";
248 return unless $has_dependencies;
249 $has_dependencies = 0;
251 foreach (glob('*.~[1-9]~'), glob('*/*.~[1-9]~')) {
253 ($fn = $_) =~ s/\.~1~$//;