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