5 # This script expects the directory ~/samba-rsync-ftp to exist and to be a
6 # copy of the /home/ftp/pub/rsync dir on samba.org. When the script is done,
7 # the git repository in the current directory will be updated, and the local
8 # ~/samba-rsync-ftp dir will be ready to be rsynced to samba.org.
15 my $dest = $ENV{HOME} . '/samba-rsync-ftp';
16 my $passfile = $ENV{HOME} . '/.rsyncpass';
17 my $path = $ENV{PATH};
18 my $make_gen_cmd = 'make -f prepare-source.mak conf && ./config.status && make gen';
20 &Getopt::Long::Configure('bundling');
21 &usage if !&GetOptions(
22 'branch|b=s' => \( my $master_branch = 'master' ),
23 'help|h' => \( my $help_opt ),
28 my $cl_today = time2str('* %a %b %d %Y', $now);
29 my $year = time2str('%Y', $now);
30 my $ztoday = time2str('%d %b %Y', $now);
31 (my $today = $ztoday) =~ s/^0//;
33 my $curdir = Cwd::cwd;
40 open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
46 @extra_files = split(' ', $_);
53 ==========================================================================
56 print $break, <<EOT, $break, "\n";
57 == This will release a new version of rsync onto an unsuspecting world. ==
60 die "$dest does not exist\n" unless -d $dest;
61 die "There is no .git dir in the current directory.\n" unless -d '.git';
62 die "'a' must not exist in the current directory.\n" if -e 'a';
63 die "'b' must not exist in the current directory.\n" if -e 'b';
65 open(IN, '-|', 'git status') or die $!;
66 my $status = join('', <IN>);
68 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
69 my($cur_branch) = $status =~ /^# On branch (.+)\n/;
70 if ($cur_branch ne $master_branch) {
71 print "The checkout is not on the $master_branch branch.\n";
72 exit 1 if $master_branch ne 'master';
73 print "Do you want to release branch $cur_branch? [n] ";
76 $master_branch = $cur_branch;
80 open(IN, '<', 'configure.in') or die $!;
82 if (/^RSYNC_VERSION=(.*)/) {
88 die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
90 open(IN, '<', 'OLDNEWS') or die $!;
92 my($lastversion) = /(\d+\.\d+\.\d+)/;
93 my($last_protocol_version, %pdate);
95 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+)$/) {
96 $pdate{$ver} = $pdate if defined $pdate;
97 $last_protocol_version = $pver if $ver eq $lastversion;
101 die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
103 my $protocol_version;
104 open(IN, '<', 'rsync.h') or die $!;
106 if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
107 $protocol_version = $1;
112 die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;
114 my $version = $confversion;
115 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
117 print "Please enter the version number of this release: [$version] ";
120 $version =~ s/pre\d+//;
124 die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
126 if (`git tag -l v$version` ne '') {
127 print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
129 exit 1 unless /^del/i;
130 system "git tag -d v$version";
133 if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
134 $lastversion = $confversion;
137 print "Enter the previous version to produce a patch against: [$lastversion] ";
139 $lastversion = $_ if $_ ne '';
140 $lastversion =~ s/[-.]*pre[-.]*/pre/;
142 my $pre = $version =~ /(pre\d+)/ ? $1 : '';
144 my $release = $pre ? '0.1' : '1';
145 print "Please enter the RPM release number of this release: [$release] ";
147 $release = $_ if $_ ne '';
148 $release .= ".$pre" if $pre;
150 (my $finalversion = $version) =~ s/pre\d+//;
151 my($proto_changed,$proto_change_date);
152 if ($protocol_version eq $last_protocol_version) {
153 $proto_changed = 'unchanged';
154 $proto_change_date = "\t\t";
156 $proto_changed = 'changed';
157 if (!defined($proto_change_date = $pdate{$finalversion})) {
159 print "On what date did the protocol change to $protocol_version get checked in? (dd Mmm yyyy) ";
161 last if /^\d\d \w\w\w \d\d\d\d$/;
163 $proto_change_date = "$_\t";
167 my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
168 if ($lastversion =~ /pre/) {
170 die "You should not diff a release version against a pre-release version.\n";
172 $srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
173 $skipping = ' ** SKIPPING **';
175 $srcdir = $srcdiffdir = 'src-previews';
177 $skipping = ' ** SKIPPING **';
179 $srcdir = $lastsrcdir = 'src';
180 $srcdiffdir = 'src-diffs';
184 print "\n", $break, <<EOT;
185 \$version is "$version"
186 \$lastversion is "$lastversion"
188 \$curdir is "$curdir"
189 \$srcdir is "$srcdir"
190 \$srcdiffdir is "$srcdiffdir"
191 \$lastsrcdir is "$lastsrcdir"
192 \$release is "$release"
195 - tweak SUBPROTOCOL_VERSION in rsync.h, if needed
196 - tweak the version in configure.in and the spec files
197 - tweak NEWS and OLDNEWS to ensure header values are correct
198 - tweak the date in the *.yo files and generate the manpages
199 - generate configure.sh, config.h.in, and proto.h
200 - page through the differences
203 print "<Press Enter to continue> ";
206 my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
207 '%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
208 '%define srcdir' => $srcdir );
209 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
210 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
212 foreach my $fn (@tweak_files) {
213 open(IN, '<', $fn) or die $!;
214 undef $/; $_ = <IN>; $/ = "\n";
216 if ($fn =~ /configure/) {
217 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
218 or die "Unable to update RSYNC_VERSION in $fn\n";
219 } elsif ($fn =~ /\.spec/) {
220 while (my($str, $val) = each %specvars) {
221 s/^\Q$str\E .*/$str $val/m
222 or die "Unable to update $str in $fn\n";
224 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
225 or die "Unable to update ChangeLog header in $fn\n";
226 } elsif ($fn =~ /\.yo/) {
227 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
228 or die "Unable to update date in manpage() header in $fn\n";
229 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
230 or die "Unable to update current version info in $fn\n";
231 } elsif ($fn eq 'rsync.h') {
232 s{(#define\s+SUBPROTOCOL_VERSION)\s+(\d+)}
233 { $1 . ' ' . get_subprotocol_version($2) }e
234 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
235 } elsif ($fn eq 'NEWS') {
236 s{^(NEWS for rsync \Q$finalversion\E )(\(UNRELEASED\))\s*(\nProtocol: )(\d+) (\([^)]+\))\n}
237 { $1 . ($pre ? $2 : "($today)") . "$3$protocol_version ($proto_changed)\n" }ei
238 or die "The first 2 lines of $fn are not in the right format. They must be:\n"
239 . "NEWS for rsync $finalversion (UNRELEASED)\n"
240 . "Protocol: $protocol_version ($proto_changed)\n";
241 } elsif ($fn eq 'OLDNEWS') {
242 s{^(\t\S\S\s\S\S\S\s\d\d\d\d)(\t\Q$finalversion\E\t).*}
243 { ($pre ? $1 : "\t$ztoday") . $2 . $proto_change_date . $protocol_version }em
244 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
245 } elsif ($fn eq 'options.c') {
246 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
248 die "Copyright comments need to be updated to $year in all files!\n";
250 # Adjust the year in the --version output.
251 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
252 or die "Unable to find Copyright string in --version output of $fn\n";
255 die "Unrecognized file in \@tweak_files: $fn\n";
257 open(OUT, '>', $fn) or die $!;
263 system "git diff --color | less -p '^diff .*'";
265 my $srctar_name = "rsync-$version.tar.gz";
266 my $pattar_name = "rsync-patches-$version.tar.gz";
267 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
268 my $srctar_file = "$dest/$srcdir/$srctar_name";
269 my $pattar_file = "$dest/$srcdir/$pattar_name";
270 my $diff_file = "$dest/$srcdiffdir/$diff_name";
271 my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
272 my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
277 - commit all version changes
278 - merge the $master_branch branch into the patch/* branches
279 - update the files in the "patches" dir and OPTIONALLY
280 (if you type 'y') to launch a shell for each patch
283 print "<Press Enter OR 'y' to continue> ";
286 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
288 print "Updating files in \"patches\" dir ...\n";
289 system "packaging/patch-update --branch=$master_branch";
292 print "\nVisiting all \"patch/*\" branches ...\n";
293 system "packaging/patch-update --branch=$master_branch --shell";
299 - create signed tag for this release: v$version
300 - create release diffs, "$diff_name"
301 - create release tar, "$srctar_name"
302 - generate rsync-$version/patches/* files
303 - create patches tar, "$pattar_name"
304 - update top-level README, *NEWS, TODO, and ChangeLog
305 - update top-level rsync*.html manpages
306 - gpg-sign the release files
307 - update hard-linked top-level release files$skipping
310 print "<Press Enter to continue> ";
316 print "\nEnter your GPG pass-phrase: ";
317 chomp($passphrase = <STDIN>);
321 # Briefly create a temp file with the passphrase for git's tagging use.
322 my $oldmask = umask 077;
324 open(OUT, '>', $passfile) or die $!;
325 print OUT $passphrase, "\n";
328 $ENV{'GPG_PASSFILE'} = $passfile;
330 # We want to use our passphrase-providing "gpg" script, so modify the PATH.
331 $ENV{PATH} = "packaging/bin:$path";
332 $_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
336 next if /bad passphrase/;
337 last unless /failed/;
341 # Extract the generated files from the old tar.
343 map { s#^#rsync-$lastversion/# } @_;
344 system "tar xzf $lasttar_file @_";
345 rename("rsync-$lastversion", 'a');
347 print "Creating $diff_file ...\n";
348 system "$make_gen_cmd && rsync -a @extra_files b/" and exit 1;
349 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
350 system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
352 rename('b', "rsync-$version");
354 print "Creating $srctar_file ...\n";
355 system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
356 system "support/git-set-file-times --prefix=rsync-$version/";
357 system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
359 print "Updating files in \"rsync-$version/patches\" dir ...\n";
360 mkdir("rsync-$version", 0755);
361 mkdir("rsync-$version/patches", 0755);
362 system "packaging/patch-update --skip-check --branch=$master_branch --gen=rsync-$version/patches";
364 print "Creating $pattar_file ...\n";
365 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
367 print "Updating the other files in $dest ...\n";
368 system "rsync -a README NEWS OLDNEWS TODO $dest";
370 link("$dest/NEWS", $news_file);
371 system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
373 system "yodl2html -o $dest/rsync.html rsync.yo";
374 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
376 foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
378 open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
379 print GPG $passphrase, "\n";
384 system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
386 foreach my $fn ($srctar_file, "$srctar_file.asc",
387 $pattar_file, "$pattar_file.asc",
388 $diff_file, "$diff_file.asc", $news_file) {
389 (my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
394 print $break, <<'EOT';
396 Local changes are done. When you're satisfied, push the git repository
397 and rsync the release files. Remember to announce the release on *BOTH*
398 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
403 sub get_subprotocol_version
406 if ($pre && $proto_changed eq 'changed') {
407 return $subver == 0 ? 1 : $subver;
415 Usage: release-rsync [OPTIONS]
417 -b, --branch=BRANCH The branch to release (default: master)
418 -h, --help Display this help message