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.
17 my($has_dependencies, @new, @rejects);
21 system "rsync -a --delete cvsdir/ workdir/" if -d 'cvsdir';
25 open(IN, '../CVS/Root') or die $!;
29 mkdir('tmp', 0777) unless -d 'tmp';
30 chdir('tmp') or die "Unable to chdir to 'tmp'";
32 mkdir('workdir') unless -d 'workdir';
33 open(OUT, '>exclude') or die $!;
44 print "Using CVS to update the tmp/cvsdir copy of the source.\n";
45 system qq|cvs -d "$root" co -d cvsdir rsync|;
47 @ARGV = glob('../*.diff') unless @ARGV;
50 foreach my $diff (@ARGV) {
51 next unless $diff =~ /\.diff$/;
52 next if $diff =~ /gzip-rsyncable\.diff$/;
53 $diff =~ s#^(patches|\.\.)/##;
55 open(IN, "../$diff") or die $!;
58 if (/^Depends-On-Patch: (\S+.diff)$/) {
60 $has_dependencies = 1;
61 print "\nApplying dependency patch $dep\n";
62 if (system("patch -d cvsdir -p0 -b -Vt -Zf <../$dep") != 0) {
63 print "Unable to cleanly apply depenency patch -- skipping $diff\n";
71 my $default = apply_patch($diff);
74 print "\n----------- $diff ------------\n",
75 "\nFix rejects, Diff create, Edit both diffs, Update patch,\n",
76 "Apply patch again, !(CMD), Build rsync, Next, Quit: [$default] ";
79 $ans = $default if $ans eq '';
80 if ($ans =~ /^!(.*)/) {
81 my $cmd = $1 || $ENV{'SHELL'};
82 chdir('workdir') or die $!;
84 chdir('..') or die $!;
88 if ($ans =~ /^\S*F/i) {
89 chdir('workdir') or die $!;
90 system "vim @rejects";
91 chdir('..') or die $!;
94 if ($ans =~ /^\S*D/i) {
95 $default = generate_new_patch($diff);
97 if ($ans =~ /^\S*E/i) {
98 chdir('workdir') or die $!;
99 system "vim -d ../../$diff ../new.patch";
100 chdir('..') or die $!;
103 if ($ans =~ /^\S*U/i) {
104 system "cp -p new.patch ../$diff";
105 print "\nUpdated $diff from new.patch\n";
108 if ($ans =~ /^\S*A/i) {
109 $default = apply_patch($diff);
111 if ($ans =~ /^\S*B/i) {
112 if (!-f 'workdir/Makefile') {
113 open(IN, '../../Makefile') or die $!;
114 open(OUT, '>workdir/Makefile') or die $!;
115 print OUT "srcdir=.\n\n";
127 chdir('workdir') or die $!;
128 system "make gen; ./configure $CONF_OPTS; make";
129 chdir('..') or die $!;
130 $default = '!make test';
132 if ($ans =~ /^\S*Q/i) {
135 if ($ans =~ /^\S*N/i) {
152 system "rsync -a --delete cvsdir/ workdir/";
154 open(IN, "patch -d workdir -p0 --no-backup-if-mismatch -Zf <../$diff |") or die $!;
158 if (s/^patching file //) {
159 push(@new, $_) unless -f "cvsdir/$_";
160 } elsif (s/.* saving rejects to file //) {
162 } elsif (/^Hunk #\d+ FAILED/) {
164 } elsif (/^Hunk #\d+ succeeded/) {
165 $def = 'E' unless $def eq 'F,D,E';
170 generate_new_patch($diff);
175 sub generate_new_patch
180 system "touch -r workdir/$_ cvsdir/$_";
182 open(IN, "../$diff") or die $!;
183 open(OUT, '>new.patch') or die $!;
189 open(IN, 'diff --exclude-from=exclude -upr cvsdir workdir |') or die $!;
191 next if /^(diff -|Index: |Only in )/;
192 s#^\Q--- cvsdir/\E#--- orig/#;
193 s#^\Q+++ workdir/\E#+++ #;
194 s#(\.000000000)? \+0000$##;
202 if (system("diff ../$diff new.patch >/dev/null") == 0) {
203 print "\n(New patch is identical to old.)\n";
211 return unless $has_dependencies;
212 $has_dependencies = 0;
214 foreach (glob('*.~[1-9]~'), glob('*/*.~[1-9]~')) {
216 ($fn = $_) =~ s/\.~1~$//;