Commit | Line | Data |
---|---|---|
6d12a859 WD |
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 | ||
5fa38cd6 WD |
23 | my $break = <<EOT; |
24 | ========================================================================== | |
6d12a859 WD |
25 | EOT |
26 | my $note = <<EOT; | |
5fa38cd6 | 27 | == Note: type "-a u,n" if you want to auto-accept the U,N suggestions. == |
6d12a859 WD |
28 | EOT |
29 | ||
30 | my $live = shift; | |
4d8639eb | 31 | my $skipping = ''; |
6d12a859 | 32 | |
5fa38cd6 | 33 | print $break; |
6d12a859 | 34 | if ($live) { |
5fa38cd6 WD |
35 | print <<EOT; |
36 | == This will release a new version of rsync onto an unsuspecting world. == | |
37 | EOT | |
6d12a859 | 38 | } else { |
5fa38cd6 WD |
39 | print <<EOT; |
40 | == **** TESTMODE **** (Add "live" arg to avoid this.) == | |
41 | EOT | |
6d12a859 | 42 | $dest =~ s#([^/]+$)#tmp/$1#; |
4d8639eb | 43 | $skipping = ' ** SKIPPING **'; |
6d12a859 WD |
44 | } |
45 | die "$dest does not exist\n" unless -d $dest; | |
46 | ||
5fa38cd6 | 47 | print $break, "\nChecking out the latest rsync into $releasedir ...\n"; |
519c8de1 WD |
48 | |
49 | mkdir($releasedir, 0755) or die $! unless -d $releasedir; | |
50 | chdir($releasedir) or die $!; | |
51 | ||
5fa38cd6 WD |
52 | system 'rm -rf rsync'; |
53 | ||
54 | my(%dirs, @files); | |
55 | open(CVS, '-|', 'cvs checkout -P rsync') or die $!; | |
56 | while (<CVS>) { | |
57 | print $_; | |
58 | next if /\.(cvs)?ignore$/; | |
59 | if (m#^[UP] rsync/(.*)#) { | |
60 | my $fn = $1; | |
61 | my($dir) = $fn =~ m#^(.+)/#; | |
62 | push(@files, $dir) if defined($dir) && !$dirs{$1}++; | |
63 | push(@files, $fn); | |
64 | } | |
65 | } | |
519c8de1 WD |
66 | |
67 | chdir('rsync') or die $!; | |
68 | ||
69 | my($version, $lastversion); | |
70 | open(IN, 'configure.in') or die $!; | |
71 | while (<IN>) { | |
72 | if (/^RSYNC_VERSION=(.*)/) { | |
73 | $version = $lastversion = $1; | |
74 | last; | |
75 | } | |
76 | } | |
77 | close IN; | |
78 | ||
79 | $lastversion =~ s/(\d+)cvs$/ $1 - 1 /e; | |
80 | $version =~ s/cvs/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e; | |
81 | ||
5fa38cd6 | 82 | print $break, "\nPlease enter the version number of this release: [$version] "; |
519c8de1 WD |
83 | chomp($_ = <STDIN>); |
84 | if ($_ eq '.') { | |
85 | $version =~ s/pre\d+//; | |
86 | } elsif ($_ ne '') { | |
87 | $version = $_; | |
88 | } | |
6d12a859 WD |
89 | $version =~ s/[-.]*pre[-.]*/pre/; |
90 | ||
519c8de1 WD |
91 | $lastversion =~ s/(\d+)pre\d+$/ $1 - 1 /e unless $version =~ /pre/; |
92 | ||
6d12a859 WD |
93 | my $cvstag = "release-$version"; |
94 | $cvstag =~ s/[.]/-/g; | |
95 | $cvstag =~ s/pre/-pre/; | |
96 | ||
519c8de1 WD |
97 | print "Enter the previous version to produce a patch against: [$lastversion] "; |
98 | chomp($_ = <STDIN>); | |
99 | $lastversion = $_ if $_ ne ''; | |
6d12a859 WD |
100 | $lastversion =~ s/[-.]*pre[-.]*/pre/; |
101 | ||
519c8de1 WD |
102 | my $release = 1; |
103 | print "Please enter the RPM release number of this release: [$release] "; | |
104 | chomp($_ = <STDIN>); | |
105 | $release = $_ if $_ ne ''; | |
6d12a859 WD |
106 | |
107 | my $diffdir; | |
5fa38cd6 | 108 | my $skipping2; |
6d12a859 WD |
109 | if ($lastversion =~ /pre/) { |
110 | if ($version !~ /pre/) { | |
111 | die "You should not diff a release version against a pre-release version.\n"; | |
112 | } | |
113 | $diffdir = "$dest/old-previews"; | |
5fa38cd6 | 114 | $skipping2 = ' ** SKIPPING **'; |
6d12a859 WD |
115 | } elsif ($version =~ /pre/) { |
116 | $diffdir = $dest; | |
5fa38cd6 | 117 | $skipping2 = ' ** SKIPPING **'; |
6d12a859 WD |
118 | } else { |
119 | $diffdir = "$dest/old-versions"; | |
5fa38cd6 | 120 | $skipping2 = ''; |
6d12a859 WD |
121 | } |
122 | ||
5fa38cd6 | 123 | print "\n", $break, <<EOT; |
6d12a859 WD |
124 | \$version is "$version" |
125 | \$lastversion is "$lastversion" | |
126 | \$cvstag is "$cvstag" | |
127 | \$dest is "$dest" | |
128 | \$releasedir is "$releasedir" | |
129 | \$diffdir is "$diffdir" | |
130 | \$release is "$release" | |
131 | ||
132 | About to: | |
5fa38cd6 | 133 | - make sure that configure, config.h.in, and proto.h are updated |
6d12a859 | 134 | - tweak the version in configure.in, configure, and the spec files |
5fa38cd6 | 135 | - tweak NEWS and OLDNEWS to update the release date$skipping2 |
6d12a859 WD |
136 | - tweak the date in the *.yo files and re-generate the man pages |
137 | - make sure that the patches dir has been updated | |
138 | - page through the "cvs diff" output | |
139 | ||
140 | EOT | |
141 | print "<Press Enter to continue> "; | |
142 | $_ = <STDIN>; | |
c2b2bd6a | 143 | my $f_opt = /f/ ? ' -f' : ''; |
6d12a859 | 144 | |
5fa38cd6 | 145 | print $break; |
6d12a859 WD |
146 | system "./prepare-source && touch proto.h"; |
147 | ||
148 | my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), | |
149 | glob('*.yo'), qw( configure.in configure ) ); | |
150 | if ($version !~ /pre/) { | |
151 | push(@tweak_files, qw( NEWS OLDNEWS )); | |
152 | } | |
153 | foreach my $fn (@tweak_files) { | |
154 | open(IN, '<', $fn) or die $!; | |
155 | undef $/; $_ = <IN>; $/ = "\n"; | |
156 | close IN; | |
157 | if ($fn =~ /configure/) { | |
200f2d98 | 158 | s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m; |
6d12a859 WD |
159 | } elsif ($fn =~ /\.spec/) { |
160 | s/^(Version:) .*/$1 $version/m; | |
161 | s/^(Release:) .*/$1 $release/m; | |
162 | } elsif ($fn =~ /\.yo/) { | |
163 | s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m; | |
164 | s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m; | |
178a1d20 WD |
165 | } elsif ($fn eq 'NEWS') { |
166 | s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi | |
167 | or die "Couldn't update NEWS file with release date!\n"; | |
168 | } elsif ($fn eq 'OLDNEWS') { | |
169 | s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m | |
170 | or die "Couldn't update OLDNEWS file with release date!\n"; | |
6d12a859 | 171 | } else { |
178a1d20 | 172 | die "Unrecognized file in \@tweak_files: $fn\n"; |
6d12a859 WD |
173 | } |
174 | open(OUT, '>', $fn) or die $!; | |
175 | print OUT $_; | |
176 | close OUT; | |
177 | } | |
178 | ||
d9126a86 WD |
179 | system "yodl2man -o rsync.1 rsync.yo; ./tweak_manpage_dashes rsync.1"; |
180 | system "yodl2man -o rsyncd.conf.5 rsyncd.conf.yo; ./tweak_manpage_dashes rsyncd.conf.5"; | |
6d12a859 WD |
181 | |
182 | mkdir('patches/tmp') or die $!; | |
183 | system "rsync -a --exclude=patches/ --exclude-from=.cvsignore . patches/tmp/cvsdir/"; | |
184 | ||
5fa38cd6 | 185 | print "\n", $break, $note, $break; |
c2b2bd6a | 186 | system "patches/verify-patches -n -an$f_opt"; |
6d12a859 | 187 | |
5fa38cd6 | 188 | print $break; |
6d12a859 WD |
189 | system "cvs -q diff | egrep -v '^(===============|RCS file: |retrieving revision |Index: )' | less -p '^diff .*'"; |
190 | ||
5fa38cd6 | 191 | print $break, <<EOT; |
6d12a859 WD |
192 | |
193 | About to: | |
4d8639eb WD |
194 | - "cvs commit" all changes$skipping |
195 | - "cvs tag" this release as $cvstag$skipping | |
5fa38cd6 | 196 | - change the diffs in the patches dir to include generated files |
6d12a859 WD |
197 | |
198 | EOT | |
5fa38cd6 WD |
199 | print "<Press Enter to continue> "; |
200 | $_ = <STDIN>; | |
6d12a859 | 201 | |
5fa38cd6 | 202 | if ($live) { |
6d12a859 WD |
203 | system "cvs commit -m 'Preparing for release of $version'"; |
204 | system "cvs tag -F $cvstag ."; | |
6d12a859 WD |
205 | } |
206 | ||
5fa38cd6 WD |
207 | if (!/skip/i) { |
208 | print "\n", $break, $note, $break; | |
209 | system "patches/verify-patches -pun -an"; | |
210 | } | |
211 | ||
e60bba3f WD |
212 | my $tar_name = "rsync-$version.tar.gz"; |
213 | my $diff_name = "rsync-$lastversion-$version.diffs.gz"; | |
214 | my $tar_file = "$dest/$tar_name"; | |
215 | my $diff_file = "$dest/$diff_name"; | |
5fa38cd6 WD |
216 | |
217 | print $break, <<EOT; | |
6d12a859 WD |
218 | |
219 | About to do the following in the samba-rsync-ftp dir: | |
4d8639eb | 220 | - move the old tar/diff files into the appropriate old-* dirs |
5f12a07b | 221 | - hard-link the moved tar/diff files on samba.org$skipping |
e60bba3f WD |
222 | - create release tar, "$tar_name" |
223 | - create release diffs, "$diff_name" | |
6d12a859 WD |
224 | - update README, *NEWS, TODO, and cvs.log |
225 | - update rsync*.html man pages | |
e60bba3f | 226 | - gpg-sign the release files$skipping |
6d12a859 WD |
227 | |
228 | EOT | |
229 | print "<Press Enter to continue> "; | |
230 | $_ = <STDIN>; | |
231 | ||
6d12a859 WD |
232 | chdir($releasedir) or die $!; |
233 | ||
5fa38cd6 WD |
234 | print $break; |
235 | system "rm -rf rsync-$version"; | |
236 | rename('rsync', "rsync-$version") or die $!; | |
6d12a859 WD |
237 | |
238 | # When creating a pre-release after a normal release, there's nothing to move. | |
239 | if ($diffdir ne $dest) { | |
240 | chdir($dest) or die $!; | |
241 | ||
5fa38cd6 WD |
242 | print "Shuffling old files ...\n"; |
243 | ||
519c8de1 WD |
244 | # We need to run this regardless of $lastversion's "pre"ness. |
245 | my @moved_files; | |
6d12a859 | 246 | foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) { |
5f12a07b WD |
247 | link($fn, "old-previews/$fn") or die $!; |
248 | push(@moved_files, $fn); | |
6d12a859 | 249 | } |
6d12a859 WD |
250 | |
251 | if ($version !~ /pre/) { | |
252 | foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) { | |
4d8639eb | 253 | next if $fn =~ /^rsync.*pre/; |
5f12a07b WD |
254 | link($fn, "old-versions/$fn") or die $!; |
255 | push(@moved_files, $fn); | |
6d12a859 WD |
256 | } |
257 | ||
178a1d20 WD |
258 | foreach my $fn (glob('rsync*pre*.diffs.gz*')) { |
259 | unlink($fn); | |
260 | } | |
261 | ||
6d12a859 | 262 | foreach my $fn (glob('rsync*.diffs.gz*')) { |
5f12a07b WD |
263 | link($fn, "old-patches/$fn") or die $!; |
264 | push(@moved_files, $fn); | |
6d12a859 WD |
265 | } |
266 | } | |
267 | ||
519c8de1 | 268 | # Optimize our future upload (in the absence of --detect-renamed) by |
5f12a07b | 269 | # using rsync to hard-link the above files on samba.org. |
519c8de1 | 270 | if ($live) { |
5f12a07b | 271 | system "rsync -avHOC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync"; |
519c8de1 | 272 | } |
178a1d20 | 273 | foreach (@moved_files) { |
519c8de1 WD |
274 | unlink($_); |
275 | } | |
276 | ||
6d12a859 WD |
277 | chdir($releasedir) or die $!; |
278 | } | |
6d12a859 | 279 | |
5fa38cd6 WD |
280 | print "Creating $tar_file ...\n"; |
281 | system "fakeroot tar czf $tar_file rsync-$version"; | |
651dc65e | 282 | open(TAR, '|-', "fakeroot tar --files-from=- --no-recursion --mode=g+w -czf $tar_file rsync-$version") or die $!; |
5fa38cd6 WD |
283 | foreach (@files) { |
284 | print TAR "rsync-$version/$_\n"; | |
285 | } | |
286 | close TAR; | |
287 | ||
288 | print "Creating $diff_file ...\n"; | |
289 | system "rm -rf rsync-$version rsync-$lastversion"; | |
290 | system "tar xzf $tar_file; tar xzf $diffdir/rsync-$lastversion.tar.gz"; | |
6d12a859 WD |
291 | ## TWEAK THE VERSIONS AS DESIRED HERE ## |
292 | #mkdir("rsync-$lastversion/support", 0755) or die $!; | |
293 | #rename("rsync-$lastversion/rsyncstats", "rsync-$lastversion/support/rsyncstats"); | |
a00f5a37 | 294 | #unlink("rsync-$lastversion/.ignore"); |
6d12a859 | 295 | ## END ## |
5fa38cd6 | 296 | system "diff -urN --exclude=patches rsync-$lastversion rsync-$version| gzip -9 >$diff_file"; |
6d12a859 | 297 | |
5fa38cd6 WD |
298 | print "Updating the other files in $dest ...\n"; |
299 | system "rsync -a rsync-$version/{README,NEWS,OLDNEWS,TODO} $dest"; | |
6d12a859 WD |
300 | unlink("$dest/rsync-$version-NEWS"); |
301 | link("$dest/NEWS", "$dest/rsync-$version-NEWS"); | |
302 | system "rsync -a $cvsroot/CVSROOT/rsync.updates $dest/cvs.log"; | |
303 | ||
5fa38cd6 WD |
304 | system "yodl2html -o $dest/rsync.html rsync-$version/rsync.yo"; |
305 | system "yodl2html -o $dest/rsyncd.conf.html rsync-$version/rsyncd.conf.yo"; | |
6d12a859 | 306 | |
5fa38cd6 | 307 | system "rm -rf rsync-*"; |
6d12a859 WD |
308 | |
309 | if ($live) { | |
310 | chdir($dest) or die $!; | |
e60bba3f | 311 | system "gpg -ba $tar_name; gpg -ba $diff_name"; |
de343840 | 312 | print $break, <<EOT; |
6d12a859 WD |
313 | |
314 | All done. Remember to announce the release on *BOTH* | |
315 | rsync-announce\@lists.samba.org and rsync\@lists.samba.org! | |
316 | EOT | |
de343840 WD |
317 | } else { |
318 | print $break, "All done.\n"; | |
319 | } |