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.
14 my $dest = $ENV{HOME} . '/samba-rsync-ftp';
15 my $passfile = $ENV{HOME} . '/.rsyncpass';
16 my $path = $ENV{PATH};
18 &Getopt::Long::Configure('bundling');
19 &usage if !&GetOptions(
20 'branch|b=s' => \( my $master_branch = 'master' ),
21 'help|h' => \( my $help_opt ),
26 my $cl_today = time2str('* %a %b %d %Y', $now);
27 my $year = time2str('%Y', $now);
28 my $ztoday = time2str('%d %b %Y', $now);
29 (my $today = $ztoday) =~ s/^0//;
31 my $curdir = Cwd::cwd;
38 open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
44 @extra_files = split(' ', $_);
51 ==========================================================================
54 print $break, <<EOT, $break, "\n";
55 == This will release a new version of rsync onto an unsuspecting world. ==
58 die "$dest does not exist\n" unless -d $dest;
59 die "There is no .git dir in the current directory.\n" unless -d '.git';
60 die "'a' must not exist in the current directory.\n" if -e 'a';
61 die "'b' must not exist in the current directory.\n" if -e 'b';
63 open(IN, '-|', 'git status') or die $!;
64 my $status = join('', <IN>);
66 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
67 my($cur_branch) = $status =~ /^# On branch (.+)\n/;
68 if ($cur_branch ne $master_branch) {
69 print "The checkout is not on the $master_branch branch.\n";
70 exit 1 if $master_branch ne 'master';
71 print "Do you want to release branch $cur_branch? [n] ";
74 $master_branch = $cur_branch;
78 open(IN, '<', 'configure.in') or die $!;
80 if (/^RSYNC_VERSION=(.*)/) {
86 die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
88 open(IN, '<', 'OLDNEWS') or die $!;
90 my($lastversion) = /(\d+\.\d+\.\d+)/;
91 my($last_protocol_version, %pdate);
93 if (my($ver,$pdate,$pver) = /^\s+\S\S\s\S\S\S\s\d\d\d\d\s+(\d+\.\d+\.\d+)\s+(\d\d \w\w\w \d\d\d\d\s+)?(\d+)$/) {
94 $pdate{$ver} = $pdate if defined $pdate;
95 $last_protocol_version = $pver if $ver eq $lastversion;
99 die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
101 my $protocol_version;
102 open(IN, '<', 'rsync.h') or die $!;
104 if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
105 $protocol_version = $1;
110 die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;
112 my $version = $confversion;
113 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
115 print "Please enter the version number of this release: [$version] ";
118 $version =~ s/pre\d+//;
122 die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
124 if (`git tag -l v$version` ne '') {
125 print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
127 exit 1 unless /^del/i;
128 system "git tag -d v$version";
131 if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
132 $lastversion = $confversion;
135 print "Enter the previous version to produce a patch against: [$lastversion] ";
137 $lastversion = $_ if $_ ne '';
138 $lastversion =~ s/[-.]*pre[-.]*/pre/;
140 my $pre = $version =~ /(pre\d+)/ ? $1 : '';
142 my $release = $pre ? '0.1' : '1';
143 print "Please enter the RPM release number of this release: [$release] ";
145 $release = $_ if $_ ne '';
146 $release .= ".$pre" if $pre;
148 (my $finalversion = $version) =~ s/pre\d+//;
149 my($proto_changed,$proto_change_date);
150 if ($protocol_version eq $last_protocol_version) {
151 $proto_changed = 'unchanged';
152 $proto_change_date = "\t\t";
154 $proto_changed = 'changed';
155 if (!defined($proto_change_date = $pdate{$finalversion})) {
157 print "On what date did the protocol change to $protocol_version get checked in? (dd Mmm yyyy) ";
159 last if /^\d\d \w\w\w \d\d\d\d$/;
161 $proto_change_date = "$_\t";
165 my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
166 if ($lastversion =~ /pre/) {
168 die "You should not diff a release version against a pre-release version.\n";
170 $srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
171 $skipping = ' ** SKIPPING **';
173 $srcdir = $srcdiffdir = 'src-previews';
175 $skipping = ' ** SKIPPING **';
177 $srcdir = $lastsrcdir = 'src';
178 $srcdiffdir = 'src-diffs';
182 print "\n", $break, <<EOT;
183 \$version is "$version"
184 \$lastversion is "$lastversion"
186 \$curdir is "$curdir"
187 \$srcdir is "$srcdir"
188 \$srcdiffdir is "$srcdiffdir"
189 \$lastsrcdir is "$lastsrcdir"
190 \$release is "$release"
193 - tweak SUBPROTOCOL_VERSION in rsync.h, if needed
194 - tweak the version in configure.in and the spec files
195 - tweak NEWS and OLDNEWS to ensure header values are correct
196 - tweak the date in the *.yo files and generate the manpages
197 - generate configure.sh, config.h.in, and proto.h
198 - page through the differences
201 print "<Press Enter to continue> ";
204 my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
205 '%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
206 '%define srcdir' => $srcdir );
207 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
208 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
210 foreach my $fn (@tweak_files) {
211 open(IN, '<', $fn) or die $!;
212 undef $/; $_ = <IN>; $/ = "\n";
214 if ($fn =~ /configure/) {
215 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
216 or die "Unable to update RSYNC_VERSION in $fn\n";
217 } elsif ($fn =~ /\.spec/) {
218 while (my($str, $val) = each %specvars) {
219 s/^\Q$str\E .*/$str $val/m
220 or die "Unable to update $str in $fn\n";
222 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
223 or die "Unable to update ChangeLog header in $fn\n";
224 } elsif ($fn =~ /\.yo/) {
225 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
226 or die "Unable to update date in manpage() header in $fn\n";
227 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
228 or die "Unable to update current version info in $fn\n";
229 } elsif ($fn eq 'rsync.h') {
230 s{(#define\s+SUBPROTOCOL_VERSION)\s+(\d+)}
231 { $1 . ' ' . get_subprotocol_version($2) }e
232 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
233 } elsif ($fn eq 'NEWS') {
234 s{^(NEWS for rsync \Q$finalversion\E )(\(UNRELEASED\))\s*(\nProtocol: )(\d+) (\([^)]+\))\n}
235 { $1 . ($pre ? $2 : "($today)") . "$3$protocol_version ($proto_changed)\n" }ei
236 or die "The first 2 lines of $fn are not in the right format. They must be:\n"
237 . "NEWS for rsync $finalversion (UNRELEASED)\n"
238 . "Protocol: $protocol_version ($proto_changed)\n";
239 } elsif ($fn eq 'OLDNEWS') {
240 s{^(\t\S\S\s\S\S\S\s\d\d\d\d)(\t\Q$finalversion\E\t).*}
241 { ($pre ? $1 : "\t$ztoday") . $2 . $proto_change_date . $protocol_version }em
242 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
243 } elsif ($fn eq 'options.c') {
244 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
246 die "Copyright comments need to be updated to $year in all files!\n";
248 # Adjust the year in the --version output.
249 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
250 or die "Unable to find Copyright string in --version output of $fn\n";
253 die "Unrecognized file in \@tweak_files: $fn\n";
255 open(OUT, '>', $fn) or die $!;
261 system "git diff --color | less -p '^diff .*'";
263 my $srctar_name = "rsync-$version.tar.gz";
264 my $pattar_name = "rsync-patches-$version.tar.gz";
265 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
266 my $srctar_file = "$dest/$srcdir/$srctar_name";
267 my $pattar_file = "$dest/$srcdir/$pattar_name";
268 my $diff_file = "$dest/$srcdiffdir/$diff_name";
269 my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
270 my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
275 - commit all version changes
276 - merge the $master_branch branch into the patch/* branches
277 - update the files in the "patches" dir and OPTIONALLY
278 (if you type 'y') to launch a shell for each patch
281 print "<Press Enter OR 'y' to continue> ";
284 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
286 print "Updating files in \"patches\" dir ...\n";
287 system "packaging/patch-update --branch=$master_branch";
290 print "\nVisiting all \"patch/*\" branches ...\n";
291 system "packaging/patch-update --branch=$master_branch --shell";
297 - create signed tag for this release: v$version
298 - create release diffs, "$diff_name"
299 - create release tar, "$srctar_name"
300 - generate rsync-$version/patches/* files
301 - create patches tar, "$pattar_name"
302 - update top-level README, *NEWS, TODO, and ChangeLog
303 - update top-level rsync*.html manpages
304 - gpg-sign the release files
305 - update hard-linked top-level release files$skipping
308 print "<Press Enter to continue> ";
314 print "\nEnter your GPG pass-phrase: ";
315 chomp($passphrase = <STDIN>);
319 # Briefly create a temp file with the passphrase for git's tagging use.
320 my $oldmask = umask 077;
322 open(OUT, '>', $passfile) or die $!;
323 print OUT $passphrase, "\n";
326 $ENV{'GPG_PASSFILE'} = $passfile;
328 # We want to use our passphrase-providing "gpg" script, so modify the PATH.
329 $ENV{PATH} = "packaging/bin:$path";
330 $_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
334 next if /bad passphrase/;
335 last unless /failed/;
339 # Extract the generated files from the old tar.
341 map { s#^#rsync-$lastversion/# } @_;
342 system "tar xzf $lasttar_file @_";
343 rename("rsync-$lastversion", 'a');
345 print "Creating $diff_file ...\n";
346 system "./config.status Makefile; make gen; rsync -a @extra_files b/";
347 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
348 system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
350 rename('b', "rsync-$version");
352 print "Creating $srctar_file ...\n";
353 system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
354 system "support/git-set-file-times --prefix=rsync-$version/";
355 system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
357 print "Updating files in \"rsync-$version/patches\" dir ...\n";
358 mkdir("rsync-$version", 0755);
359 mkdir("rsync-$version/patches", 0755);
360 system "packaging/patch-update --skip-check --branch=$master_branch --gen=rsync-$version/patches";
362 print "Creating $pattar_file ...\n";
363 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
365 print "Updating the other files in $dest ...\n";
366 system "rsync -a README NEWS OLDNEWS TODO $dest";
368 link("$dest/NEWS", $news_file);
369 system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
371 system "yodl2html -o $dest/rsync.html rsync.yo";
372 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
374 foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
376 open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
377 print GPG $passphrase, "\n";
382 system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
384 foreach my $fn ($srctar_file, "$srctar_file.asc",
385 $pattar_file, "$pattar_file.asc",
386 $diff_file, "$diff_file.asc", $news_file) {
387 (my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
392 print $break, <<'EOT';
394 Local changes are done. When you're satisfied, push the git repository
395 and rsync the release files. Remember to announce the release on *BOTH*
396 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
401 sub get_subprotocol_version
404 if ($pre && $proto_changed eq 'changed') {
405 return $subver == 0 ? 1 : $subver;
413 Usage: release-rsync [OPTIONS]
415 -b, --branch=BRANCH The branch to release (default: master)
416 -h, --help Display this help message