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.
12 my $dest = $ENV{HOME} . '/samba-rsync-ftp';
15 my $cl_today = time2str('* %a %b %d %Y', $now);
16 my $year = time2str('%Y', $now);
17 my $ztoday = time2str('%d %b %Y', $now);
18 (my $today = $ztoday) =~ s/^0//;
20 my $curdir = Cwd::cwd;
23 open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
29 @extra_files = split(' ', $_);
36 ==========================================================================
39 print $break, <<EOT, $break, "\n";
40 == This will release a new version of rsync onto an unsuspecting world. ==
43 die "$dest does not exist\n" unless -d $dest;
44 die "There is no .git dir in the current directory.\n" unless -d '.git';
45 die "'a' must not exist in the current directory.\n" if -e 'a';
46 die "'b' must not exist in the current directory.\n" if -e 'b';
48 open(IN, '-|', 'git status') or die $!;
49 my $status = join('', <IN>);
51 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
52 die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
55 open(IN, '<', 'configure.in') or die $!;
57 if (/^RSYNC_VERSION=(.*)/) {
63 die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
65 open(IN, '<', 'OLDNEWS') or die $!;
68 my($lastversion) = /(\d+\.\d+\.\d+)/;
70 my $version = $confversion;
71 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
73 print "Please enter the version number of this release: [$version] ";
76 $version =~ s/pre\d+//;
81 if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
82 $lastversion = $confversion;
85 print "Enter the previous version to produce a patch against: [$lastversion] ";
87 $lastversion = $_ if $_ ne '';
88 $lastversion =~ s/[-.]*pre[-.]*/pre/;
91 print "Please enter the RPM release number of this release: [$release] ";
93 $release = $_ if $_ ne '';
97 if ($lastversion =~ /pre/) {
98 if ($version !~ /pre/) {
99 die "You should not diff a release version against a pre-release version.\n";
101 $diffdir = "$dest/old-previews";
102 $skipping = ' ** SKIPPING **';
103 } elsif ($version =~ /pre/) {
105 $skipping = ' ** SKIPPING **';
107 $diffdir = "$dest/old-versions";
111 print "\n", $break, <<EOT;
112 \$version is "$version"
113 \$lastversion is "$lastversion"
115 \$curdir is "$curdir"
116 \$diffdir is "$diffdir"
117 \$release is "$release"
120 - make sure that SUBPROTOCOL_VERSION is 0$skipping
121 - tweak the version in configure.in and the spec files
122 - tweak NEWS and OLDNEWS to update the release date$skipping
123 - tweak the date in the *.yo files and generate the man pages
124 - generate configure.sh, config.h.in, and proto.h
125 - page through the differences
128 print "<Press Enter to continue> ";
131 (my $finalversion = $version) =~ s/pre\d+//;
132 my %specvars = ( 'Version:' => $version, 'Release:' => $release,
133 'Released' => "$version." );
134 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
135 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
137 foreach my $fn (@tweak_files) {
138 open(IN, '<', $fn) or die $!;
139 undef $/; $_ = <IN>; $/ = "\n";
141 if ($fn =~ /configure/) {
142 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
143 or die "Unable to update RSYNC_VERSION in $fn\n";
144 } elsif ($fn =~ /\.spec/) {
145 while (my($str, $val) = each %specvars) {
146 s/^\Q$str\E .*/$str $val/m
147 or die "Unable to update $str in $fn\n";
149 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
150 or die "Unable to update ChangeLog header in $fn\n";
151 } elsif ($fn =~ /\.yo/) {
152 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
153 or die "Unable to update date in manpage() header in $fn\n";
154 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
155 or die "Unable to update current version info in $fn\n";
156 } elsif ($fn eq 'rsync.h') {
157 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
158 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
159 next if $version =~ /pre/;
160 } elsif ($fn eq 'NEWS') {
161 s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
162 or die "The first line of $fn is not in the right format. It must be:\n"
163 . "NEWS for rsync $finalversion (UNRELEASED)\n";
164 next if $version =~ /pre/;
165 } elsif ($fn eq 'OLDNEWS') {
166 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
167 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
168 next if $version =~ /pre/;
169 } elsif ($fn eq 'options.c') {
170 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
172 die "Copyright comments need to be updated to $year in all files!\n";
174 # Adjust the year in the --version output.
175 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
176 or die "Unable to find Copyright string in --version output of $fn\n";
179 die "Unrecognized file in \@tweak_files: $fn\n";
181 open(OUT, '>', $fn) or die $!;
187 system "git diff --color | less -p '^diff .*'";
189 my $srctar_name = "rsync-$version.tar.gz";
190 my $pattar_name = "rsync-patches-$version.tar.gz";
191 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
192 my $srctar_file = "$dest/$srctar_name";
193 my $pattar_file = "$dest/$pattar_name";
194 my $diff_file = "$dest/$diff_name";
195 my $lasttar_file = "$dest/rsync-$lastversion.tar.gz";
201 - tag this release as v$version
202 - move the old tar/diff files into the appropriate old-* dirs
203 - hard-link the moved tar/diff files on samba.org
204 - create release tar, "$srctar_name"
205 - create patches tar, "$pattar_name"
206 - create release diffs, "$diff_name"
207 - update patch branches and generate patch/* files
208 - update README, *NEWS, TODO, and ChangeLog
209 - update rsync*.html man pages
210 - gpg-sign the release files
213 print "<Press Enter to continue> ";
216 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
217 print "\nSign the tag:";
218 system "git tag -s -m 'Version $version.' v$version" and exit 1;
220 # Extract some files from the old tar before we do the shuffle.
222 map { s#^#rsync-$lastversion/# } @_;
223 system "tar xzf $lasttar_file @_";
224 rename("rsync-$lastversion", 'a');
226 # When creating a pre-release after a normal release, there's nothing to move.
227 if ($diffdir ne $dest) {
228 chdir($dest) or die $!;
230 print "Shuffling old files ...\n";
232 # We need to run this regardless of $lastversion's "pre"ness.
234 foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) {
235 link($fn, "old-previews/$fn") or die $!;
236 push(@moved_files, $fn);
239 if ($version !~ /pre/) {
240 foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) {
241 next if $fn =~ /^rsync.*pre/;
242 link($fn, "old-versions/$fn") or die $!;
243 push(@moved_files, $fn);
246 foreach my $fn (glob('rsync*pre*.diffs.gz*')) {
250 foreach my $fn (glob('rsync*.diffs.gz*')) {
251 link($fn, "old-patches/$fn") or die $!;
252 push(@moved_files, $fn);
256 # Optimize our future upload (in the absence of --detect-renamed) by
257 # using rsync to hard-link the above files on samba.org.
258 system "rsync -avHOC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync";
259 foreach (@moved_files) {
263 chdir($curdir) or die $!;
266 print "Creating $diff_file ...\n";
267 system "./config.status Makefile; make gen; rsync -a @extra_files b/";
268 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
269 system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
271 rename('b', "rsync-$version");
273 print "Creating $srctar_file ...\n";
274 system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
275 system "support/git-set-file-times --prefix=rsync-$version/";
276 system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
278 mkdir("rsync-$version", 0755);
279 mkdir("rsync-$version/patches", 0755);
280 system "support/patch-update --skip-check --gen=rsync-$version/patches";
281 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
283 print "Updating the other files in $dest ...\n";
284 system "rsync -a README NEWS OLDNEWS TODO $dest";
285 unlink("$dest/rsync-$version-NEWS");
286 link("$dest/NEWS", "$dest/rsync-$version-NEWS");
287 system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
289 system "yodl2html -o $dest/rsync.html rsync.yo";
290 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
292 chdir($dest) or die $!;
294 foreach my $fn ($srctar_name, $pattar_name, $diff_name) {
295 print ++$cnt, ". Sign file \"$fn\":";
296 system "gpg -ba $fn";
298 print $break, <<'EOT';
300 Local changes are done. When you're satisfied, push the git repository
301 and rsync the release files. Remember to announce the release on *BOTH*
302 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!