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