| 1 | #!/usr/bin/perl |
| 2 | use strict; |
| 3 | |
| 4 | # This script expects the directory ~/samba-rsync-ftp to exist and to |
| 5 | # be a copy of the /home/ftp/pub/rsync dir on samba.org. If it is run |
| 6 | # in test mode, it instead expects a dir named ~/tmp/samba-rsync-ftp |
| 7 | # (e.g. copy ~/samba-rsync-ftp into ~/tmp and you can do a trial-run of |
| 8 | # a release without affecting the files in the ~/samba-rsync-ftp dir). |
| 9 | # |
| 10 | # Run this as "release-rsync live" to affect ~/samba-rsync-ftp instead |
| 11 | # of ~/tmp/samba-rsync-ftp. |
| 12 | |
| 13 | use Date::Format; |
| 14 | |
| 15 | my $dest = $ENV{HOME} . '/samba-rsync-ftp'; |
| 16 | my $releasedir = $ENV{HOME} . '/release'; |
| 17 | my $cvsroot = $ENV{CVSROOT} = 'samba.org:/data/cvs'; |
| 18 | |
| 19 | my $ztoday = time2str('%d %b %Y', time); |
| 20 | my $today = $ztoday; |
| 21 | $today =~ s/^0//; |
| 22 | |
| 23 | my $dots = <<EOT; |
| 24 | ......................................................................... |
| 25 | EOT |
| 26 | my $note = <<EOT; |
| 27 | |
| 28 | ** |
| 29 | ** Note: type "-a u,n" if you want to auto-accept the U,N suggestions. ** |
| 30 | ** |
| 31 | EOT |
| 32 | |
| 33 | my $live = shift; |
| 34 | my $skipping = ''; |
| 35 | |
| 36 | if ($live) { |
| 37 | print "This will release a new version of rsync onto an unsuspecting world.\n"; |
| 38 | } else { |
| 39 | print "**** TESTMODE **** (add \"live\" arg to avoid this)\n"; |
| 40 | $dest =~ s#([^/]+$)#tmp/$1#; |
| 41 | $skipping = ' ** SKIPPING **'; |
| 42 | } |
| 43 | die "$dest does not exist\n" unless -d $dest; |
| 44 | |
| 45 | print "Checking out the latest rsync into $releasedir...\n"; |
| 46 | |
| 47 | mkdir($releasedir, 0755) or die $! unless -d $releasedir; |
| 48 | chdir($releasedir) or die $!; |
| 49 | |
| 50 | system "rm -rf rsync rsync-*"; |
| 51 | |
| 52 | system "cvs checkout -P rsync"; |
| 53 | |
| 54 | chdir('rsync') or die $!; |
| 55 | |
| 56 | my($version, $lastversion); |
| 57 | open(IN, 'configure.in') or die $!; |
| 58 | while (<IN>) { |
| 59 | if (/^RSYNC_VERSION=(.*)/) { |
| 60 | $version = $lastversion = $1; |
| 61 | last; |
| 62 | } |
| 63 | } |
| 64 | close IN; |
| 65 | |
| 66 | $lastversion =~ s/(\d+)cvs$/ $1 - 1 /e; |
| 67 | $version =~ s/cvs/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e; |
| 68 | |
| 69 | print "\nPlease enter the version number of this release: [$version] "; |
| 70 | chomp($_ = <STDIN>); |
| 71 | if ($_ eq '.') { |
| 72 | $version =~ s/pre\d+//; |
| 73 | } elsif ($_ ne '') { |
| 74 | $version = $_; |
| 75 | } |
| 76 | $version =~ s/[-.]*pre[-.]*/pre/; |
| 77 | |
| 78 | $lastversion =~ s/(\d+)pre\d+$/ $1 - 1 /e unless $version =~ /pre/; |
| 79 | |
| 80 | my $cvstag = "release-$version"; |
| 81 | $cvstag =~ s/[.]/-/g; |
| 82 | $cvstag =~ s/pre/-pre/; |
| 83 | |
| 84 | print "Enter the previous version to produce a patch against: [$lastversion] "; |
| 85 | chomp($_ = <STDIN>); |
| 86 | $lastversion = $_ if $_ ne ''; |
| 87 | $lastversion =~ s/[-.]*pre[-.]*/pre/; |
| 88 | |
| 89 | my $release = 1; |
| 90 | print "Please enter the RPM release number of this release: [$release] "; |
| 91 | chomp($_ = <STDIN>); |
| 92 | $release = $_ if $_ ne ''; |
| 93 | |
| 94 | my $diffdir; |
| 95 | if ($lastversion =~ /pre/) { |
| 96 | if ($version !~ /pre/) { |
| 97 | die "You should not diff a release version against a pre-release version.\n"; |
| 98 | } |
| 99 | $diffdir = "$dest/old-previews"; |
| 100 | } elsif ($version =~ /pre/) { |
| 101 | $diffdir = $dest; |
| 102 | } else { |
| 103 | $diffdir = "$dest/old-versions"; |
| 104 | } |
| 105 | |
| 106 | my $tarfile = "$dest/rsync-$version.tar.gz"; |
| 107 | |
| 108 | print <<EOT; |
| 109 | |
| 110 | \$version is "$version" |
| 111 | \$lastversion is "$lastversion" |
| 112 | \$cvstag is "$cvstag" |
| 113 | \$dest is "$dest" |
| 114 | \$releasedir is "$releasedir" |
| 115 | \$diffdir is "$diffdir" |
| 116 | \$release is "$release" |
| 117 | |
| 118 | About to: |
| 119 | - tweak NEWS and OLDNEWS to update the release date |
| 120 | - tweak the version in configure.in, configure, and the spec files |
| 121 | - tweak the date in the *.yo files and re-generate the man pages |
| 122 | - make sure that the patches dir has been updated |
| 123 | - page through the "cvs diff" output |
| 124 | |
| 125 | EOT |
| 126 | print "<Press Enter to continue> "; |
| 127 | $_ = <STDIN>; |
| 128 | |
| 129 | print $dots; |
| 130 | |
| 131 | system "./prepare-source && touch proto.h"; |
| 132 | |
| 133 | my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), |
| 134 | glob('*.yo'), qw( configure.in configure ) ); |
| 135 | if ($version !~ /pre/) { |
| 136 | push(@tweak_files, qw( NEWS OLDNEWS )); |
| 137 | } |
| 138 | foreach my $fn (@tweak_files) { |
| 139 | open(IN, '<', $fn) or die $!; |
| 140 | undef $/; $_ = <IN>; $/ = "\n"; |
| 141 | close IN; |
| 142 | if ($fn =~ /configure/) { |
| 143 | s/^RSYNC_VERSION.*/RSYNC_VERSION=$version/m; |
| 144 | } elsif ($fn =~ /\.spec/) { |
| 145 | s/^(Version:) .*/$1 $version/m; |
| 146 | s/^(Release:) .*/$1 $release/m; |
| 147 | } elsif ($fn =~ /\.yo/) { |
| 148 | s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m; |
| 149 | s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m; |
| 150 | } else { |
| 151 | s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*$/$1 ($today)\n/m; |
| 152 | s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m; |
| 153 | } |
| 154 | open(OUT, '>', $fn) or die $!; |
| 155 | print OUT $_; |
| 156 | close OUT; |
| 157 | } |
| 158 | |
| 159 | system "yodl2man -o rsync.1 rsync.yo"; |
| 160 | system "yodl2man -o rsyncd.conf.5 rsyncd.conf.yo"; |
| 161 | #system "perl -pi -e \"s/\\\\\\'/\\\\&'/g\" rsync.1 rsyncd.conf.5"; |
| 162 | |
| 163 | mkdir('patches/tmp') or die $!; |
| 164 | system "rsync -a --exclude=patches/ --exclude-from=.cvsignore . patches/tmp/cvsdir/"; |
| 165 | |
| 166 | print $dots, $note; |
| 167 | |
| 168 | system "patches/verify-patches -un -an"; |
| 169 | |
| 170 | system "cvs -q diff | egrep -v '^(===============|RCS file: |retrieving revision |Index: )' | less -p '^diff .*'"; |
| 171 | |
| 172 | print <<EOT; |
| 173 | |
| 174 | About to: |
| 175 | - "cvs commit" all changes$skipping |
| 176 | - "cvs tag" this release as $cvstag$skipping |
| 177 | |
| 178 | EOT |
| 179 | if ($live) { |
| 180 | print "<Press Enter to continue> "; |
| 181 | $_ = <STDIN>; |
| 182 | |
| 183 | system "cvs commit -m 'Preparing for release of $version'"; |
| 184 | system "cvs tag -F $cvstag ."; |
| 185 | } else { |
| 186 | print "** Skipping prompt in TESTMODE **\n"; |
| 187 | } |
| 188 | |
| 189 | print <<EOT; |
| 190 | |
| 191 | About to do the following in the samba-rsync-ftp dir: |
| 192 | - change the diffs in the patches dir to include generated files |
| 193 | - move the old tar/diff files into the appropriate old-* dirs |
| 194 | - hard-link the new tar/diff files to the old files on samba.org$skipping |
| 195 | - create release tar "$tarfile" |
| 196 | - create release diffs |
| 197 | - update README, *NEWS, TODO, and cvs.log |
| 198 | - update rsync*.html man pages |
| 199 | |
| 200 | EOT |
| 201 | print "<Press Enter to continue> "; |
| 202 | $_ = <STDIN>; |
| 203 | |
| 204 | print $note; |
| 205 | |
| 206 | system "patches/verify-patches -pun -an"; |
| 207 | |
| 208 | chdir($releasedir) or die $!; |
| 209 | |
| 210 | print $dots; |
| 211 | |
| 212 | mkdir("rsync-$version", 0755) or die $!; |
| 213 | system "rsync -aC --exclude=.cvsignore rsync/ rsync-$version"; |
| 214 | |
| 215 | # When creating a pre-release after a normal release, there's nothing to move. |
| 216 | if ($diffdir ne $dest) { |
| 217 | chdir($dest) or die $!; |
| 218 | |
| 219 | # We need to run this regardless of $lastversion's "pre"ness. |
| 220 | my @moved_files; |
| 221 | foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) { |
| 222 | link($fn, "old-previews/$fn") or die $!; |
| 223 | push(@moved_files, $fn); |
| 224 | } |
| 225 | |
| 226 | if ($version !~ /pre/) { |
| 227 | foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) { |
| 228 | next if $fn =~ /^rsync.*pre/; |
| 229 | link($fn, "old-versions/$fn") or die $!; |
| 230 | push(@moved_files, $fn); |
| 231 | } |
| 232 | |
| 233 | foreach my $fn (glob('rsync*.diffs.gz*')) { |
| 234 | next if $fn =~ /^rsync.*pre/; |
| 235 | link($fn, "old-patches/$fn") or die $!; |
| 236 | push(@moved_files, $fn); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | # Optimize our future upload (in the absence of --detect-renamed) by |
| 241 | # uploading the above hard-linked files that we are about to delete. |
| 242 | if ($live) { |
| 243 | system "rsync -avHC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync"; |
| 244 | } |
| 245 | foreach (@moved_files, glob("rsync*pre*.diffs.gz*")) { |
| 246 | unlink($_); |
| 247 | } |
| 248 | |
| 249 | chdir($releasedir) or die $!; |
| 250 | } |
| 251 | system "fakeroot tar czf $tarfile rsync-$version"; |
| 252 | |
| 253 | system "tar xzf $diffdir/rsync-$lastversion.tar.gz"; |
| 254 | ## TWEAK THE VERSIONS AS DESIRED HERE ## |
| 255 | #mkdir("rsync-$lastversion/support", 0755) or die $!; |
| 256 | #rename("rsync-$lastversion/rsyncstats", "rsync-$lastversion/support/rsyncstats"); |
| 257 | ## END ## |
| 258 | system "diff -urN --exclude=patches rsync-$lastversion rsync-$version" |
| 259 | . "| gzip -9 >$dest/rsync-$lastversion-$version.diffs.gz"; |
| 260 | |
| 261 | system "rsync -a rsync/{README,NEWS,OLDNEWS,TODO} $dest"; |
| 262 | unlink("$dest/rsync-$version-NEWS"); |
| 263 | link("$dest/NEWS", "$dest/rsync-$version-NEWS"); |
| 264 | system "rsync -a $cvsroot/CVSROOT/rsync.updates $dest/cvs.log"; |
| 265 | |
| 266 | system "yodl2html -o $dest/rsync.html rsync/rsync.yo"; |
| 267 | system "yodl2html -o $dest/rsyncd.conf.html rsync/rsyncd.conf.yo"; |
| 268 | |
| 269 | system "rm -rf rsync rsync-*"; |
| 270 | |
| 271 | if ($live) { |
| 272 | chdir($dest) or die $!; |
| 273 | system "gpg -ba rsync-$version.tar.gz"; |
| 274 | system "gpg -ba rsync-$lastversion-$version.diffs.gz"; |
| 275 | } |
| 276 | |
| 277 | print <<EOT; |
| 278 | |
| 279 | All done. Remember to announce the release on *BOTH* |
| 280 | rsync-announce\@lists.samba.org and rsync\@lists.samba.org! |
| 281 | EOT |