]> Pileus Git - ~andy/fetchmail/blob - dist-tools/makerelease
bcb94c3af7f528451f9872c18d3585e3dbfa6ef0
[~andy/fetchmail] / dist-tools / makerelease
1 #!/usr/bin/env perl
2 #
3 # Make a fetchmail release.
4 # Dumps a release notice and diffs as a MIME multipart message 
5 # in RELEASE_NOTES
6 #
7 use POSIX qw(strftime);
8 $timezone = strftime('%z', localtime) || "-0500";
9 $tmp = $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp";
10
11 $project = "fetchmail";
12 $svnrepos = "https://decoy.wox.org/svn/$project";
13 $website = "http://developer.berlios.de/projects/$project";
14 $mailfrom = "<$project-devel-owner\@lists.berlios.de> (Fetchmail Development Team)";
15
16 # parse options
17 $diffs = 0;
18 $verbose = 0;
19 $null = ">/dev/null";
20 $errnull = "2>/dev/null";
21 while ($i = shift @ARGV)
22 {
23         if ($i =~ /^(--diffs|-d)$/i)
24         {
25                 $diffs = 1;
26                 next;
27         }
28
29         if ($i =~ /^(--verbose|-v)$/i)
30         {
31                 $verbose = 1;
32                 $null = "";
33                 next;
34         }
35
36         die "Error: Unknown option: $i\n";
37 }
38
39 # extract version from source
40 $version=`grep 'AC_INIT' configure.ac`;
41 $version =~ /AC_INIT\([^,]*,\[?([0-9.rc-]+)\]?\)/;
42 $version = $1;
43 die "cannot determine version" unless defined $1;
44 $tag = "RELEASE_$version";
45 $tag =~ tr/./-/;
46
47 # extract existing tags
48 open(ID, "-|", "svn", "ls", $svnrepos . "/tags") || die "cannot run svn ls: $!\naborting";
49 while (<ID>) {
50     if (m{^(RELEASE_.*)/}) {
51         unshift(@versions, $1);
52     }
53 }
54 close ID || die "svn ls  failed, aborting";
55
56 if ($versions[0] eq $tag) {
57     $tag = $versions[0];
58     $oldtag = $versions[1];
59 } else {
60     $tag = '<workfile>';
61     $oldtag = $versions[0];
62 }
63
64 $ENV{PATH} .= ":./dist-tools:./dist-tools/shipper:.";
65
66 print "Building $version release, tag $tag, previous tag $oldtag\n";
67
68 if (-d autom4te.cache) {
69     system("rm -rf autom4te.cache")
70         and die "Failure in removing autom4te.cache";
71 }
72
73 if (system("autoreconf -isv")) {
74         die("Failure in regenerating autoconf files\n");
75 }
76
77 if (system("./configure && make clean && make -C po update-po && make clean")) {
78         die("Failure in translation-file rebuild\n");
79 }
80
81 print "### Test-building the software...\n";
82 if (system("./configure && make clean && make distcheck")) {
83         die("Compilation failure\n");
84 }
85
86 print "### Building the distribution...\n";
87 if (system("make dist $null")) {
88         die("Distribution-build failure\n");
89 }
90
91 print "### Building the RPMs...\n";
92 if (system("buildrpms $project-${version}.tar.gz $null")) {
93         die("RPM-build failure\n");
94 }
95
96 open(REPORT, ">$tmp/$project.PREAMBLE.$$");
97
98 print REPORT <<EOF;
99 From: $mailfrom
100 Subject: The $version release of $project is available
101
102 The $version release of $project is now available at the usual locations,
103 including <URL:$website>.
104
105 The source archive is available at:
106 <URL:$website/$project-${version}.tar.gz>
107
108 Here are the release notes:
109
110 EOF
111
112 # Extract the current notes
113 open(NEWS, "NEWS");
114 while (<NEWS>) {
115     if (/^$project/) {
116         print REPORT $_;
117         last;
118     }
119 }
120 while (<NEWS>) {
121     if (/^$project/) {
122         last;
123     }
124     print REPORT $_;
125 }
126
127 $oldver = $oldtag;
128 $oldver =~ tr/-/./;
129 $oldver =~ s/^RELEASE_//;
130
131 if ($diffs) {
132         print REPORT "Diffs from the previous ($oldver) release follow as a MIME attachment."
133 } else {
134         print REPORT "By popular demand, diffs from the previous release have been omitted."
135 }
136
137 close(NEWS);
138
139 close(REPORT);
140
141 if ($tag eq '<workfile>') {
142     system("svn diff -r$oldtag        $errnull >$tmp/$project.DIFFS.$$");
143 } else {
144     system("svn diff -r$oldtag -r$tag $errnull >$tmp/$project.DIFFS.$$");
145 }
146 print "Diff size:";
147 system("wc <$tmp/$project.DIFFS.$$");
148
149 if ($diffs) {
150         system "metasend -b"
151             ." -D '$project-$tag announcement' -m 'text/plain' -e 7bit -f $tmp/$project.PREAMBLE.$$"
152             ." -n -D 'diff between $oldver and $version' -m 'text/plain' -e 7bit -f $tmp/$project.DIFFS.$$"
153             ." -o ANNOUNCE.EMAIL";
154 } else {
155         rename("$tmp/$project.PREAMBLE.$$", "ANNOUNCE.EMAIL");
156 }
157 #system("chown esr ANNOUNCE.EMAIL");
158 #chmod(0700, "ANNOUNCE.EMAIL");
159
160 #unlink("$tmp/$project.PREAMBLE.$$");
161 unlink("$tmp/$project.DIFFS.$$");
162
163 print "Building index page...\n";
164 system("rm -f index.html; indexgen.sh");
165
166 if (-r "testsites") {
167         print "Building test server list...\n";
168         system("rm -f testservers.html; testservers-gen.sh >testservers.html");
169 }
170
171 print "Making activity graph...";
172 system "growthplot";
173
174 print "Done\n";
175
176 # makerelease ends here