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 die "The checkout is not on the $master_branch branch.\n" unless $status =~ /^# On branch $master_branch\n/;
70 open(IN, '<', 'configure.in') or die $!;
72 if (/^RSYNC_VERSION=(.*)/) {
78 die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
80 open(IN, '<', 'OLDNEWS') or die $!;
83 my($lastversion) = /(\d+\.\d+\.\d+)/;
85 my $version = $confversion;
86 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
88 print "Please enter the version number of this release: [$version] ";
91 $version =~ s/pre\d+//;
95 die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
97 if (`git tag -l v$version` ne '') {
98 print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
100 exit 1 unless /^del/i;
101 system "git tag -d v$version";
104 if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
105 $lastversion = $confversion;
108 print "Enter the previous version to produce a patch against: [$lastversion] ";
110 $lastversion = $_ if $_ ne '';
111 $lastversion =~ s/[-.]*pre[-.]*/pre/;
113 my $pre = $version =~ /(pre\d+)/ ? $1 : '';
115 my $release = $pre ? '0.1' : '1';
116 print "Please enter the RPM release number of this release: [$release] ";
118 $release = $_ if $_ ne '';
119 $release .= ".$pre" if $pre;
121 my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
122 if ($lastversion =~ /pre/) {
124 die "You should not diff a release version against a pre-release version.\n";
126 $srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
127 $skipping = ' ** SKIPPING **';
129 $srcdir = $srcdiffdir = 'src-previews';
131 $skipping = ' ** SKIPPING **';
133 $srcdir = $lastsrcdir = 'src';
134 $srcdiffdir = 'src-diffs';
138 print "\n", $break, <<EOT;
139 \$version is "$version"
140 \$lastversion is "$lastversion"
142 \$curdir is "$curdir"
143 \$srcdir is "$srcdir"
144 \$srcdiffdir is "$srcdiffdir"
145 \$lastsrcdir is "$lastsrcdir"
146 \$release is "$release"
149 - make sure that SUBPROTOCOL_VERSION is 0$skipping
150 - tweak the version in configure.in and the spec files
151 - tweak NEWS and OLDNEWS to update the release date$skipping
152 - tweak the date in the *.yo files and generate the manpages
153 - generate configure.sh, config.h.in, and proto.h
154 - page through the differences
157 print "<Press Enter to continue> ";
160 (my $finalversion = $version) =~ s/pre\d+//;
161 my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
162 '%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
163 '%define srcdir' => $srcdir );
164 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
165 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
167 foreach my $fn (@tweak_files) {
168 open(IN, '<', $fn) or die $!;
169 undef $/; $_ = <IN>; $/ = "\n";
171 if ($fn =~ /configure/) {
172 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
173 or die "Unable to update RSYNC_VERSION in $fn\n";
174 } elsif ($fn =~ /\.spec/) {
175 while (my($str, $val) = each %specvars) {
176 s/^\Q$str\E .*/$str $val/m
177 or die "Unable to update $str in $fn\n";
179 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
180 or die "Unable to update ChangeLog header in $fn\n";
181 } elsif ($fn =~ /\.yo/) {
182 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
183 or die "Unable to update date in manpage() header in $fn\n";
184 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
185 or die "Unable to update current version info in $fn\n";
186 } elsif ($fn eq 'rsync.h') {
187 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
188 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
190 } elsif ($fn eq 'NEWS') {
191 s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
192 or die "The first line of $fn is not in the right format. It must be:\n"
193 . "NEWS for rsync $finalversion (UNRELEASED)\n";
195 } elsif ($fn eq 'OLDNEWS') {
196 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
197 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
199 } elsif ($fn eq 'options.c') {
200 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
202 die "Copyright comments need to be updated to $year in all files!\n";
204 # Adjust the year in the --version output.
205 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
206 or die "Unable to find Copyright string in --version output of $fn\n";
209 die "Unrecognized file in \@tweak_files: $fn\n";
211 open(OUT, '>', $fn) or die $!;
217 system "git diff --color | less -p '^diff .*'";
219 my $srctar_name = "rsync-$version.tar.gz";
220 my $pattar_name = "rsync-patches-$version.tar.gz";
221 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
222 my $srctar_file = "$dest/$srcdir/$srctar_name";
223 my $pattar_file = "$dest/$srcdir/$pattar_name";
224 my $diff_file = "$dest/$srcdiffdir/$diff_name";
225 my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
226 my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
231 - commit all version changes
232 - merge the $master_branch branch into the patch/* branches
233 - update the files in the "patches" dir and OPTIONALLY
234 (if you type 'y') to launch a shell for each patch
237 print "<Press Enter OR 'y' to continue> ";
240 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
242 print "Updating files in \"patches\" dir ...\n";
243 system "packaging/patch-update";
246 print "\nVisiting all \"patch/*\" branches ...\n";
247 system "packaging/patch-update --shell";
253 - create signed tag for this release: v$version
254 - create release diffs, "$diff_name"
255 - create release tar, "$srctar_name"
256 - generate rsync-$version/patches/* files
257 - create patches tar, "$pattar_name"
258 - update top-level README, *NEWS, TODO, and ChangeLog
259 - update top-level rsync*.html manpages
260 - gpg-sign the release files
261 - update hard-linked top-level release files$skipping
264 print "<Press Enter to continue> ";
270 print "\nEnter your GPG pass-phrase: ";
271 chomp($passphrase = <STDIN>);
275 # Briefly create a temp file with the passphrase for git's tagging use.
276 my $oldmask = umask 077;
278 open(OUT, '>', $passfile) or die $!;
279 print OUT $passphrase, "\n";
282 $ENV{'GPG_PASSFILE'} = $passfile;
284 # We want to use our passphrase-providing "gpg" script, so modify the PATH.
285 $ENV{PATH} = "packaging/bin:$path";
286 $_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
290 next if /bad passphrase/;
291 last unless /failed/;
295 # Extract the generated files from the old tar.
297 map { s#^#rsync-$lastversion/# } @_;
298 system "tar xzf $lasttar_file @_";
299 rename("rsync-$lastversion", 'a');
301 print "Creating $diff_file ...\n";
302 system "./config.status Makefile; make gen; rsync -a @extra_files b/";
303 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
304 system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
306 rename('b', "rsync-$version");
308 print "Creating $srctar_file ...\n";
309 system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
310 system "support/git-set-file-times --prefix=rsync-$version/";
311 system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
313 print "Updating files in \"rsync-$version/patches\" dir ...\n";
314 mkdir("rsync-$version", 0755);
315 mkdir("rsync-$version/patches", 0755);
316 system "packaging/patch-update --skip-check --gen=rsync-$version/patches";
318 print "Creating $pattar_file ...\n";
319 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
321 print "Updating the other files in $dest ...\n";
322 system "rsync -a README NEWS OLDNEWS TODO $dest";
324 link("$dest/NEWS", $news_file);
325 system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
327 system "yodl2html -o $dest/rsync.html rsync.yo";
328 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
330 foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
332 open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
333 print GPG $passphrase, "\n";
338 system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
340 foreach my $fn ($srctar_file, "$srctar_file.asc",
341 $pattar_file, "$pattar_file.asc",
342 $diff_file, "$diff_file.asc", $news_file) {
343 (my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
348 print $break, <<'EOT';
350 Local changes are done. When you're satisfied, push the git repository
351 and rsync the release files. Remember to announce the release on *BOTH*
352 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
360 Usage: release-rsync [OPTIONS]
362 -b, --branch=BRANCH The branch to release (default: master)
363 -h, --help Display this help message