Some improvements and fixes for the upcoming release.
[rsync/rsync.git] / packaging / release-rsync
CommitLineData
6d12a859
WD
1#!/usr/bin/perl
2use strict;
3
4# This script expects the directory ~/samba-rsync-ftp to exist and to
5# be a copy of the /home/ftp/pub/rsync dir on samba.org. If it is run
6# in test mode, it instead expects a dir named ~/tmp/samba-rsync-ftp
7# (e.g. copy ~/samba-rsync-ftp into ~/tmp and you can do a trial-run of
8# a release without affecting the files in the ~/samba-rsync-ftp dir).
9#
10# Run this as "release-rsync live" to affect ~/samba-rsync-ftp instead
11# of ~/tmp/samba-rsync-ftp.
12
13use Date::Format;
14
15my $dest = $ENV{HOME} . '/samba-rsync-ftp';
16my $releasedir = $ENV{HOME} . '/release';
17my $cvsroot = $ENV{CVSROOT} = 'samba.org:/data/cvs';
18
19my $ztoday = time2str('%d %b %Y', time);
20my $today = $ztoday;
21$today =~ s/^0//;
22
5fa38cd6
WD
23my $break = <<EOT;
24==========================================================================
6d12a859
WD
25EOT
26my $note = <<EOT;
5fa38cd6 27== Note: type "-a u,n" if you want to auto-accept the U,N suggestions. ==
6d12a859
WD
28EOT
29
30my $live = shift;
4d8639eb 31my $skipping = '';
6d12a859 32
5fa38cd6 33print $break;
6d12a859 34if ($live) {
5fa38cd6
WD
35 print <<EOT;
36== This will release a new version of rsync onto an unsuspecting world. ==
37EOT
6d12a859 38} else {
5fa38cd6
WD
39 print <<EOT;
40== **** TESTMODE **** (Add "live" arg to avoid this.) ==
41EOT
6d12a859 42 $dest =~ s#([^/]+$)#tmp/$1#;
4d8639eb 43 $skipping = ' ** SKIPPING **';
6d12a859
WD
44}
45die "$dest does not exist\n" unless -d $dest;
46
5fa38cd6 47print $break, "\nChecking out the latest rsync into $releasedir ...\n";
519c8de1
WD
48
49mkdir($releasedir, 0755) or die $! unless -d $releasedir;
50chdir($releasedir) or die $!;
51
5fa38cd6
WD
52system 'rm -rf rsync';
53
54my(%dirs, @files);
55open(CVS, '-|', 'cvs checkout -P rsync') or die $!;
56while (<CVS>) {
57 print $_;
58 next if /\.(cvs)?ignore$/;
59 if (m#^[UP] rsync/(.*)#) {
60 my $fn = $1;
61 my($dir) = $fn =~ m#^(.+)/#;
62 push(@files, $dir) if defined($dir) && !$dirs{$1}++;
63 push(@files, $fn);
64 }
65}
519c8de1
WD
66
67chdir('rsync') or die $!;
68
69my($version, $lastversion);
70open(IN, 'configure.in') or die $!;
71while (<IN>) {
72 if (/^RSYNC_VERSION=(.*)/) {
73 $version = $lastversion = $1;
74 last;
75 }
76}
77close IN;
78
2e4a3d17
WD
79if (my($major, $minor, $rel) = $lastversion =~ /(\d+)\.(\d+)\.(\d+)cvs$/) {
80 if (--$rel < 0) {
81 $rel = 9;
82 if (--$minor < 0) {
83 $minor = 6;
84 $major--;
85 }
86 }
87 $lastversion = "$major.$minor.$rel";
88}
89
519c8de1
WD
90$version =~ s/cvs/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
91
5fa38cd6 92print $break, "\nPlease enter the version number of this release: [$version] ";
519c8de1
WD
93chomp($_ = <STDIN>);
94if ($_ eq '.') {
95 $version =~ s/pre\d+//;
96} elsif ($_ ne '') {
97 $version = $_;
98}
6d12a859
WD
99$version =~ s/[-.]*pre[-.]*/pre/;
100
519c8de1
WD
101$lastversion =~ s/(\d+)pre\d+$/ $1 - 1 /e unless $version =~ /pre/;
102
6d12a859
WD
103my $cvstag = "release-$version";
104$cvstag =~ s/[.]/-/g;
105$cvstag =~ s/pre/-pre/;
106
519c8de1
WD
107print "Enter the previous version to produce a patch against: [$lastversion] ";
108chomp($_ = <STDIN>);
109$lastversion = $_ if $_ ne '';
6d12a859
WD
110$lastversion =~ s/[-.]*pre[-.]*/pre/;
111
519c8de1
WD
112my $release = 1;
113print "Please enter the RPM release number of this release: [$release] ";
114chomp($_ = <STDIN>);
115$release = $_ if $_ ne '';
6d12a859
WD
116
117my $diffdir;
5fa38cd6 118my $skipping2;
6d12a859
WD
119if ($lastversion =~ /pre/) {
120 if ($version !~ /pre/) {
121 die "You should not diff a release version against a pre-release version.\n";
122 }
123 $diffdir = "$dest/old-previews";
5fa38cd6 124 $skipping2 = ' ** SKIPPING **';
6d12a859
WD
125} elsif ($version =~ /pre/) {
126 $diffdir = $dest;
5fa38cd6 127 $skipping2 = ' ** SKIPPING **';
6d12a859
WD
128} else {
129 $diffdir = "$dest/old-versions";
5fa38cd6 130 $skipping2 = '';
6d12a859
WD
131}
132
5fa38cd6 133print "\n", $break, <<EOT;
6d12a859
WD
134\$version is "$version"
135\$lastversion is "$lastversion"
136\$cvstag is "$cvstag"
137\$dest is "$dest"
138\$releasedir is "$releasedir"
139\$diffdir is "$diffdir"
140\$release is "$release"
141
142About to:
2e4a3d17 143 - make sure that SUBPROTOCOL_VERSION is 0$skipping2
6d12a859 144 - tweak the version in configure.in, configure, and the spec files
2e4a3d17 145 - make sure that configure, config.h.in, and proto.h are updated
5fa38cd6 146 - tweak NEWS and OLDNEWS to update the release date$skipping2
6d12a859
WD
147 - tweak the date in the *.yo files and re-generate the man pages
148 - make sure that the patches dir has been updated
149 - page through the "cvs diff" output
150
151EOT
152print "<Press Enter to continue> ";
153$_ = <STDIN>;
c2b2bd6a 154my $f_opt = /f/ ? ' -f' : '';
6d12a859 155
5fa38cd6 156print $break;
6d12a859
WD
157system "./prepare-source && touch proto.h";
158
159my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'),
160 glob('*.yo'), qw( configure.in configure ) );
161if ($version !~ /pre/) {
2e4a3d17 162 push(@tweak_files, qw( rsync.h NEWS OLDNEWS ));
6d12a859
WD
163}
164foreach my $fn (@tweak_files) {
165 open(IN, '<', $fn) or die $!;
166 undef $/; $_ = <IN>; $/ = "\n";
167 close IN;
168 if ($fn =~ /configure/) {
200f2d98 169 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m;
6d12a859
WD
170 } elsif ($fn =~ /\.spec/) {
171 s/^(Version:) .*/$1 $version/m;
172 s/^(Release:) .*/$1 $release/m;
173 } elsif ($fn =~ /\.yo/) {
174 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
175 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
178a1d20
WD
176 } elsif ($fn eq 'NEWS') {
177 s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
178 or die "Couldn't update NEWS file with release date!\n";
2e4a3d17
WD
179 } elsif ($fn eq 'rsync.h') {
180 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/;
178a1d20
WD
181 } elsif ($fn eq 'OLDNEWS') {
182 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m
183 or die "Couldn't update OLDNEWS file with release date!\n";
6d12a859 184 } else {
178a1d20 185 die "Unrecognized file in \@tweak_files: $fn\n";
6d12a859
WD
186 }
187 open(OUT, '>', $fn) or die $!;
188 print OUT $_;
189 close OUT;
190}
191
2e4a3d17
WD
192system "yodl2man -o rsync.1 rsync.yo; ./tweak_manpage rsync.1";
193system "yodl2man -o rsyncd.conf.5 rsyncd.conf.yo; ./tweak_manpage rsyncd.conf.5";
6d12a859
WD
194
195mkdir('patches/tmp') or die $!;
196system "rsync -a --exclude=patches/ --exclude-from=.cvsignore . patches/tmp/cvsdir/";
197
5fa38cd6 198print "\n", $break, $note, $break;
c2b2bd6a 199system "patches/verify-patches -n -an$f_opt";
6d12a859 200
5fa38cd6 201print $break;
6d12a859
WD
202system "cvs -q diff | egrep -v '^(===============|RCS file: |retrieving revision |Index: )' | less -p '^diff .*'";
203
5fa38cd6 204print $break, <<EOT;
6d12a859
WD
205
206About to:
4d8639eb
WD
207 - "cvs commit" all changes$skipping
208 - "cvs tag" this release as $cvstag$skipping
5fa38cd6 209 - change the diffs in the patches dir to include generated files
6d12a859
WD
210
211EOT
5fa38cd6
WD
212print "<Press Enter to continue> ";
213$_ = <STDIN>;
6d12a859 214
5fa38cd6 215if ($live) {
6d12a859
WD
216 system "cvs commit -m 'Preparing for release of $version'";
217 system "cvs tag -F $cvstag .";
6d12a859
WD
218}
219
5fa38cd6
WD
220if (!/skip/i) {
221 print "\n", $break, $note, $break;
222 system "patches/verify-patches -pun -an";
223}
224
e60bba3f
WD
225my $tar_name = "rsync-$version.tar.gz";
226my $diff_name = "rsync-$lastversion-$version.diffs.gz";
227my $tar_file = "$dest/$tar_name";
228my $diff_file = "$dest/$diff_name";
5fa38cd6
WD
229
230print $break, <<EOT;
6d12a859
WD
231
232About to do the following in the samba-rsync-ftp dir:
4d8639eb 233 - move the old tar/diff files into the appropriate old-* dirs
5f12a07b 234 - hard-link the moved tar/diff files on samba.org$skipping
e60bba3f
WD
235 - create release tar, "$tar_name"
236 - create release diffs, "$diff_name"
6d12a859
WD
237 - update README, *NEWS, TODO, and cvs.log
238 - update rsync*.html man pages
e60bba3f 239 - gpg-sign the release files$skipping
6d12a859
WD
240
241EOT
242print "<Press Enter to continue> ";
243$_ = <STDIN>;
244
6d12a859
WD
245chdir($releasedir) or die $!;
246
5fa38cd6
WD
247print $break;
248system "rm -rf rsync-$version";
249rename('rsync', "rsync-$version") or die $!;
6d12a859
WD
250
251# When creating a pre-release after a normal release, there's nothing to move.
252if ($diffdir ne $dest) {
253 chdir($dest) or die $!;
254
5fa38cd6
WD
255 print "Shuffling old files ...\n";
256
519c8de1
WD
257 # We need to run this regardless of $lastversion's "pre"ness.
258 my @moved_files;
6d12a859 259 foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) {
5f12a07b
WD
260 link($fn, "old-previews/$fn") or die $!;
261 push(@moved_files, $fn);
6d12a859 262 }
6d12a859
WD
263
264 if ($version !~ /pre/) {
265 foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) {
4d8639eb 266 next if $fn =~ /^rsync.*pre/;
5f12a07b
WD
267 link($fn, "old-versions/$fn") or die $!;
268 push(@moved_files, $fn);
6d12a859
WD
269 }
270
178a1d20
WD
271 foreach my $fn (glob('rsync*pre*.diffs.gz*')) {
272 unlink($fn);
273 }
274
6d12a859 275 foreach my $fn (glob('rsync*.diffs.gz*')) {
5f12a07b
WD
276 link($fn, "old-patches/$fn") or die $!;
277 push(@moved_files, $fn);
6d12a859
WD
278 }
279 }
280
519c8de1 281 # Optimize our future upload (in the absence of --detect-renamed) by
5f12a07b 282 # using rsync to hard-link the above files on samba.org.
519c8de1 283 if ($live) {
5f12a07b 284 system "rsync -avHOC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync";
519c8de1 285 }
178a1d20 286 foreach (@moved_files) {
519c8de1
WD
287 unlink($_);
288 }
289
6d12a859
WD
290 chdir($releasedir) or die $!;
291}
6d12a859 292
5fa38cd6
WD
293print "Creating $tar_file ...\n";
294system "fakeroot tar czf $tar_file rsync-$version";
651dc65e 295open(TAR, '|-', "fakeroot tar --files-from=- --no-recursion --mode=g+w -czf $tar_file rsync-$version") or die $!;
5fa38cd6
WD
296foreach (@files) {
297 print TAR "rsync-$version/$_\n";
298}
299close TAR;
300
301print "Creating $diff_file ...\n";
302system "rm -rf rsync-$version rsync-$lastversion";
303system "tar xzf $tar_file; tar xzf $diffdir/rsync-$lastversion.tar.gz";
6d12a859
WD
304## TWEAK THE VERSIONS AS DESIRED HERE ##
305#mkdir("rsync-$lastversion/support", 0755) or die $!;
306#rename("rsync-$lastversion/rsyncstats", "rsync-$lastversion/support/rsyncstats");
a00f5a37 307#unlink("rsync-$lastversion/.ignore");
6d12a859 308## END ##
5fa38cd6 309system "diff -urN --exclude=patches rsync-$lastversion rsync-$version| gzip -9 >$diff_file";
6d12a859 310
5fa38cd6
WD
311print "Updating the other files in $dest ...\n";
312system "rsync -a rsync-$version/{README,NEWS,OLDNEWS,TODO} $dest";
6d12a859
WD
313unlink("$dest/rsync-$version-NEWS");
314link("$dest/NEWS", "$dest/rsync-$version-NEWS");
315system "rsync -a $cvsroot/CVSROOT/rsync.updates $dest/cvs.log";
316
5fa38cd6
WD
317system "yodl2html -o $dest/rsync.html rsync-$version/rsync.yo";
318system "yodl2html -o $dest/rsyncd.conf.html rsync-$version/rsyncd.conf.yo";
6d12a859 319
5fa38cd6 320system "rm -rf rsync-*";
6d12a859
WD
321
322if ($live) {
323 chdir($dest) or die $!;
e60bba3f 324 system "gpg -ba $tar_name; gpg -ba $diff_name";
de343840 325 print $break, <<EOT;
6d12a859
WD
326
327All done. Remember to announce the release on *BOTH*
328rsync-announce\@lists.samba.org and rsync\@lists.samba.org!
329EOT
de343840
WD
330} else {
331 print $break, "All done.\n";
332}