source: branches/2.0.8/tools/mkchangelog.pl @ 656

Last change on this file since 656 was 656, checked in by bcornec, 13 years ago

Debian build continued

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates changelog for packages from Changelog files in the apps
4#
5# $Id$
6#
7# Syntax : mkchangelog dtype package-name output-file
8#
9
10use strict;
11use Date::Manip;
12use File::Basename;
13use English;
14
15my $log = "";
16my $dtype = $ARGV[0];
17my $pkg = $ARGV[1];
18my $pkg2;
19my $outfile = $ARGV[2];
20my $chglog = "";
21my $ndate = "";
22my $n2date = "";
23my $tmp = "";
24my $ver = "";
25my $date = "";
26
27# For date handling
28$ENV{LANG}="C";
29
30die "Syntax : mkchangelog dtype package-name output-file" 
31    if ((not (defined $dtype)) || ($dtype eq "") || 
32        (not (defined $pkg)) || ($pkg eq "") || 
33        (not (defined $outfile)) || ($outfile eq ""));
34
35my $TOOLHOME;
36$tmp = dirname($PROGRAM_NAME);
37if ($tmp =~ /^\//) {
38    $TOOLHOME = $tmp;
39    }
40else {
41    $TOOLHOME = "$ENV{PWD}/$tmp";
42    }
43
44die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
45
46if (-f "$TOOLHOME/../$pkg/ChangeLog") {
47    $chglog = "$TOOLHOME/../$pkg/ChangeLog";
48    }
49else {
50    $pkg2 = $pkg;
51    $pkg2 =~ s/-..*//;
52    if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
53        $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
54        }
55    else {
56        die "Unable to find a ChangeLog file for $pkg\n";
57    }
58}
59print "Using $chglog as input ChangeLog file for $pkg\n";
60
61open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
62open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
63# Skip first 4 lines
64$tmp = <INPUT>;
65$tmp = <INPUT>;
66$tmp = <INPUT>;
67if ($dtype eq "announce") {
68    print OUTPUT $tmp;
69}
70$tmp = <INPUT>;
71if ($dtype eq "announce") {
72    print OUTPUT $tmp;
73}
74
75# Handle each block separated by newline
76while (<INPUT>) {
77    ($ver, $date) = split(/ /);
78    chomp($date);
79    $date =~ s/\(([0-9-]+)\)/$1/;
80    #print "**$date**\n";
81    $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
82    $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
83    #print "**$ndate**\n";
84    if ($dtype eq "rpm") {
85        print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
86        print OUTPUT "- Updated to $ver\n";
87        }
88    if ($dtype eq "deb") {
89        print OUTPUT "$pkg ($ver) unstable; urgency=low\n";
90        print OUTPUT "\n";
91        }
92
93    $tmp = <INPUT>; 
94    while ($tmp !~ /^$/) {
95        print OUTPUT "  * $tmp";
96        last if (eof(INPUT));
97        $tmp = <INPUT>;
98    }
99    print OUTPUT "\n";
100
101    if ($dtype eq "deb") {
102        print OUTPUT " -- Bruno Cornec <bruno\@mondorescue.org>  $n2date\n\n";
103        print OUTPUT "\n";
104        }
105
106    last if (eof(INPUT));
107    last if ($dtype eq "announce");
108}
109close(OUTPUT);
110close(INPUT);
Note: See TracBrowser for help on using the repository browser.