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.
13 my $dest = $ENV{HOME} . '/samba-rsync-ftp';
14 my $passfile = $ENV{HOME} . '/.rsyncpass';
15 my $path = $ENV{PATH};
18 my $cl_today = time2str('* %a %b %d %Y', $now);
19 my $year = time2str('%Y', $now);
20 my $ztoday = time2str('%d %b %Y', $now);
21 (my $today = $ztoday) =~ s/^0//;
23 my $curdir = Cwd::cwd;
30 open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
36 @extra_files = split(' ', $_);
43 ==========================================================================
46 print $break, <<EOT, $break, "\n";
47 == This will release a new version of rsync onto an unsuspecting world. ==
50 die "$dest does not exist\n" unless -d $dest;
51 die "There is no .git dir in the current directory.\n" unless -d '.git';
52 die "'a' must not exist in the current directory.\n" if -e 'a';
53 die "'b' must not exist in the current directory.\n" if -e 'b';
55 open(IN, '-|', 'git status') or die $!;
56 my $status = join('', <IN>);
58 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
59 die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
62 open(IN, '<', 'configure.in') or die $!;
64 if (/^RSYNC_VERSION=(.*)/) {
70 die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
72 open(IN, '<', 'OLDNEWS') or die $!;
75 my($lastversion) = /(\d+\.\d+\.\d+)/;
77 my $version = $confversion;
78 $version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
80 print "Please enter the version number of this release: [$version] ";
83 $version =~ s/pre\d+//;
87 die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
89 if (`git tag -l v$version` ne '') {
90 print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
92 exit 1 unless /^del/i;
93 system "git tag -d v$version";
96 if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
97 $lastversion = $confversion;
100 print "Enter the previous version to produce a patch against: [$lastversion] ";
102 $lastversion = $_ if $_ ne '';
103 $lastversion =~ s/[-.]*pre[-.]*/pre/;
105 my $pre = $version =~ /(pre\d+)/ ? $1 : '';
107 my $release = $pre ? '0.1' : '1';
108 print "Please enter the RPM release number of this release: [$release] ";
110 $release = $_ if $_ ne '';
111 $release .= ".$pre" if $pre;
113 my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
114 if ($lastversion =~ /pre/) {
116 die "You should not diff a release version against a pre-release version.\n";
118 $srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
119 $skipping = ' ** SKIPPING **';
121 $srcdir = $srcdiffdir = 'src-previews';
123 $skipping = ' ** SKIPPING **';
125 $srcdir = $lastsrcdir = 'src';
126 $srcdiffdir = 'src-diffs';
130 print "\n", $break, <<EOT;
131 \$version is "$version"
132 \$lastversion is "$lastversion"
134 \$curdir is "$curdir"
135 \$srcdir is "$srcdir"
136 \$srcdiffdir is "$srcdiffdir"
137 \$lastsrcdir is "$lastsrcdir"
138 \$release is "$release"
141 - make sure that SUBPROTOCOL_VERSION is 0$skipping
142 - tweak the version in configure.in and the spec files
143 - tweak NEWS and OLDNEWS to update the release date$skipping
144 - tweak the date in the *.yo files and generate the manpages
145 - generate configure.sh, config.h.in, and proto.h
146 - page through the differences
149 print "<Press Enter to continue> ";
152 (my $finalversion = $version) =~ s/pre\d+//;
153 my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
154 '%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
155 '%define srcdir' => $srcdir );
156 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
157 qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
159 foreach my $fn (@tweak_files) {
160 open(IN, '<', $fn) or die $!;
161 undef $/; $_ = <IN>; $/ = "\n";
163 if ($fn =~ /configure/) {
164 s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
165 or die "Unable to update RSYNC_VERSION in $fn\n";
166 } elsif ($fn =~ /\.spec/) {
167 while (my($str, $val) = each %specvars) {
168 s/^\Q$str\E .*/$str $val/m
169 or die "Unable to update $str in $fn\n";
171 s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
172 or die "Unable to update ChangeLog header in $fn\n";
173 } elsif ($fn =~ /\.yo/) {
174 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
175 or die "Unable to update date in manpage() header in $fn\n";
176 s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
177 or die "Unable to update current version info in $fn\n";
178 } elsif ($fn eq 'rsync.h') {
179 s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
180 or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
182 } elsif ($fn eq 'NEWS') {
183 s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
184 or die "The first line of $fn is not in the right format. It must be:\n"
185 . "NEWS for rsync $finalversion (UNRELEASED)\n";
187 } elsif ($fn eq 'OLDNEWS') {
188 s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
189 or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
191 } elsif ($fn eq 'options.c') {
192 if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
194 die "Copyright comments need to be updated to $year in all files!\n";
196 # Adjust the year in the --version output.
197 s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
198 or die "Unable to find Copyright string in --version output of $fn\n";
201 die "Unrecognized file in \@tweak_files: $fn\n";
203 open(OUT, '>', $fn) or die $!;
209 system "git diff --color | less -p '^diff .*'";
211 my $srctar_name = "rsync-$version.tar.gz";
212 my $pattar_name = "rsync-patches-$version.tar.gz";
213 my $diff_name = "rsync-$lastversion-$version.diffs.gz";
214 my $srctar_file = "$dest/$srcdir/$srctar_name";
215 my $pattar_file = "$dest/$srcdir/$pattar_name";
216 my $diff_file = "$dest/$srcdiffdir/$diff_name";
217 my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
218 my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
223 - commit all version changes
224 - merge the master branch into the patch/* branches
225 - update the files in the "patches" dir and OPTIONALLY
226 (if you type 'y') to launch a shell for each patch
229 print "<Press Enter OR 'y' to continue> ";
232 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
234 print "Updating files in \"patches\" dir ...\n";
235 system "support/patch-update";
238 print "\nVisiting all \"patch/*\" branches ...\n";
239 system "support/patch-update --shell";
245 - create signed tag for this release: v$version
246 - create release diffs, "$diff_name"
247 - create release tar, "$srctar_name"
248 - generate rsync-$version/patches/* files
249 - create patches tar, "$pattar_name"
250 - update top-level README, *NEWS, TODO, and ChangeLog
251 - update top-level rsync*.html manpages
252 - gpg-sign the release files
253 - update hard-linked top-level release files$skipping
256 print "<Press Enter to continue> ";
262 print "\nEnter your GPG pass-phrase: ";
263 chomp($passphrase = <STDIN>);
267 # Briefly create a temp file with the passphrase for git's tagging use.
268 my $oldmask = umask 077;
270 open(OUT, '>', $passfile) or die $!;
271 print OUT $passphrase, "\n";
274 $ENV{'GPG_PASSFILE'} = $passfile;
276 # We want to use our passphrase-providing "gpg" script, so modify the PATH.
277 $ENV{PATH} = "packaging/bin:$path";
278 $_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
282 next if /bad passphrase/;
283 last unless /failed/;
287 # Extract the generated files from the old tar.
289 map { s#^#rsync-$lastversion/# } @_;
290 system "tar xzf $lasttar_file @_";
291 rename("rsync-$lastversion", 'a');
293 print "Creating $diff_file ...\n";
294 system "./config.status Makefile; make gen; rsync -a @extra_files b/";
295 my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
296 system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
298 rename('b', "rsync-$version");
300 print "Creating $srctar_file ...\n";
301 system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
302 system "support/git-set-file-times --prefix=rsync-$version/";
303 system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
305 print "Updating files in \"rsync-$version/patches\" dir ...\n";
306 mkdir("rsync-$version", 0755);
307 mkdir("rsync-$version/patches", 0755);
308 system "support/patch-update --skip-check --gen=rsync-$version/patches";
310 print "Creating $pattar_file ...\n";
311 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
313 print "Updating the other files in $dest ...\n";
314 system "rsync -a README NEWS OLDNEWS TODO $dest";
316 link("$dest/NEWS", $news_file);
317 system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
319 system "yodl2html -o $dest/rsync.html rsync.yo";
320 system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
322 foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
324 open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
325 print GPG $passphrase, "\n";
330 system "rm $dest/rsync-*{.tar.gz,.asc,-NEWS} $dest/src-preview/rsync-*diffs.gz";
332 foreach my $fn ($srctar_file, "$srctar_file.asc",
333 $pattar_file, "$pattar_file.asc",
334 $diff_file, "$diff_file.asc", $news_file) {
335 (my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
340 print $break, <<'EOT';
342 Local changes are done. When you're satisfied, push the git repository
343 and rsync the release files. Remember to announce the release on *BOTH*
344 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!