Simplify the description of what we're doing.
[rsync/rsync.git] / packaging / release-rsync
CommitLineData
6d12a859
WD
1#!/usr/bin/perl
2use strict;
3
805d8ac4
WD
4# This script expects the directory ~/samba-rsync-ftp to exist and to be a
5# copy of the /home/ftp/pub/rsync dir on samba.org. When the script is done,
6# the git repository in the current directory will be updated, and the local
7# ~/samba-rsync-ftp dir will be ready to be rsynced to samba.org.
6d12a859 8
805d8ac4 9use Cwd;
6d12a859
WD
10use Date::Format;
11
12my $dest = $ENV{HOME} . '/samba-rsync-ftp';
6d12a859 13
fede3785
WD
14my $now = time;
15my $cl_today = time2str('* %a %b %d %Y', $now);
16my $year = time2str('%Y', $now);
17my $ztoday = time2str('%d %b %Y', $now);
90ac152d 18(my $today = $ztoday) =~ s/^0//;
6d12a859 19
805d8ac4
WD
20my $curdir = Cwd::cwd;
21
67b9b26f
WD
22my @extra_files;
23open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
24while (<IN>) {
25 if (s/^GENFILES=//) {
26 while (s/\\$//) {
27 $_ .= <IN>;
28 }
29 @extra_files = split(' ', $_);
30 last;
31 }
32}
805d8ac4
WD
33close IN;
34
5fa38cd6
WD
35my $break = <<EOT;
36==========================================================================
6d12a859 37EOT
6d12a859 38
805d8ac4 39print $break, <<EOT, $break, "\n";
5fa38cd6
WD
40== This will release a new version of rsync onto an unsuspecting world. ==
41EOT
519c8de1 42
805d8ac4
WD
43die "$dest does not exist\n" unless -d $dest;
44die "There is no .git dir in the current directory.\n" unless -d '.git';
45die "'a' must not exist in the current directory.\n" if -e 'a';
46die "'b' must not exist in the current directory.\n" if -e 'b';
519c8de1 47
6a2456c5 48open(IN, '-|', 'git status') or die $!;
805d8ac4
WD
49my $status = join('', <IN>);
50close IN;
51die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
52die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
519c8de1 53
fede3785 54my $confversion;
578219be 55open(IN, '<', 'configure.in') or die $!;
519c8de1
WD
56while (<IN>) {
57 if (/^RSYNC_VERSION=(.*)/) {
fede3785 58 $confversion = $1;
519c8de1
WD
59 last;
60 }
61}
62close IN;
fede3785 63die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
2e4a3d17 64
62ca3826
WD
65open(IN, '<', 'OLDNEWS') or die $!;
66$_ = <IN>;
67close IN;
fede3785 68my($lastversion) = /(\d+\.\d+\.\d+)/;
62ca3826 69
fede3785 70my $version = $confversion;
805d8ac4 71$version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
519c8de1 72
805d8ac4 73print "Please enter the version number of this release: [$version] ";
519c8de1
WD
74chomp($_ = <STDIN>);
75if ($_ eq '.') {
76 $version =~ s/pre\d+//;
77} elsif ($_ ne '') {
78 $version = $_;
79}
fede3785
WD
80
81if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
82 $lastversion = $confversion;
83}
6d12a859 84
519c8de1
WD
85print "Enter the previous version to produce a patch against: [$lastversion] ";
86chomp($_ = <STDIN>);
87$lastversion = $_ if $_ ne '';
6d12a859
WD
88$lastversion =~ s/[-.]*pre[-.]*/pre/;
89
519c8de1
WD
90my $release = 1;
91print "Please enter the RPM release number of this release: [$release] ";
92chomp($_ = <STDIN>);
93$release = $_ if $_ ne '';
6d12a859 94
e63d3a29 95my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
6d12a859
WD
96if ($lastversion =~ /pre/) {
97 if ($version !~ /pre/) {
98 die "You should not diff a release version against a pre-release version.\n";
99 }
e63d3a29 100 $srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
805d8ac4 101 $skipping = ' ** SKIPPING **';
6d12a859 102} elsif ($version =~ /pre/) {
e63d3a29
WD
103 $srcdir = $srcdiffdir = 'src-previews';
104 $lastsrcdir = 'src';
805d8ac4 105 $skipping = ' ** SKIPPING **';
6d12a859 106} else {
e63d3a29
WD
107 $srcdir = $lastsrcdir = 'src';
108 $srcdiffdir = 'src-diffs';
805d8ac4 109 $skipping = '';
6d12a859
WD
110}
111
5fa38cd6 112print "\n", $break, <<EOT;
6d12a859
WD
113\$version is "$version"
114\$lastversion is "$lastversion"
6d12a859 115\$dest is "$dest"
805d8ac4 116\$curdir is "$curdir"
e63d3a29
WD
117\$srcdir is "$srcdir"
118\$srcdiffdir is "$srcdiffdir"
119\$lastsrcdir is "$lastsrcdir"
6d12a859
WD
120\$release is "$release"
121
122About to:
805d8ac4
WD
123 - make sure that SUBPROTOCOL_VERSION is 0$skipping
124 - tweak the version in configure.in and the spec files
125 - tweak NEWS and OLDNEWS to update the release date$skipping
126 - tweak the date in the *.yo files and generate the man pages
127 - generate configure.sh, config.h.in, and proto.h
128 - page through the differences
6d12a859
WD
129
130EOT
131print "<Press Enter to continue> ";
132$_ = <STDIN>;
133
800a4485
WD
134(my $finalversion = $version) =~ s/pre\d+//;
135my %specvars = ( 'Version:' => $version, 'Release:' => $release,
136 'Released' => "$version." );
137my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
138 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
805d8ac4 139
6d12a859
WD
140foreach my $fn (@tweak_files) {
141 open(IN, '<', $fn) or die $!;
142 undef $/; $_ = <IN>; $/ = "\n";
143 close IN;
144 if ($fn =~ /configure/) {
800a4485
WD
145 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
146 or die "Unable to update RSYNC_VERSION in $fn\n";
6d12a859 147 } elsif ($fn =~ /\.spec/) {
800a4485
WD
148 while (my($str, $val) = each %specvars) {
149 s/^\Q$str\E .*/$str $val/m
150 or die "Unable to update $str in $fn\n";
151 }
152 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
153 or die "Unable to update ChangeLog header in $fn\n";
6d12a859 154 } elsif ($fn =~ /\.yo/) {
800a4485
WD
155 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
156 or die "Unable to update date in manpage() header in $fn\n";
157 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
158 or die "Unable to update current version info in $fn\n";
2e4a3d17 159 } elsif ($fn eq 'rsync.h') {
800a4485
WD
160 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
161 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
162 next if $version =~ /pre/;
163 } elsif ($fn eq 'NEWS') {
164 s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
165 or die "The first line of $fn is not in the right format. It must be:\n"
166 . "NEWS for rsync $finalversion (UNRELEASED)\n";
167 next if $version =~ /pre/;
178a1d20 168 } elsif ($fn eq 'OLDNEWS') {
800a4485
WD
169 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
170 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
171 next if $version =~ /pre/;
fede3785 172 } elsif ($fn eq 'options.c') {
800a4485
WD
173 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
174 && $2 ne $year) {
175 die "Copyright comments need to be updated to $year in all files!\n";
176 }
177 # Adjust the year in the --version output.
178 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
179 or die "Unable to find Copyright string in --version output of $fn\n";
180 next if $2 eq $year;
6d12a859 181 } else {
178a1d20 182 die "Unrecognized file in \@tweak_files: $fn\n";
6d12a859
WD
183 }
184 open(OUT, '>', $fn) or die $!;
185 print OUT $_;
186 close OUT;
187}
188
5fa38cd6 189print $break;
6a2456c5 190system "git diff --color | less -p '^diff .*'";
5fa38cd6 191
805d8ac4
WD
192my $srctar_name = "rsync-$version.tar.gz";
193my $pattar_name = "rsync-patches-$version.tar.gz";
e60bba3f 194my $diff_name = "rsync-$lastversion-$version.diffs.gz";
e63d3a29
WD
195my $srctar_file = "$dest/$srcdir/$srctar_name";
196my $pattar_file = "$dest/$srcdir/$pattar_name";
197my $diff_file = "$dest/$srcdiffdir/$diff_name";
198my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
199my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
5fa38cd6
WD
200
201print $break, <<EOT;
6d12a859 202
805d8ac4
WD
203About to:
204 - commit all changes
205 - tag this release as v$version
af6241f7 206 - update hard-linked top-level files for new version$skipping
805d8ac4
WD
207 - create release tar, "$srctar_name"
208 - create patches tar, "$pattar_name"
e60bba3f 209 - create release diffs, "$diff_name"
805d8ac4 210 - update patch branches and generate patch/* files
eaa28e65 211 - update README, *NEWS, TODO, and ChangeLog
6d12a859 212 - update rsync*.html man pages
805d8ac4 213 - gpg-sign the release files
6d12a859
WD
214
215EOT
216print "<Press Enter to continue> ";
217$_ = <STDIN>;
218
6a2456c5 219system "git commit -a -m 'Preparing for release of $version'" and exit 1;
62ca3826 220print "\nSign the tag:";
6a2456c5 221system "git tag -s -m 'Version $version.' v$version" and exit 1;
6d12a859 222
e63d3a29 223# Extract the generated files from the old tar.
4bb319c6
WD
224@_ = @extra_files;
225map { s#^#rsync-$lastversion/# } @_;
226system "tar xzf $lasttar_file @_";
227rename("rsync-$lastversion", 'a');
228
5fa38cd6 229print "Creating $diff_file ...\n";
4da9fcd4 230system "./config.status Makefile; make gen; rsync -a @extra_files b/";
ee8a733d 231my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
62ca3826 232system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
9217ce30
WD
233system "rm -rf a";
234rename('b', "rsync-$version");
235
236print "Creating $srctar_file ...\n";
237system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
238system "support/git-set-file-times --prefix=rsync-$version/";
239system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
805d8ac4 240
4da9fcd4
WD
241mkdir("rsync-$version", 0755);
242mkdir("rsync-$version/patches", 0755);
f2b7b64d 243system "support/patch-update --skip-check --gen=rsync-$version/patches";
4da9fcd4 244system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
6d12a859 245
5fa38cd6 246print "Updating the other files in $dest ...\n";
805d8ac4 247system "rsync -a README NEWS OLDNEWS TODO $dest";
e63d3a29
WD
248unlink($news_file);
249link("$dest/NEWS", $news_file);
eaa28e65 250system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
6d12a859 251
805d8ac4
WD
252system "yodl2html -o $dest/rsync.html rsync.yo";
253system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
6d12a859 254
e0fe5231 255my $cnt = 0;
e63d3a29
WD
256print "\n";
257foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
e0fe5231
WD
258 print ++$cnt, ". Sign file \"$fn\":";
259 system "gpg -ba $fn";
260}
e63d3a29
WD
261
262if ($version !~ /pre/) {
263 system "rm $dest/rsync-*{.tar.gz,.asc,-NEWS} $dest/src-preview/rsync-*diffs.gz";
264
265 foreach my $fn ($srctar_file, "$srctar_file.asc",
266 $pattar_file, "$pattar_file.asc",
267 $diff_file, "$diff_file.asc", $news_file) {
268 (my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
269 link($fn, $top_fn);
270 }
271}
272
e0fe5231 273print $break, <<'EOT';
6d12a859 274
e0fe5231
WD
275Local changes are done. When you're satisfied, push the git repository
276and rsync the release files. Remember to announce the release on *BOTH*
277rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
6d12a859 278EOT