source: subversion/applications/utils/packaging/svn_log2debian_changelog.pl @ 29923

Last change on this file since 29923 was 16551, checked in by joerg, 10 years ago

Add possibility to get a release changelog

  • Property svn:executable set to *
File size: 6.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use IO::File;
6use Getopt::Long;
7use Pod::Usage;
8use Time::Local;
9use POSIX qw(strftime);
10
11my $project_name="";
12
13my $append=0;
14my $release=0;
15my $prefix="";
16my $debug = 0;
17
18$ENV{'LANGUAGE'}="en_US";
19$ENV{'LANG'}="en_US";
20
21
22GetOptions (
23    'project_name:s'    => \$project_name,
24    'prefix:s'          => \$prefix,
25    'append'            => \$append,
26    'release:s'         => \$release,
27    'debug'             => \$debug,
28    ) or pod2usage(1);
29
30unless ( $project_name ) {
31    pod2usage(2);
32    die "No Projectname defined";
33}
34
35
36my $fi = IO::File->new("svn log . |");
37
38my $fo;
39if ( $append )  {
40    $fo = IO::File->new(">>debian/changelog");
41} else {
42    $fo = IO::File->new(">debian/changelog");
43}
44my ($rev,$user,$date,$lines) = ('','','','');
45my ($date_dummy,$date_time,$date_offset,$date_date) = ('','','','');
46my $t='@';
47my $user2full_name={
48    root        => "the Maintainer",
49    amillar     => "Alan Millar",
50    andystreet  => "",
51    artem       => "Artem Pavlenko",
52    ben         => "Ben Robinson",
53    bobkare     => "Knut Arne Bjørndal",
54    breki       => "Igor Brejic",
55    brent       => "",
56    bretth      => "Brett Henderson",
57    christofd   => "Christof Dallermassl",
58    damians     => "",
59    danmoore    => "Dan Moore",
60    david       => "David Earl <david${t}frankieandshadow.com>",
61    deelkar     => "Dirk-Lüder Kreie",
62    dennis_de   => "dennis_de",
63    dirkl       => "Dirk-Lüder Kreie now deelkar",
64    dotbaz      => "Barry Crabtree",
65    dshpak      => "Darryl Shpak",
66    enxrah      => "",
67    etienne     => "Etienne Cherdlu",
68    frederik    => "Frederik Ramm",
69    frsantos    => "Francisco R. Santos <frsantos${t}gmail.com> ",
70    gabriel     => "Gabriel Ebner",
71    gslater     => "Grant Slater",
72    guenther    => "Guenter Maier",
73    hakan       => "Hakan Tandogan",
74    harrywood   => "Harry Wood",
75    imi         => "Immanuel Scholz",
76    isortega    => "Iván Sánchez Ortega",
77    jdschmidt   => "J. D. 'Dutch' Schmidt",
78    jeroen      => "Jeroen Ticheler",
79    jochen      => "Jochen Topf",
80    joerg       => "Joerg Ostertag (Debian Packages) <debian${t}ostertag.name>",
81    jonas       => "",
82    jonb        => "Jon Burgess",
83    jrreid      => "Jason Reid",
84    ksharp      => "Keith Sharp",
85    lorenz      => "Lorenz Kiefner",
86    marc        => "",
87    martinvoosterhout   => "Martijn van Oosterhout",
88    matt_gnu    => "",
89    matthewnc   => "",
90    mstrecke    => "Michael Strecke <MStrecke${t}gmx.de>",
91    nick        => "",
92    nickb       => "Nick Black",
93    nickburch   => "Nick Burch",
94    ojw         => "Almién Oliver White <ojwlists${t}googlemail.com>",
95    pere        => "Petter Reinholdtsen",
96    richard     => "Richard Fairhurst",
97    spaetz      => "Sebastian Spaeth",
98    stefanb     => "Stefan B (Ljubljana, Slovenia)",
99    steve       => "Steve Coast",
100    t2000       => "",
101    tabacha     => "Sven Anders",
102    texamus     => "Artem Dudarev",
103    tim         => "",
104    tomhughes   => "Tom Hughes",
105    twalraet    => "Thomas Walraet",
106    tweety      => "Joerg Ostertag (Debian Packages) <debian${t}ostertag.name>",
107    ostertag    => "Joerg Ostertag (Debian Packages) <debian${t}ostertag.name>",
108    ulf         => "Ulf Lamping",
109    ulflulfl    => "Ulf Lamping",
110    charles     => "Charles Curley <charlescurley${t}charlescurley.com>",
111    cjastram    => "Christopher Jastram",
112    commiter    => "Taken from last tar File",
113    dse         => "Guenther Meyer <d.s.e${t}sordidmusic.com>",
114    d_s_e       => "Guenther Meyer <d.s.e${t}sordidmusic.com>",
115    ganter      => "Fritz Ganter",
116    gladiac     => "Andreas Schneider",
117    hamish      => "Hamish <hamish_b${t}yahoo.com>",
118    loom        => "Christoph Metz <loom${t}mopper.de>",
119    pollardd    => "\"David Pollard\" <david.pollard${t}optusnet.com.au>",
120    robstewart  => "Rob Stewart",
121};
122
123my %unknown_users=();
124sub print_user_line($$){
125    my $user = shift;
126    my $date = shift;
127
128    if ( $user ) {
129        my $full_name= $user2full_name->{$user};
130        if ( ! $full_name ) {
131            $unknown_users{$user}++;
132            $full_name = $user;
133        }
134        $full_name =~ s/^\((.*)\)$/$1/; #  (no author) --> no author
135        if ( $full_name =~ m/\@/ ) {
136            $full_name =~ s/\@/ via the domain /;
137            $full_name =~ s/</(/;
138            $full_name =~ s/>/)/;
139        }
140        if ( $full_name !~ m/\@/ ) {
141            #my $fake_e_mail=$full_name;
142            #$fake_e_mail=~ s/ /_/g;
143            #$full_name = "$full_name <$fake_e_mail-fake-tmf\@gpsdrive.de>";
144            if ( $project_name =~ m/gpsdrive/ ) {
145                $full_name = "$full_name via GPSdrive discussion list <gpsdrive\@lists.gpsdrivers.org>";
146            } else {
147                $full_name = "$full_name via osm-dev List <dev\@openstreetmap.org>";
148            }
149        }
150
151#       print "Date: $date\n";
152        my ($date_dummy,$date_time,$date_offset,$date_date) = split(m/\s+/,$date,4);
153        $date_date =~ s/[\(\)]//g;
154
155        print $fo "\n -- $full_name  $date_date $date_time $date_offset\n\n";
156    }
157}
158
159my $commitmessage_seen=0;
160my $entry_no=0;
161
162if ( $release ) {
163    print $fo "$project_name (${release}) unstable; urgency=med\n";
164    print $fo "\n";
165    print $fo "   * Release";
166    print $fo "-Candidate" if $release =~ m/rc\d+/;
167    print $fo "-Pre Version" if $release =~ m/pre\d+/;
168    print $fo " $project_name-${release}\n";
169    my $date=strftime("%Y-%m-%d %T %Z %z (%a, %d %B %Y)",localtime(time()));
170    $date =~ s/CEST\s*//;
171
172    print_user_line("ostertag",$date);
173    print $fo "\n";
174}
175
176
177
178while ( my $line = $fi->getline()) {
179    if ( $line =~ m/^-+$/) {
180        if ( $entry_no && ! $commitmessage_seen ) {
181            print $fo "   * no Commit Message\n";
182            print $fo "\n"
183        }
184        $entry_no++;
185        $commitmessage_seen=0;
186        next;
187    } elsif ( $line =~ m/^r\d+.*\|.*\|.*line/ ) {
188        print_user_line($user,$date);
189        ($rev,$user,$date,$lines) = split(m/\s*\|\s*/,$line);
190        ($date_dummy,$date_time,$date_offset,$date_date) = split(m/\s+/,$date,4);
191        $date_date =~ s/[\(\)]//g;
192        $rev =~ s/^r//;
193
194        print $fo "$project_name (${prefix}$rev) unstable; urgency=low\n\n";
195    } elsif ( $line=~ m/^\s*$/ ) {
196#       print $fo "\n";
197    } else {
198        print $fo "   * $line";
199        $commitmessage_seen++;
200    }
201};
202print_user_line($user,$date);
203
204$fi->close();
205$fo->close();
206
207if ( $debug ) {
208    if ( keys %unknown_users ) {
209        warn "Unknown Users:\n\t".
210            join("\n\t",sort keys %unknown_users).
211            "\n";
212    }
213};
214
215exit 0;
216
217__END__
218=head1 NAME
219
220svn_log2debian_changelog.pl - convert svn log to a debian/changelog
221
222=head1 SYNOPSIS
223
224svn_log2debian_changelog.pl tries to fetch the current svn changelog and
225convert it into a valid debian changelog.
226
227
228svn_log2debian_changelog.pl --project_name="openstreetmap-utils" --prefix="2.10svn" --append
229
230    --prefix=<prefix>
231      Prefix is added as a prefix in front of each svn-revision to
232      get the debian revision number.
233
234    --append
235         Append to an existing File
236
237    --release=<Release-Version>
238         Build a release changelog.
239         Release-Version could be something like 2.10pre7
240
241    --debug
242         also printout which users could not be inserted with there full name
243
244
245
246=head1 RESULT
247
248 #############################################
249 # Example of the result:
250
251 openstreetmap-utils (7572) unstable; urgency=low
252
253  * Initial Version
254 
255 -- Joerg Ostertag (Debian Packages) via GPSdrive discussion list <gpsdrive\@lists.gpsdrivers.org>  Fri, 1 Jan 2007 07:05:36 +0100
256
Note: See TracBrowser for help on using the repository browser.