]> Pileus Git - ~andy/fetchmail/blob - dist-tools/makerelease.pl
Get ready for 6.3.22 release.
[~andy/fetchmail] / dist-tools / makerelease.pl
1 #!/usr/bin/perl -w
2 #
3 # Make a fetchmail release.
4 # Dumps a release notice and diffs as a MIME multipart message 
5 # in RELEASE_NOTES
6 #
7
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
13 # ---------------------------------------------------------------------
14
15 use POSIX qw(strftime);
16 use Getopt::Long;
17 use strict vars;
18
19 # check environment
20 (-r "NEWS" and -r "fetchmail.c" and -r "configure.ac") or die "Please cd to the top-level source directory!";
21 die "Need GNU sort!" unless `sort --version | head -n1` =~ /GNU/;
22 system("lftp --version >/dev/null 2>&1") and die "lftp not found!";
23
24 # parse options
25 my $diffs = 0;
26 my $verbose = 0;
27 my $help = 0;
28 my $null = ">/dev/null";
29 my $errnull = "2>/dev/null";
30
31 sub usage($$) {
32     my ($own, $rc) = @_;
33
34     print STDERR "Usage: $_[0] [--verbose,-v] [--help,-h,-?]\n";
35     exit($_[1]);
36 }
37
38 GetOptions("diffs|d" => \$diffs, "verbose|v" => \$verbose, "help|h|?" => \$help)
39     or usage($0, 1);
40
41 usage($0, 0) if $help;
42
43 die "$0 does not yet work with --diffs - needs to be updated for Git first!" if $diffs;
44
45 if ($verbose) {
46     $null = "";
47 }
48
49 my $tmp = $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp";
50
51 # extract version from source
52 my $version =`grep 'AC_INIT' configure.ac`;
53 $version =~ /AC_INIT\([^,]*,\[?([0-9.rc-]+)\]?\,.*\)/;
54 $version = $1;
55 die "cannot determine version" unless defined $1;
56 my $tag = "RELEASE_$version";
57 $tag =~ tr/./-/;
58
59 # extract existing tags
60 my @versions;
61 open(ID, "git tag | sort -t- -k1,1 -k2,2n -k3,3n |") || die "cannot run git tag: $!\naborting";
62 while (<ID>) {
63         chomp;
64         if (m{^(RELEASE_.*)$}) {
65                 unshift(@versions, $1);
66         }
67 }
68 close ID || die "git tag   failed, aborting";
69
70 my $oldtag; my $oldver;
71 if ($versions[0] eq $tag) {
72         $tag = $versions[0];
73         $oldtag = $versions[1];
74 } else {
75         $tag = '<workfile>';
76         $oldtag = $versions[0];
77 }
78
79 my $pwd = `pwd`; chomp $pwd;
80
81 $ENV{PATH} .= ":$pwd/dist-tools:$pwd/dist-tools/shipper";
82
83 print "Building $version release, tag $tag, previous tag $oldtag\n";
84
85 if (-d "autom4te.cache") {
86         system("rm -rf autom4te.cache")
87                 and die "Failure in removing autom4te.cache";
88 }
89
90 printf "### autoreconf\n";
91
92 if (system("autoreconf -ifs" . ($verbose ? 'v' : ''))) {
93         die("Failure in regenerating autoconf files\n");
94 }
95
96 print "### configure\n";
97
98 if (system("mkdir -p autobuild && cd autobuild " 
99         . " && ../configure -C --silent --with-ssl")) { die("Configuration failure\n"); }
100
101 print "### Test-building the software...\n";
102 if (system("cd autobuild && make -s clean"
103         . " && make " . ($verbose ? '' : '-s') . " check distcheck lsm")) {
104         die("Compilation failure\n");
105 }
106
107 open(REPORT, ">$tmp/$project.PREAMBLE.$$");
108
109 print REPORT <<EOF;
110 From: $mailfrom
111 Subject: The $version release of $project is available
112
113 The $version release of $project is now available at the usual locations,
114 including <$website>.
115
116 The source archive is available at:
117 <$website/$project-$version$distsufx>
118
119 Here are the release notes:
120
121 EOF
122
123 # Extract the current notes
124 open(NEWS, "NEWS");
125 while (<NEWS>) {
126         if (/^$project/) {
127                 print REPORT $_;
128                 last;
129         }
130 }
131 while (<NEWS>) {
132         if (/^$project/) {
133                 last;
134         }
135         print REPORT $_;
136 }
137
138 $oldver = $oldtag;
139 $oldver =~ tr/-/./;
140 $oldver =~ s/^RELEASE_//;
141
142 if ($diffs) {
143         print REPORT "Diffs from the previous ($oldver) release follow as a MIME attachment."
144 } else {
145         print REPORT "By popular demand, diffs from the previous release have been omitted."
146 }
147
148 close(NEWS);
149
150 close(REPORT);
151
152 if ($diffs) {
153         if ($tag eq '<workfile>') {
154                 system("svn diff -r$oldtag        $errnull >$tmp/$project.DIFFS.$$");
155         } else {
156                 system("svn diff -r$oldtag -r$tag $errnull >$tmp/$project.DIFFS.$$");
157         }
158         print "Diff size:";
159         system("wc <$tmp/$project.DIFFS.$$");
160
161         system "metasend -b"
162         ." -D '$project-$tag announcement' -m 'text/plain' -e 7bit -f $tmp/$project.PREAMBLE.$$"
163         ." -n -D 'diff between $oldver and $version' -m 'text/plain' -e 7bit -f $tmp/$project.DIFFS.$$"
164         ." -o ANNOUNCE.EMAIL";
165 } else {
166         system("mv", "$tmp/$project.PREAMBLE.$$", "ANNOUNCE.EMAIL");
167 }
168
169 #unlink("$tmp/$project.PREAMBLE.$$");
170 unlink("$tmp/$project.DIFFS.$$");
171
172 print "### Signing tarballs...\n";
173 system("cd autobuild && gpg -ba --sign $project-$version$distsufx");
174
175 print "### Uploading\n";
176 print "=== local\n";
177
178 system("cp", "autobuild/$project-$version$distsufx", "autobuild/$project-$version$distsufx.asc", "$ENV{HOME}/public_html/fetchmail/") and die "Cannot upload to \$HOME/public_html/fetchmail/: $!";
179
180 print "=== ibiblio\n";
181
182 system("lftp -e \"lcd autobuild ; mput $project-$version$distsufx $project-$version$distsufx.asc $project-$version.lsm ; quit\" ibiblio.org:/incoming/linux/") and warn "Upload to ibiblio failed: $!";
183
184 print "=== berlios\n";
185
186 system("lftp -e \"lcd autobuild ; mput $project-$version$distsufx $project-$version$distsufx.asc ; quit\" ftp.berlios.de:/incoming/") and warn "Upload to berlios failed: $!";
187
188 print "Done - please review final tasks\n";
189
190 system("cat RELEASE-INSTRUCTIONS");
191
192 # makerelease ends here