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