Back to home page

Wine source

 
 

    


File indexing completed on 2024-01-05 23:36:03

4bc2cbef0 Alex*0001 #!/usr/bin/perl -w
                0002 #
                0003 # Update the ANNOUNCE file for a new release.
                0004 #
                0005 # Usage: make_announce [new_version]
                0006 #
                0007 # Copyright 2016 Alexandre Julliard
                0008 #
                0009 # This library is free software; you can redistribute it and/or
                0010 # modify it under the terms of the GNU Lesser General Public
                0011 # License as published by the Free Software Foundation; either
                0012 # version 2.1 of the License, or (at your option) any later version.
                0013 #
                0014 # This library is distributed in the hope that it will be useful,
                0015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
                0016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                0017 # Lesser General Public License for more details.
                0018 #
                0019 # You should have received a copy of the GNU Lesser General Public
                0020 # License along with this library; if not, write to the Free Software
                0021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
                0022 #
                0023 
                0024 use strict;
                0025 use locale;
                0026 use POSIX;
                0027 use Text::CSV::Encoded;
b6a091a2b Alex*0028 use open ':encoding(utf8)';
4bc2cbef0 Alex*0029 
                0030 sub unescape($)
                0031 {
                0032     my $str = shift;
                0033     $str =~ s/"/\"/g;
                0034     $str =~ s/'/\'/g;
                0035     $str =~ s/&/&/g;
                0036     $str =~ s/&lt;/</g;
                0037     $str =~ s/&gt;/>/g;
                0038     $str =~ s/&#64;/\@/g;
                0039     return $str;
                0040 }
                0041 
                0042 # update a file if changed
                0043 sub update_file($)
                0044 {
                0045     my $file = shift;
                0046     if (!(-f $file) || system "cmp $file $file.new >/dev/null")
                0047     {
                0048         rename "$file.new", "$file";
                0049         print "$file updated\n";
                0050     }
                0051     else
                0052     {
                0053         unlink "$file.new";
                0054     }
                0055 }
                0056 
                0057 # determine the current version number
                0058 sub get_current_version()
                0059 {
                0060     my $version;
                0061 
                0062     open VERSION, "<VERSION" or die "cannot open VERSION";
                0063     if (<VERSION> =~ /Wine version (\S+)/) { $version = $1; }
                0064     close VERSION;
                0065     die "failed to parse VERSION" unless $version;
                0066     return $version;
                0067 }
                0068 
                0069 # retrieve a list of bugs with the specified filter
                0070 sub get_bugs($)
                0071 {
                0072     my $filter = shift;
                0073     my $csv = Text::CSV::Encoded->new({ encoding_in => "utf-8", encoding_out => "utf-8" });
                0074     my %bugs;
                0075 
                0076     open QUERY, "-|" or exec "wget", "-qO-", "https://bugs.winehq.org/buglist.cgi?columnlist=short_desc&query_format=advanced&ctype=csv&$filter"
                0077         or die "cannot query bug list";
                0078     <QUERY>;  # skip header line
                0079     while (<QUERY>)
                0080     {
                0081         next unless $csv->parse($_);
                0082         my ($id, $descr) = $csv->fields();
                0083         $bugs{$id} = $descr;
                0084     }
                0085     close QUERY;
                0086     return %bugs;
                0087 }
                0088 
                0089 # retrieve the current list of authors
                0090 sub get_authors()
                0091 {
                0092     my %authors;
                0093 
                0094     open AUTHORS, "<AUTHORS" or die "cannot open AUTHORS";
                0095     <AUTHORS>;  # skip header line
                0096     while (<AUTHORS>)
                0097     {
                0098         chomp;
                0099         next if /^$/;
                0100         $authors{$_} = 1;
                0101     }
                0102     close AUTHORS;
                0103     return %authors;
                0104 }
                0105 
                0106 # determine the version number
                0107 
                0108 my $old = get_current_version();
                0109 my $new = $ARGV[0];
                0110 unless ($new)
                0111 {
9629bb6ad Alex*0112     if ($old =~ /^([0-9]+)\.([0-9]+)$/) { $new = "$1." . ($2 + 1); }
4bc2cbef0 Alex*0113     elsif ($old =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/) { $new = "$1.$2." . ($3 + 1); }
                0114     elsif ($old =~ /^([0-9]+)\.([0-9]+)-rc([0-9]+)$/) { $new = "$1.$2-rc" . ($3 + 1); }
                0115     else { die "unknown version format $old"; }
                0116 }
                0117 
                0118 print "Updating files for release $new\n";
                0119 
9629bb6ad Alex*0120 my $reldir = $new;
                0121 if ($reldir =~ /^([0-9]+\.0)/) { $reldir = $1; }
                0122 elsif ($reldir =~ /^([0-9]+)\./) { $reldir = "$1.x"; }
                0123 else { die "unknown version format $reldir"; }
                0124 
                0125 my $is_stable = ($new =~ /^([0-9]+)\.0\.([0-9]+)$/);  # stable releases have a 0 minor number
4bc2cbef0 Alex*0126 my $filter = "product=Wine&resolution=FIXED&" . ($is_stable ? "target_milestone=$reldir.x" : "bug_status=RESOLVED");
                0127 
                0128 my %bugs = get_bugs( $filter );
                0129 my %authors = get_authors();
                0130 
                0131 # update the ANNOUNCE file
                0132 
62cb2bcdc Alex*0133 open ANNOUNCE, "<ANNOUNCE.md" or die "cannot open ANNOUNCE.md";
                0134 open NEW, ">ANNOUNCE.md.new" or die "cannot create ANNOUNCE.md.new";
9629bb6ad Alex*0135 
                0136 # replace version number in first line
                0137 $_ = <ANNOUNCE>;
                0138 s/(([0-9]+)\.)+[0-9]+(-rc[0-9]+)?/$new/;
                0139 print NEW $_;
                0140 
4bc2cbef0 Alex*0141 while (<ANNOUNCE>)
                0142 {
                0143     last if /^------------------/;
62cb2bcdc Alex*0144     s!(https://.*/wine/source/).*\.tar!$1$reldir/wine-$new.tar!;
                0145     s/wine-(([0-9]+)\.)+[0-9]+(-rc[0-9]+)?/wine-$new/g;
4bc2cbef0 Alex*0146     print NEW $_;
                0147 }
62cb2bcdc Alex*0148 close ANNOUNCE;
4bc2cbef0 Alex*0149 
                0150 print NEW "----------------------------------------------------------------\n\n";
62cb2bcdc Alex*0151 printf NEW "### Bugs fixed in %s (total %u):\n\n", $new, scalar( keys %bugs );
4bc2cbef0 Alex*0152 foreach my $id (sort {$a <=> $b} keys %bugs)
                0153 {
a1af41248 Alex*0154     printf NEW " - #%-6d %s\n", $id, unescape( $bugs{$id} );
4bc2cbef0 Alex*0155 }
                0156 
62cb2bcdc Alex*0157 print NEW "\n### Changes since $old:\n```\n";
4bc2cbef0 Alex*0158 
62cb2bcdc Alex*0159 my @shortlog = ();
4bc2cbef0 Alex*0160 open LOG, "-|" or exec "git", "shortlog", "wine-$old..HEAD" or die "cannot run git shortlog";
                0161 while (<LOG>)
                0162 {
a1af41248 Alex*0163     next if /^$/;
62cb2bcdc Alex*0164     if (/^(\S.*)\s\(\d+\):$/) { $authors{$1} = 1; push @shortlog, "\n" if @shortlog; }
                0165     push @shortlog, $_;
4bc2cbef0 Alex*0166 }
                0167 close LOG;
62cb2bcdc Alex*0168 print NEW join("",@shortlog);
                0169 print NEW "```\n";
4bc2cbef0 Alex*0170 close NEW;
62cb2bcdc Alex*0171 update_file( "ANNOUNCE.md" );
4bc2cbef0 Alex*0172 
                0173 # update the AUTHORS file
                0174 
                0175 setlocale( LC_COLLATE, "en_US.UTF-8" );
                0176 
                0177 open AUTHORS, ">AUTHORS.new" or die "cannot create AUTHORS.new";
                0178 print AUTHORS "Wine is available thanks to the work of:\n\n", join( "\n", sort keys %authors ), "\n";
                0179 close AUTHORS;
                0180 update_file( "AUTHORS" );