3 # Make a fetchmail release.
4 # Dumps a release notice and diffs as a MIME multipart message
8 my $project = "fetchmail";
9 my $website = "http://developer.berlios.de/projects/$project";
10 my $mailfrom = "<$project-devel\@lists.berlios.de> (Fetchmail Development Team)";
11 my $distsufx = '.tar.bz2';
12 my $xzsufx = '.tar.xz';
14 # ---------------------------------------------------------------------
16 use POSIX qw(strftime);
21 (-r "NEWS" and -r "fetchmail.c" and -r "configure.ac") or die "Please cd to the top-level source directory!";
22 die "Need GNU sort!" unless `sort --version | head -n1` =~ /GNU/;
23 system("lftp --version >/dev/null 2>&1") and die "lftp not found!";
29 my $null = ">/dev/null";
30 my $errnull = "2>/dev/null";
35 print STDERR "Usage: $_[0] [--verbose,-v] [--help,-h,-?]\n";
39 sub makerelnotes($$) {
40 my ($infile, $outfile) = @_;
41 open(F, "<$infile") or die "cannot read $infile: $!";
42 open(G, ">$outfile") or die "cannot write to $outfile: $!";
45 $ctr++ if /^fetchmail-/;
48 close F or die "cannot read $infile: $!";
49 close G or die "cannot write to $outfile: $!";
52 GetOptions("diffs|d" => \$diffs, "verbose|v" => \$verbose, "help|h|?" => \$help)
55 usage($0, 0) if $help;
57 die "$0 does not yet work with --diffs - needs to be updated for Git first!" if $diffs;
63 my $tmp = $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp";
65 # extract version from source
66 my $version =`grep 'AC_INIT' configure.ac`;
67 $version =~ /AC_INIT\([^,]*,\[?([0-9.rc-]+)\]?\,.*\)/;
69 die "cannot determine version" unless defined $1;
70 my $tag = "RELEASE_$version";
73 # extract existing tags
75 open(ID, "git tag | sort -t- -k1,1 -k2,2n -k3,3n |") || die "cannot run git tag: $!\naborting";
78 if (m{^(RELEASE_.*)$}) {
79 unshift(@versions, $1);
82 close ID || die "git tag failed, aborting";
84 my $oldtag; my $oldver;
85 if ($versions[0] eq $tag) {
87 $oldtag = $versions[1];
90 $oldtag = $versions[0];
93 my $pwd = `pwd`; chomp $pwd;
95 $ENV{PATH} .= ":$pwd/dist-tools:$pwd/dist-tools/shipper";
97 print "Building $version release, tag $tag, previous tag $oldtag\n";
99 if (-d "autom4te.cache") {
100 system("rm -rf autom4te.cache")
101 and die "Failure in removing autom4te.cache";
104 printf "### autoreconf\n";
106 if (system("autoreconf -ifs" . ($verbose ? 'v' : ''))) {
107 die("Failure in regenerating autoconf files\n");
110 print "### configure\n";
112 if (system("mkdir -p autobuild && cd autobuild "
113 . " && ../configure -C --silent --with-ssl")) { die("Configuration failure\n"); }
115 print "### Test-building the software...\n";
116 if (system("cd autobuild && make -s clean"
117 . " && make " . ($verbose ? '' : '-s') . " check distcheck")) {
118 die("Compilation failure\n");
121 open(REPORT, ">$tmp/$project.PREAMBLE.$$");
125 Subject: The $version release of $project is available
127 The $version release of $project is now available at the usual locations,
128 including <$website>.
130 The source archive is available at:
131 <$website/$project-$version$distsufx>
133 Here are the release notes:
137 # Extract the current notes
154 $oldver =~ s/^RELEASE_//;
157 print REPORT "Diffs from the previous ($oldver) release follow as a MIME attachment."
159 print REPORT "By popular demand, diffs from the previous release have been omitted."
167 if ($tag eq '<workfile>') {
168 system("svn diff -r$oldtag $errnull >$tmp/$project.DIFFS.$$");
170 system("svn diff -r$oldtag -r$tag $errnull >$tmp/$project.DIFFS.$$");
173 system("wc <$tmp/$project.DIFFS.$$");
176 ." -D '$project-$tag announcement' -m 'text/plain' -e 7bit -f $tmp/$project.PREAMBLE.$$"
177 ." -n -D 'diff between $oldver and $version' -m 'text/plain' -e 7bit -f $tmp/$project.DIFFS.$$"
178 ." -o ANNOUNCE.EMAIL";
180 system("mv", "$tmp/$project.PREAMBLE.$$", "ANNOUNCE.EMAIL");
183 #unlink("$tmp/$project.PREAMBLE.$$");
184 unlink("$tmp/$project.DIFFS.$$");
186 print "### Signing tarballs...\n";
187 system("cd autobuild && gpg -ba --sign $project-$version$distsufx");
188 system("cd autobuild && gpg -ba --sign $project-$version$xzsufx");
190 print "### Extracting release notes...\n";
191 makerelnotes('NEWS', 'autobuild/README');
193 print "### Uploading\n";
196 system("cp", "autobuild/$project-$version$xzsufx", "autobuild/$project-$version$xzsufx.asc", "$ENV{HOME}/public_html/fetchmail/") and die "Cannot upload to \$HOME/public_html/fetchmail/: $!";
198 print "=== berlios\n";
200 system("lftp -e \"lcd autobuild ; mput $project-$version$distsufx $project-$version$distsufx.asc ; quit\" ftp.berlios.de:/incoming/") and warn "Upload to berlios failed: $!";
202 print "=== sourceforge \n";
203 system("rsync -acvHP autobuild/$project-$version$xzsufx autobuild/$project-$version$xzsufx.asc autobuild/README m-a\@frs.sourceforge.net:/home/frs/project/fetchmail/branch_6.3/");
204 unlink 'autobuild/README' or die "cannot unlink autobuild/README: $!";
206 print "=== Done - please review final tasks\n";
208 system("cat RELEASE-INSTRUCTIONS");
210 # makerelease ends here