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