tools: Import make_announce changes from the devel tree.
[wine.git] / tools / make_announce
blobcd61cbb6bce4194455fddb88d13f8f01617445fe
1 #!/usr/bin/perl -w
3 # Update the ANNOUNCE file for a new release.
5 # Usage: make_announce [new_version]
7 # Copyright 2016 Alexandre Julliard
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 use strict;
25 use locale;
26 use POSIX;
27 use open ':encoding(utf8)';
29 sub unescape($)
31 my $str = shift;
32 $str =~ s/"/\"/g;
33 $str =~ s/'/\'/g;
34 $str =~ s/&/&/g;
35 $str =~ s/&lt;/</g;
36 $str =~ s/&gt;/>/g;
37 $str =~ s/&#64;/\@/g;
38 return $str;
41 # update a file if changed
42 sub update_file($)
44 my $file = shift;
45 if (!(-f $file) || system "cmp $file $file.new >/dev/null")
47 rename "$file.new", "$file";
48 print "$file updated\n";
50 else
52 unlink "$file.new";
56 # determine the current version number
57 sub get_current_version()
59 my $version;
61 open VERSION, "<VERSION" or die "cannot open VERSION";
62 if (<VERSION> =~ /Wine version (\S+)/) { $version = $1; }
63 close VERSION;
64 die "failed to parse VERSION" unless $version;
65 return $version;
68 # retrieve a list of bugs with the specified filter
69 sub get_bugs($)
71 my %bugs;
73 open QUERY, "-|" or exec "git", "log", "--notes=stable-notes", "--format=%N", "wine-" . get_current_version() . ".."
74 or die "cannot query bug list";
75 while (<QUERY>)
77 next unless /^Fixes: \[(\d+)\] (.*)/;
78 $bugs{$1} = $2;
80 close QUERY;
81 return %bugs;
84 # retrieve the current list of authors
85 sub get_authors()
87 my %authors;
89 open AUTHORS, "<AUTHORS" or die "cannot open AUTHORS";
90 <AUTHORS>; # skip header line
91 while (<AUTHORS>)
93 chomp;
94 next if /^$/;
95 $authors{$_} = 1;
97 close AUTHORS;
98 return %authors;
101 # determine the version number
103 my $old = get_current_version();
104 my $new = $ARGV[0];
105 unless ($new)
107 if ($old =~ /^([0-9]+)\.([0-9]+)$/) { $new = "$1." . ($2 + 1); }
108 elsif ($old =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) { $new = "$1.$2." . ($3 + 1); }
109 elsif ($old =~ /^([0-9]+)\.([0-9]+)-rc([0-9]+)$/) { $new = "$1.$2-rc" . ($3 + 1); }
110 else { die "unknown version format $old"; }
113 print "Updating files for release $new\n";
115 my $reldir = $new;
116 if ($reldir =~ /^([0-9]+\.0)/) { $reldir = $1; }
117 elsif ($reldir =~ /^([0-9]+)\./) { $reldir = "$1.x"; }
118 else { die "unknown version format $reldir"; }
120 my $is_stable = ($new =~ /^([0-9]+)\.0\.([0-9]+)$/); # stable releases have a 0 minor number
121 my $filter = "product=Wine&resolution=FIXED&" . ($is_stable ? "target_milestone=$reldir.x" : "bug_status=RESOLVED");
123 my %bugs = get_bugs( $filter );
124 my %authors = get_authors();
126 # update the ANNOUNCE file
128 open ANNOUNCE, "<ANNOUNCE" or die "cannot open ANNOUNCE";
129 open NEW, ">ANNOUNCE.new" or die "cannot create ANNOUNCE.new";
131 # replace version number in first line
132 $_ = <ANNOUNCE>;
133 s/(([0-9]+)\.)+[0-9]+(-rc[0-9]+)?/$new/;
134 print NEW $_;
136 while (<ANNOUNCE>)
138 last if /^------------------/;
139 s!(https?://.*/wine/source/).*\.tar!$1$reldir/wine-$new.tar!;
140 print NEW $_;
143 print NEW "----------------------------------------------------------------\n\n";
144 printf NEW "Bugs fixed in %s (total %u):\n\n", $new, scalar( keys %bugs );
145 foreach my $id (sort {$a <=> $b} keys %bugs)
147 printf NEW " - #%-6d %s\n", $id, unescape( $bugs{$id} );
150 print NEW "\n----------------------------------------------------------------\n\n";
151 print NEW "Changes since $old:\n";
153 open LOG, "-|" or exec "git", "shortlog", "wine-$old..HEAD" or die "cannot run git shortlog";
154 while (<LOG>)
156 next if /^$/;
157 if (/^(\S.*)\s\(\d+\):$/) { $authors{$1} = 1; print NEW "\n"; }
158 print NEW $_;
160 close LOG;
161 close ANNOUNCE;
162 close NEW;
163 update_file( "ANNOUNCE" );
165 # update the AUTHORS file
167 setlocale( LC_COLLATE, "en_US.UTF-8" );
169 open AUTHORS, ">AUTHORS.new" or die "cannot create AUTHORS.new";
170 print AUTHORS "Wine is available thanks to the work of:\n\n", join( "\n", sort keys %authors ), "\n";
171 close AUTHORS;
172 update_file( "AUTHORS" );