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';
14 my $cl_today = time2str('* %a %b %d %Y', time);
15 my $ztoday = time2str('%d %b %Y', time);
16 (my $today = $ztoday) =~ s/^0//;
18 my $curdir = Cwd::cwd;
20 open(IN, '<', 'prepare-source.mak') or die "Couldn't open prepare-source.mak: $!\n";
24 my @extra_files = m{\n([^\s:]+):.*\n\t\S}g;
27 ==========================================================================
30 print $break, <<EOT, $break, "\n";
31 == This will release a new version of rsync onto an unsuspecting world. ==
34 die "$dest does not exist\n" unless -d $dest;
35 die "There is no .git dir in the current directory.\n" unless -d '.git';
36 die "'a' must not exist in the current directory.\n" if -e 'a';
37 die "'b' must not exist in the current directory.\n" if -e 'b';
39 open(IN, '-|', 'git-status') or die $!;
40 my $status = join('', <IN>);
42 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
43 die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
46 open(IN, '<', 'configure.in') or die $!;
48 if (/^RSYNC_VERSION=(.*)/) {
54 if ($lastversion =~ /dev$/) {
55 open(IN, '<', 'OLDNEWS') or die $!;
58 ($lastversion) = /(\d+\.\d+\.\d+)/;
61 my $version = $lastversion;
62 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
64 print "Please enter the version number of this release: [$version] ";
67 $version =~ s/pre\d+//;
71 $version =~ s/[-.]*pre[-.]*/pre/;
73 print "Enter the previous version to produce a patch against: [$lastversion] ";
75 $lastversion = $_ if $_ ne '';
76 $lastversion =~ s/[-.]*pre[-.]*/pre/;
79 print "Please enter the RPM release number of this release: [$release] ";
81 $release = $_ if $_ ne '';
85 if ($lastversion =~ /pre/) {
86 if ($version !~ /pre/) {
87 die "You should not diff a release version against a pre-release version.\n";
89 $diffdir = "$dest/old-previews";
90 $skipping = ' ** SKIPPING **';
91 } elsif ($version =~ /pre/) {
93 $skipping = ' ** SKIPPING **';
95 $diffdir = "$dest/old-versions";
99 print "\n", $break, <<EOT;
100 \$version is "$version"
101 \$lastversion is "$lastversion"
103 \$curdir is "$curdir"
104 \$diffdir is "$diffdir"
105 \$release is "$release"
108 - make sure that SUBPROTOCOL_VERSION is 0$skipping
109 - tweak the version in configure.in and the spec files
110 - tweak NEWS and OLDNEWS to update the release date$skipping
111 - tweak the date in the *.yo files and generate the man pages
112 - generate configure.sh, config.h.in, and proto.h
113 - page through the differences
116 print "<Press Enter to continue> ";
121 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'),
122 glob('*.yo'), qw( configure.in ) );
124 if ($version !~ /pre/) {
125 push(@tweak_files, qw( rsync.h NEWS OLDNEWS ));
127 foreach my $fn (@tweak_files) {
128 open(IN, '<', $fn) or die $!;
129 undef $/; $_ = <IN>; $/ = "\n";
131 if ($fn =~ /configure/) {
132 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m;
133 } elsif ($fn =~ /\.spec/) {
134 s/^(Version:) .*/$1 $version/m;
135 s/^(Release:) .*/$1 $release/m;
136 s/^(Released) .*/$1 $version./m;
137 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m;
138 } elsif ($fn =~ /\.yo/) {
139 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
140 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
141 } elsif ($fn eq 'NEWS') {
142 s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
143 or die "Couldn't update NEWS file with release date!\n";
144 } elsif ($fn eq 'rsync.h') {
145 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/;
146 } elsif ($fn eq 'OLDNEWS') {
147 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m
148 or die "Couldn't update OLDNEWS file with release date!\n";
150 die "Unrecognized file in \@tweak_files: $fn\n";
152 open(OUT, '>', $fn) or die $!;
157 system "./prepare-source && touch proto.h";
160 system "git-diff --color |less -p '^diff .*'";
162 my $srctar_name = "rsync-$version.tar.gz";
163 my $pattar_name = "rsync-patches-$version.tar.gz";
164 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
165 my $srctar_file = "$dest/$srctar_name";
166 my $pattar_file = "$dest/$pattar_name";
167 my $diff_file = "$dest/$diff_name";
168 my $lasttar_file = "$dest/rsync-$lastversion.tar.gz";
174 - tag this release as v$version
175 - move the old tar/diff files into the appropriate old-* dirs
176 - hard-link the moved tar/diff files on samba.org
177 - create release tar, "$srctar_name"
178 - create patches tar, "$pattar_name"
179 - create release diffs, "$diff_name"
180 - update patch branches and generate patch/* files
181 - update README, *NEWS, TODO, and changelog
182 - update rsync*.html man pages
183 - gpg-sign the release files
186 print "<Press Enter to continue> ";
191 $_[0] =~ s/configure\.sh/configure/; # XXX remove soon
192 system "tar xzf $lasttar_file @_";
193 rename("a/configure", "a/configure.sh"); # XXX remove soon
195 system "rsync -a @extra_files rsync-$version/";
197 system "git-commit -a -m 'Preparing for release of $version'" and exit 1;
198 system "git-tag -s -m 'Version $version.' v$version" and exit 1;
200 # When creating a pre-release after a normal release, there's nothing to move.
201 if ($diffdir ne $dest) {
202 chdir($dest) or die $!;
204 print "Shuffling old files ...\n";
206 # We need to run this regardless of $lastversion's "pre"ness.
208 foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) {
209 link($fn, "old-previews/$fn") or die $!;
210 push(@moved_files, $fn);
213 if ($version !~ /pre/) {
214 foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) {
215 next if $fn =~ /^rsync.*pre/;
216 link($fn, "old-versions/$fn") or die $!;
217 push(@moved_files, $fn);
220 foreach my $fn (glob('rsync*pre*.diffs.gz*')) {
224 foreach my $fn (glob('rsync*.diffs.gz*')) {
225 link($fn, "old-patches/$fn") or die $!;
226 push(@moved_files, $fn);
230 # Optimize our future upload (in the absence of --detect-renamed) by
231 # using rsync to hard-link the above files on samba.org.
232 system "rsync -avHOC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync";
233 foreach (@moved_files) {
237 chdir($curdir) or die $!;
240 print "Creating $srctar_file ...\n";
241 (my $srctar_tmp = $srctar_file) =~ s/\.gz$//;
242 system "git-archive --format=tar --prefix=rsync-$version/ v$version >$srctar_tmp";
243 system "fakeroot tar rf $srctar_tmp rsync-$version/*; gzip -9 $srctar_tmp";
245 print "Creating $diff_file ...\n";
246 rename("rsync-$version", 'b');
247 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
248 system "(git-diff v$lastversion v$version; diff -up a b | sed -r '$sed_script') | gzip -9 >$diff_file";
251 system "support/patch-update --gen";
253 symlink('.', "rsync-$version");
254 system "tar czf $pattar_file rsync-$version/patches";
255 unlink("rsync-$version");
257 print "Updating the other files in $dest ...\n";
258 system "rsync -a README NEWS OLDNEWS TODO $dest";
259 unlink("$dest/rsync-$version-NEWS");
260 link("$dest/NEWS", "$dest/rsync-$version-NEWS");
261 system "git-log --name-status | gzip -9 >$dest/changelog.gz";
263 system "yodl2html -o $dest/rsync.html rsync.yo";
264 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
266 chdir($dest) or die $!;
267 system "gpg -ba $srctar_name; gpg -ba $pattar_name; gpg -ba $diff_name";
270 All done. Remember to announce the release on *BOTH*
271 rsync-announce\@lists.samba.org and rsync\@lists.samba.org!