- Moved the checkout of the cvs source above the version prompting so
[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
23my $dots = <<EOT;
24.........................................................................
25EOT
26my $note = <<EOT;
27
28**
29** Note: type "-a u,n" if you want to auto-accept the U,N suggestions. **
30**
31EOT
32
33my $live = shift;
34
35if ($live) {
36 print "This will release a new version of rsync onto an unsuspecting world.\n";
37} else {
38 print "**** TESTMODE **** (add \"live\" arg to avoid this)\n";
39 $dest =~ s#([^/]+$)#tmp/$1#;
40}
41die "$dest does not exist\n" unless -d $dest;
42
519c8de1
WD
43print "Checking out the latest rsync into $releasedir...\n";
44
45mkdir($releasedir, 0755) or die $! unless -d $releasedir;
46chdir($releasedir) or die $!;
47
48system "rm -rf rsync rsync-*";
49
50system "cvs checkout -P rsync";
51
52chdir('rsync') or die $!;
53
54my($version, $lastversion);
55open(IN, 'configure.in') or die $!;
56while (<IN>) {
57 if (/^RSYNC_VERSION=(.*)/) {
58 $version = $lastversion = $1;
59 last;
60 }
61}
62close IN;
63
64$lastversion =~ s/(\d+)cvs$/ $1 - 1 /e;
65$version =~ s/cvs/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
66
67print "\nPlease enter the version number of this release: [$version] ";
68chomp($_ = <STDIN>);
69if ($_ eq '.') {
70 $version =~ s/pre\d+//;
71} elsif ($_ ne '') {
72 $version = $_;
73}
6d12a859
WD
74$version =~ s/[-.]*pre[-.]*/pre/;
75
519c8de1
WD
76$lastversion =~ s/(\d+)pre\d+$/ $1 - 1 /e unless $version =~ /pre/;
77
6d12a859
WD
78my $cvstag = "release-$version";
79$cvstag =~ s/[.]/-/g;
80$cvstag =~ s/pre/-pre/;
81
519c8de1
WD
82print "Enter the previous version to produce a patch against: [$lastversion] ";
83chomp($_ = <STDIN>);
84$lastversion = $_ if $_ ne '';
6d12a859
WD
85$lastversion =~ s/[-.]*pre[-.]*/pre/;
86
519c8de1
WD
87my $release = 1;
88print "Please enter the RPM release number of this release: [$release] ";
89chomp($_ = <STDIN>);
90$release = $_ if $_ ne '';
6d12a859
WD
91
92my $diffdir;
93if ($lastversion =~ /pre/) {
94 if ($version !~ /pre/) {
95 die "You should not diff a release version against a pre-release version.\n";
96 }
97 $diffdir = "$dest/old-previews";
98} elsif ($version =~ /pre/) {
99 $diffdir = $dest;
100} else {
101 $diffdir = "$dest/old-versions";
102}
103
104my $tarfile = "$dest/rsync-$version.tar.gz";
105
106print <<EOT;
107
108\$version is "$version"
109\$lastversion is "$lastversion"
110\$cvstag is "$cvstag"
111\$dest is "$dest"
112\$releasedir is "$releasedir"
113\$diffdir is "$diffdir"
114\$release is "$release"
115
116About to:
6d12a859
WD
117 - tweak NEWS and OLDNEWS to update the release date
118 - tweak the version in configure.in, configure, and the spec files
119 - tweak the date in the *.yo files and re-generate the man pages
120 - make sure that the patches dir has been updated
121 - page through the "cvs diff" output
122
123EOT
124print "<Press Enter to continue> ";
125$_ = <STDIN>;
126
6d12a859
WD
127print $dots;
128
129system "./prepare-source && touch proto.h";
130
131my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'),
132 glob('*.yo'), qw( configure.in configure ) );
133if ($version !~ /pre/) {
134 push(@tweak_files, qw( NEWS OLDNEWS ));
135}
136foreach my $fn (@tweak_files) {
137 open(IN, '<', $fn) or die $!;
138 undef $/; $_ = <IN>; $/ = "\n";
139 close IN;
140 if ($fn =~ /configure/) {
141 s/^RSYNC_VERSION.*/RSYNC_VERSION=$version/m;
142 } elsif ($fn =~ /\.spec/) {
143 s/^(Version:) .*/$1 $version/m;
144 s/^(Release:) .*/$1 $release/m;
145 } elsif ($fn =~ /\.yo/) {
146 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
147 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
148 } else {
149 s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*$/$1 ($today)\n/m;
150 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m;
151 }
152 open(OUT, '>', $fn) or die $!;
153 print OUT $_;
154 close OUT;
155}
156
157system "yodl2man -o rsync.1 rsync.yo";
158system "yodl2man -o rsyncd.conf.5 rsyncd.conf.yo";
159#system "perl -pi -e \"s/\\\\\\'/\\\\&'/g\" rsync.1 rsyncd.conf.5";
160
161mkdir('patches/tmp') or die $!;
162system "rsync -a --exclude=patches/ --exclude-from=.cvsignore . patches/tmp/cvsdir/";
163
164print $dots, $note;
165
166system "patches/verify-patches -un -an";
167
168system "cvs -q diff | egrep -v '^(===============|RCS file: |retrieving revision |Index: )' | less -p '^diff .*'";
169
73abdda4 170print <<EOT;
6d12a859
WD
171
172About to:
173 - "cvs commit" all changes
174 - "cvs tag" this release as $cvstag
175
176EOT
73abdda4 177if ($live) {
6d12a859
WD
178 print "<Press Enter to continue> ";
179 $_ = <STDIN>;
180
181 system "cvs commit -m 'Preparing for release of $version'";
182 system "cvs tag -F $cvstag .";
183} else {
519c8de1 184 print "**** Skipping cvs commit and tagging in TESTMODE ****\n";
6d12a859
WD
185}
186
187print <<EOT;
188
189About to do the following in the samba-rsync-ftp dir:
190 - change the diffs in the patches dir to include generated files
519c8de1
WD
191 - move the old tar/diff files into the appropriate old-* dir
192 - hard-link the new tar/diff files to the old on samba.org
6d12a859
WD
193 - create release tar "$tarfile"
194 - create release diffs
195 - update README, *NEWS, TODO, and cvs.log
196 - update rsync*.html man pages
197
198EOT
199print "<Press Enter to continue> ";
200$_ = <STDIN>;
201
202print $note;
203
204system "patches/verify-patches -pun -an";
205
206chdir($releasedir) or die $!;
207
208print $dots;
209
210mkdir("rsync-$version", 0755) or die $!;
211system "rsync -aC --exclude=.cvsignore rsync/ rsync-$version";
212
213# When creating a pre-release after a normal release, there's nothing to move.
214if ($diffdir ne $dest) {
215 chdir($dest) or die $!;
216
519c8de1
WD
217 # We need to run this regardless of $lastversion's "pre"ness.
218 my @moved_files;
6d12a859 219 foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) {
519c8de1
WD
220 link($fn, "old-previews/$fn") or die $!;
221 push(@moved_files, $fn);
6d12a859 222 }
6d12a859
WD
223
224 if ($version !~ /pre/) {
225 foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) {
519c8de1
WD
226 link($fn, "old-versions/$fn") or die $!;
227 push(@moved_files, $fn);
6d12a859
WD
228 }
229
230 foreach my $fn (glob('rsync*.diffs.gz*')) {
519c8de1
WD
231 link($fn, "old-patches/$fn") or die $!;
232 push(@moved_files, $fn);
6d12a859
WD
233 }
234 }
235
519c8de1
WD
236 # Optimize our future upload (in the absence of --detect-renamed) by
237 # uploading the above hard-linked files that we are about to delete.
238 if ($live) {
239 system "rsync -avHC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync";
240 }
241 foreach (@moved_files, glob("rsync*pre*.diffs.gz*")) {
242 unlink($_);
243 }
244
6d12a859
WD
245 chdir($releasedir) or die $!;
246}
247system "fakeroot tar czf $tarfile rsync-$version";
248
249system "tar xzf $diffdir/rsync-$lastversion.tar.gz";
250## TWEAK THE VERSIONS AS DESIRED HERE ##
251#mkdir("rsync-$lastversion/support", 0755) or die $!;
252#rename("rsync-$lastversion/rsyncstats", "rsync-$lastversion/support/rsyncstats");
253## END ##
254system "diff -urN --exclude=patches rsync-$lastversion rsync-$version"
255 . "| gzip -9 >$dest/rsync-$lastversion-$version.diffs.gz";
256
257system "rsync -a rsync/{README,NEWS,OLDNEWS,TODO} $dest";
258unlink("$dest/rsync-$version-NEWS");
259link("$dest/NEWS", "$dest/rsync-$version-NEWS");
260system "rsync -a $cvsroot/CVSROOT/rsync.updates $dest/cvs.log";
261
262system "yodl2html -o $dest/rsync.html rsync/rsync.yo";
263system "yodl2html -o $dest/rsyncd.conf.html rsync/rsyncd.conf.yo";
264
265system "rm -rf rsync rsync-$version rsync-$lastversion";
266
267if ($live) {
268 chdir($dest) or die $!;
269 system "gpg -ba rsync-$version.tar.gz";
270 system "gpg -ba rsync-$lastversion-$version.diffs.gz";
271}
272
273print <<EOT;
274
275All done. Remember to announce the release on *BOTH*
276rsync-announce\@lists.samba.org and rsync\@lists.samba.org!
277EOT