]> Pileus Git - ~andy/fetchmail/blob - dist-tools/makerelease.pl
Update documents/scripts after SVN -> Git move.
[~andy/fetchmail] / dist-tools / makerelease.pl
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 $tmp = $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp";
9
10 die "This script ($0) needs to be updated for the Git-orious repo.";
11
12 $project = "fetchmail";
13 $svnrepos = "http://mknod.org/svn/$project";
14 $website = "http://developer.berlios.de/projects/$project";
15 $mailfrom = "<$project-devel-owner\@lists.berlios.de> (Fetchmail Development Team)";
16
17 die "Need GNU sort!" unless `sort --version | head -n1` =~ /GNU/;
18
19 # parse options
20 $diffs = 0;
21 $verbose = 0;
22 $null = ">/dev/null";
23 $errnull = "2>/dev/null";
24 while ($i = shift @ARGV)
25 {
26         if ($i =~ /^(--diffs|-d)$/i)
27         {
28                 $diffs = 1;
29                 next;
30         }
31
32         if ($i =~ /^(--verbose|-v)$/i)
33         {
34                 $verbose = 1;
35                 $null = "";
36                 next;
37         }
38
39         die "Error: Unknown option: $i\n";
40 }
41
42 # extract version from source
43 $version=`grep 'AC_INIT' configure.ac`;
44 $version =~ /AC_INIT\([^,]*,\[?([0-9.rc-]+)\]?\,.*\)/;
45 $version = $1;
46 die "cannot determine version" unless defined $1;
47 $tag = "RELEASE_$version";
48 $tag =~ tr/./-/;
49
50 # extract existing tags
51 open(ID, "svn ls \"$svnrepos/tags\" | sort -t- -k1,1 -k2,2n -k3,3n |") || die "cannot run svn ls: $!\naborting";
52 while (<ID>) {
53     if (m{^(RELEASE_.*)/}) {
54         unshift(@versions, $1);
55     }
56 }
57 close ID || die "svn ls  failed, aborting";
58
59 if ($versions[0] eq $tag) {
60     $tag = $versions[0];
61     $oldtag = $versions[1];
62 } else {
63     $tag = '<workfile>';
64     $oldtag = $versions[0];
65 }
66
67 $pwd = `pwd`; chomp $pwd;
68
69 $ENV{PATH} .= ":$pwd/dist-tools:$pwd/dist-tools/shipper";
70
71 print "Building $version release, tag $tag, previous tag $oldtag\n";
72
73 if (-d "autom4te.cache") {
74     system("rm -rf autom4te.cache")
75         and die "Failure in removing autom4te.cache";
76 }
77
78 if (system("autoreconf -isv")) {
79         die("Failure in regenerating autoconf files\n");
80 }
81
82 print "### Test-building the software...\n";
83 if (system("mkdir -p autobuild && cd autobuild && ../configure -C --silent && make -s clean && make check distcheck")) {
84         die("Compilation failure\n");
85 }
86
87 # print "### Building the RPMs...\n";
88 # if (system("cd autobuild && cp ../fetchmail.xpm . && buildrpms $project-${version}.tar.bz2 $null")) {
89 #       die("RPM-build failure\n");
90 # }
91
92 open(REPORT, ">$tmp/$project.PREAMBLE.$$");
93
94 print REPORT <<EOF;
95 From: $mailfrom
96 Subject: The $version release of $project is available
97
98 The $version release of $project is now available at the usual locations,
99 including <$website>.
100
101 The source archive is available at:
102 <$website/$project-${version}.tar.gz>
103
104 Here are the release notes:
105
106 EOF
107
108 # Extract the current notes
109 open(NEWS, "NEWS");
110 while (<NEWS>) {
111     if (/^$project/) {
112         print REPORT $_;
113         last;
114     }
115 }
116 while (<NEWS>) {
117     if (/^$project/) {
118         last;
119     }
120     print REPORT $_;
121 }
122
123 $oldver = $oldtag;
124 $oldver =~ tr/-/./;
125 $oldver =~ s/^RELEASE_//;
126
127 if ($diffs) {
128         print REPORT "Diffs from the previous ($oldver) release follow as a MIME attachment."
129 } else {
130         print REPORT "By popular demand, diffs from the previous release have been omitted."
131 }
132
133 close(NEWS);
134
135 close(REPORT);
136
137 if ($tag eq '<workfile>') {
138     system("svn diff -r$oldtag        $errnull >$tmp/$project.DIFFS.$$");
139 } else {
140     system("svn diff -r$oldtag -r$tag $errnull >$tmp/$project.DIFFS.$$");
141 }
142 print "Diff size:";
143 system("wc <$tmp/$project.DIFFS.$$");
144
145 if ($diffs) {
146         system "metasend -b"
147             ." -D '$project-$tag announcement' -m 'text/plain' -e 7bit -f $tmp/$project.PREAMBLE.$$"
148             ." -n -D 'diff between $oldver and $version' -m 'text/plain' -e 7bit -f $tmp/$project.DIFFS.$$"
149             ." -o ANNOUNCE.EMAIL";
150 } else {
151         system("mv", "$tmp/$project.PREAMBLE.$$", "ANNOUNCE.EMAIL");
152 }
153
154 #unlink("$tmp/$project.PREAMBLE.$$");
155 unlink("$tmp/$project.DIFFS.$$");
156
157 print "Done\n";
158
159 # makerelease ends here